Sha256: 089f11c45b443bceef36cd6246100e062d5a72808f5c7c4b9c010cf82b6bd805

Contents?: true

Size: 1.11 KB

Versions: 38

Compression:

Stored size: 1.11 KB

Contents

# TODO: support extended property

module OpenAPIParser::Schemas
  class RequestBody < Base
    include OpenAPIParser::MediaTypeSelectable

    # @!attribute [r] description
    #   @return [String] description data
    # @!attribute [r] required
    #   @return [Boolean] required bool data
    openapi_attr_values :description, :required

    # @!attribute [r] content
    #   @return [Hash{String => MediaType}, nil] content type to MediaType object
    openapi_attr_hash_object :content, MediaType, reference: false

    # @param [String] content_type
    # @param [Hash] params
    # @param [OpenAPIParser::SchemaValidator::Options] options
    def validate_request_body(content_type, params, options)
      media_type = select_media_type(content_type)
      return params unless media_type

      media_type.validate_parameter(params, options)
    end

    # select media type by content_type (consider wild card definition)
    # @param [String] content_type
    # @return [OpenAPIParser::Schemas::MediaType, nil]
    def select_media_type(content_type)
      select_media_type_from_content(content_type, content)
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
openapi_parser-2.2.2 lib/openapi_parser/schemas/request_body.rb
openapi_parser-2.2.1 lib/openapi_parser/schemas/request_body.rb
openapi_parser-2.2.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-2.1.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-2.0.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser_firetail-1.0.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-1.0.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-1.0.0.beta1 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.15.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.14.1 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.14.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.13.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.12.1 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.12.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.11.2 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.11.1 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.11.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.10.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.9.0 lib/openapi_parser/schemas/request_body.rb
openapi_parser-0.8.0 lib/openapi_parser/schemas/request_body.rb