Class: Eazypi::RequestBody
- Inherits:
-
Object
- Object
- Eazypi::RequestBody
- Includes:
- SpecObject
- Defined in:
- lib/eazypi/request_body.rb
Overview
OpenAPI spec RequestBodyObject
Instance Method Summary collapse
- #collect_components(**kwargs) ⇒ Object
- #content(body_schema, content_type: "application/json") ⇒ Object
-
#initialize(&block) ⇒ RequestBody
constructor
A new instance of RequestBody.
- #to_openapi_spec ⇒ Object
Methods included from SpecObject
Constructor Details
#initialize(&block) ⇒ RequestBody
Returns a new instance of RequestBody.
11 12 13 14 15 |
# File 'lib/eazypi/request_body.rb', line 11 def initialize(&block) @content = {} super end |
Instance Method Details
#collect_components(**kwargs) ⇒ Object
23 24 25 26 27 |
# File 'lib/eazypi/request_body.rb', line 23 def collect_components(**kwargs) @content&.each_value do |media_type| media_type.collect_components(**kwargs) end end |
#content(body_schema, content_type: "application/json") ⇒ Object
17 18 19 20 21 |
# File 'lib/eazypi/request_body.rb', line 17 def content(body_schema, content_type: "application/json") @content[content_type] = MediaType.new do schema Eazypi::Schema.from_object(body_schema) end end |
#to_openapi_spec ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/eazypi/request_body.rb', line 29 def to_openapi_spec { "description" => description, "content" => @content.transform_values(&:to_openapi_spec), "required" => required }.compact end |