Sha256: d93c2ec5fa5cc738768ca1dd2afbd9fdf4ccdd2faa32673fe88be4238d61e810

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

# TODO: support extended property

module OpenAPIParser::Schemas
  class Responses < Base
    # @!attribute [r] default
    #   @return [Response, Reference, nil]
    openapi_attr_object :default, Response, reference: true

    # @!attribute [r] response
    #   @return [Hash{String => Response, Reference}, nil]
    openapi_attr_hash_body_objects 'response', Response, reject_keys: [:default], allow_reference: true, allow_data_type: false

    def validate_response_body(status_code, content_type, params)
      # TODO: support wildcard status code like 2XX
      return nil unless response

      res = response[status_code.to_s]
      return res.validate_parameter(content_type, params) if res


      default&.validate_parameter(content_type, params)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openapi_parser-0.1.5 lib/openapi_parser/schemas/responses.rb
openapi_parser-0.1.4 lib/openapi_parser/schemas/responses.rb
openapi_parser-0.1.3 lib/openapi_parser/schemas/responses.rb