Class: OpenapiFirst::Definition::RequestBody
- Inherits:
-
Object
- Object
- OpenapiFirst::Definition::RequestBody
- Defined in:
- lib/openapi_first/definition/request_body.rb
Overview
Represents a request body definition in the OpenAPI document that belongs to an operation.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(request_body_object, operation) ⇒ RequestBody
constructor
A new instance of RequestBody.
- #required? ⇒ Boolean
- #schema_for(content_type) ⇒ Object
Constructor Details
#initialize(request_body_object, operation) ⇒ RequestBody
9 10 11 12 |
# File 'lib/openapi_first/definition/request_body.rb', line 9 def initialize(request_body_object, operation) @request_body_object = request_body_object @operation = operation end |
Instance Method Details
#description ⇒ Object
14 15 16 |
# File 'lib/openapi_first/definition/request_body.rb', line 14 def description @request_body_object['description'] end |
#required? ⇒ Boolean
18 19 20 |
# File 'lib/openapi_first/definition/request_body.rb', line 18 def required? !!@request_body_object['required'] end |
#schema_for(content_type) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/openapi_first/definition/request_body.rb', line 22 def schema_for(content_type) content = @request_body_object['content'] return unless content&.any? content_schemas&.fetch(content_type) do type = content_type.split(';')[0] content_schemas[type] || content_schemas["#{type.split('/')[0]}/*"] || content_schemas['*/*'] end end |