class Praxis::Docs::OpenApi::ResponsesObject

Attributes

Public Class Methods

new(responses:) click to toggle source
# File lib/praxis/docs/open_api/responses_object.rb, line 12
def initialize(responses:)
  @responses = responses
end

Public Instance Methods

dump() click to toggle source
# File lib/praxis/docs/open_api/responses_object.rb, line 16
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