Class: R2OAS::Schema::V3::PathItemObject

Inherits:
Dynamic::Schema::V3::HookableBaseObject show all
Extended by:
Forwardable
Defined in:
lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb

Defined Under Namespace

Classes: HttpStatusManager

Constant Summary collapse

SUPPORT_FIELD_NAME =

reference github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#path-item-object Support Field Name: get, put, post, delete, patch

%w[get put post delete patch].freeze

Instance Attribute Summary

Attributes inherited from Dynamic::Schema::V3::HookableBaseObject

#doc

Instance Method Summary collapse

Methods inherited from Dynamic::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, opts = {}) ⇒ PathItemObject

Returns a new instance of PathItemObject.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb', line 19

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]
  @required_parameters            = route_data[:required_parameters]
  @format_name                    = create_format_name
  @http_status_manager            = HttpStatusManager.new(@path, @verb, http_statuses_when_http_method)
  @components_schema_object       = components_schema_object_class.new(route_data, path, opts)
  @components_request_body_object = components_request_body_object_class.new(route_data, path, opts)
  support_field_name? if route_data.key?(:verb)
end

Instance Method Details

#create_docObject



42
43
44
45
46
47
48
# File 'lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb', line 42

def create_doc
  result = { @verb.to_s => data_when_verb }
  attach_request_body!(result)
  attach_media_type!(result)
  attach_parameters!(result)
  doc.merge!(result)
end

#to_docObject



35
36
37
38
39
40
# File 'lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb', line 35

def to_doc
  execute_before_create(@path)
  create_doc
  execute_after_create(@path)
  doc
end