Sha256: 73518b8546f0931f670e95b9d542777d33140c06cc0072a04fbcd0d66c496535
Contents?: true
Size: 1.24 KB
Versions: 15
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true # :reek:UtilityFunction # :reek:InstanceVariableAssumption # :reek:TooManyStatements # :reek:TooManyInstanceVariables module SwaggerDocsGenerator module Actions # # Test :response # # Complete description field for action class Response def initialize(&block) instance_eval(&block) if block_given? end def to_hash { @status.to_s => construct } end private def construct element = {} element.merge!(description: @description || default_description) element.merge!(schema: @schema) if @schema.present? element.merge!(header: @header) if @header.present? element.merge!(example: @example) if @example.present? element end def status(text) @status = text end def description(text) @description = text end def default_description Rack::Utils::HTTP_STATUS_CODES[@status] end def header(text) @header = text end def example(text) @example = text end def schema(&block) @schema = SwaggerDocsGenerator::Actions::Schema.new(&block).to_hash end end end end
Version data entries
15 entries across 15 versions & 1 rubygems