class R2OAS::Schema::V3::Components::RequestBodyObject
Public Class Methods
new(route_data, path, opts = {})
click to toggle source
Calls superclass method
R2OAS::Schema::V3::BaseObject::new
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 12 def initialize(route_data, path, opts = {}) super(opts) @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] # MEMO: # Allow primitive types that cannot be passed by reference to be passed by reference # This is Compromise @ref = { schema_name: @schema_name, tag_name: @tag_name, verb: @verb } end
Public Instance Methods
generate?()
click to toggle source
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 51 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()
click to toggle source
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 26 def to_doc create_doc do child_file_manager = ComponentsFileManager.new("#/components/schemas/#{_components_schema_name}", :ref) schema_object = Components::SchemaObject.new(@route_data, @path, @opts) 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 doc end
Private Instance Methods
_components_request_body_name()
click to toggle source
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 76 def _components_request_body_name @schema_name end
_components_schema_name()
click to toggle source
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 72 def _components_schema_name @schema_name end
create_doc() { || ... }
click to toggle source
# File lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb, line 58 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