Sha256: d568e0de743a0110299ba98ba93dc7edf4ec7f07c28f7e4dcca989da7e6afdbc

Contents?: true

Size: 971 Bytes

Versions: 3

Compression:

Stored size: 971 Bytes

Contents

require 'oas_objs/media_type_obj'
require 'oas_objs/helpers'

module OpenApi
  module DSL
    # https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/3.0.0.md#responseObject
    class ResponseObj < Hash
      include Helpers

      attr_accessor :processed, :code, :media_type
      def initialize(code, desc, media_type, schema_hash)
        self.code       = "#{code}"
        self.media_type = MediaTypeObj.new(media_type, schema_hash)
        self.processed  = { description: desc }
      end

      def process
        assign(media_type.process).to_processed 'content'
        { code => processed }
      end
    end
  end
end


__END__

Response Object Examples

Response of an array of a complex type:

{
  "description": "A complex object array response",
  "content": {
    "application/json": {
      "schema": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/VeryComplexType"
        }
      }
    }
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zero-rails_openapi-1.1.1 lib/oas_objs/response_obj.rb
zero-rails_openapi-1.1.0 lib/oas_objs/response_obj.rb
zero-rails_openapi-1.0.0 lib/oas_objs/response_obj.rb