Sha256: 21ed69c80514a411f56250f46af528548c7b313ac554df73ebefebc3772d5f8c

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 KB

Contents

require_relative 'response_object'

module Praxis
  module Docs
    module OpenApi
      class ResponsesObject
        # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#responses-object
        attr_reader :responses
        def initialize(responses:)
          @responses = responses
        end


        def dump
          # {
          #   "200": {
          #     "description": "a pet to be returned",
          #     "content": {
          #       "application/json": {
          #         "schema": {
          #           type: :object
          #         }
          #       }
          #     }
          #   },
          #   "default": {
          #     "description": "Unexpected error",
          #     "content": {
          #       "application/json": {
          #         "schema": {
          #           type: :object
          #         }
          #       }
          #     }
          #   }
          # }
          responses.each_with_object({}) do |(_response_name, response_definition), hash|
            hash[response_definition.status.to_s] = ResponseObject.new(info: response_definition).dump
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
praxis-2.0.pre.18 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.17 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.16 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.15 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.14 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.13 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.12 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.11 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.10 lib/praxis/docs/open_api/responses_object.rb
praxis-2.0.pre.9 lib/praxis/docs/openapi/responses_object.rb
praxis-2.0.pre.8 lib/praxis/docs/openapi/responses_object.rb
praxis-2.0.pre.7 lib/praxis/docs/openapi/responses_object.rb
praxis-2.0.pre.6 lib/praxis/docs/openapi/responses_object.rb
praxis-2.0.pre.5 lib/praxis/docs/openapi/responses_object.rb