Class: OpenAPIParser::Schemas::RequestBody

Inherits:
Base
  • Object
show all
Includes:
MediaTypeSelectable
Defined in:
lib/openapi_parser/schemas/classes.rb,
lib/openapi_parser/schemas/request_body.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#object_reference, #parent, #raw_schema, #root

Instance Method Summary collapse

Methods inherited from Base

#after_init, #initialize, #inspect

Methods included from Expandable

#expand_reference

Methods included from Findable

#find_object, #purge_object_cache

Methods included from Parser

#_openapi_all_child_objects, #_update_child_object, included, #load_data

Constructor Details

This class inherits a constructor from OpenAPIParser::Schemas::Base

Instance Attribute Details

#contentHash{String => MediaType}? (readonly)

Returns content type to MediaType object.

Returns:

  • (Hash{String => MediaType}, nil)

    content type to MediaType object



15
# File 'lib/openapi_parser/schemas/request_body.rb', line 15

openapi_attr_hash_object :content, MediaType, reference: false

#descriptionString (readonly)

Returns description data.

Returns:

  • (String)

    description data



11
# File 'lib/openapi_parser/schemas/request_body.rb', line 11

openapi_attr_values :description, :required

#requiredBoolean (readonly)

Returns required bool data.

Returns:

  • (Boolean)

    required bool data



11
# File 'lib/openapi_parser/schemas/request_body.rb', line 11

openapi_attr_values :description, :required

Instance Method Details

#select_media_type(content_type) ⇒ OpenAPIParser::Schemas::MediaType?

select media type by content_type (consider wild card definition)

Parameters:

  • content_type (String)

Returns:



30
31
32
# File 'lib/openapi_parser/schemas/request_body.rb', line 30

def select_media_type(content_type)
  select_media_type_from_content(content_type, content)
end

#validate_request_body(content_type, params, options) ⇒ Object

Parameters:



20
21
22
23
24
25
# File 'lib/openapi_parser/schemas/request_body.rb', line 20

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