Class: R2OAS::Schema::V3::Components::RequestBodyObject
- Inherits:
-
Plugins::Schema::V3::HookableBaseObject
- Object
- BaseObject
- Plugins::Schema::V3::HookableBaseObject
- R2OAS::Schema::V3::Components::RequestBodyObject
- Defined in:
- lib/r2-oas/schema/v3/object/components/request_body_object.rb
Instance Attribute Summary
Attributes inherited from Plugins::Schema::V3::HookableBaseObject
Instance Method Summary collapse
-
#components_request_body_name(_doc, _path_component, _tag_name, _verb, schema_name) ⇒ Object
MEMO: please override in inherited class.
-
#components_schema_name(_doc, _path_component, _tag_name, _verb, schema_name) ⇒ Object
MEMO: please override in inherited class.
- #create_doc ⇒ Object
- #generate? ⇒ Boolean
-
#initialize(route_data, path) ⇒ RequestBodyObject
constructor
A new instance of RequestBodyObject.
- #to_doc ⇒ Object
Methods inherited from Plugins::Schema::V3::HookableBaseObject
execute_hook, has_hook?, hook, hook=, hooks, inherited, off, on, #use_superclass_hook
Methods inherited from BaseObject
#components_object_class, #components_request_body_object_class, #components_schema_object_class, #external_document_object_class, #info_object_class, #path_item_object_class, #paths_object_class
Constructor Details
#initialize(route_data, path) ⇒ RequestBodyObject
Returns a new instance of RequestBodyObject.
11 12 13 14 15 16 17 18 19 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 11 def initialize(route_data, path) super() @path_comp = Routing::PathComponent.new(path) @path = @path_comp.symbol_to_brace @route_data = route_data @verb = route_data[:verb] @tag_name = route_data[:tag_name] @schema_name = route_data[:schema_name] end |
Instance Method Details
#components_request_body_name(_doc, _path_component, _tag_name, _verb, schema_name) ⇒ Object
MEMO: please override in inherited class.
70 71 72 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 70 def components_request_body_name(_doc, _path_component, _tag_name, _verb, schema_name) schema_name end |
#components_schema_name(_doc, _path_component, _tag_name, _verb, schema_name) ⇒ Object
MEMO: please override in inherited class.
64 65 66 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 64 def components_schema_name(_doc, _path_component, _tag_name, _verb, schema_name) schema_name end |
#create_doc ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 48 def create_doc file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref) doc.deep_merge!( 'content' => { 'application/json' => { 'schema' => { '$ref' => file_manager.original_path } } } ) yield if block_given? end |
#generate? ⇒ Boolean
74 75 76 77 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 74 def generate? file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref) (@verb.in? http_methods_when_generate_request_body) && !file_manager.skip_save? end |
#to_doc ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/r2-oas/schema/v3/object/components/request_body_object.rb', line 21 def to_doc execute_before_create(@schema_name) create_doc do child_file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref) schema_object = components_schema_object_class.new(@route_data, @path) unless child_file_manager.skip_save? result = { 'components' => { 'schemas' => { _components_schema_name => schema_object.to_doc } } } doc.deep_merge!( 'has_one' => { 'type' => 'schema', 'original_path' => child_file_manager.original_path, 'data' => result } ) end end execute_after_create(@schema_name) doc end |