Class: OpenAPIParser::Schemas::OpenAPI
- Defined in:
- lib/openapi_parser/schemas/classes.rb,
lib/openapi_parser/schemas/openapi.rb
Instance Attribute Summary collapse
- #components ⇒ Components? readonly
- #info ⇒ Info? readonly
- #openapi ⇒ String? readonly
- #paths ⇒ Paths? readonly
Attributes inherited from Base
#object_reference, #parent, #raw_schema, #root
Instance Method Summary collapse
-
#initialize(raw_schema, config, uri: nil, schema_registry: {}) ⇒ OpenAPI
constructor
A new instance of OpenAPI.
-
#load_another_schema(uri) ⇒ OpenAPIParser::Schemas::OpenAPI
load another schema with shared config and schema_registry.
- #request_operation(http_method, request_path) ⇒ OpenAPIParser::RequestOperation?
Methods inherited from Base
Methods included from Expandable
Methods included from Findable
#find_object, #purge_object_cache
Methods included from Parser
#_openapi_all_child_objects, #_update_child_object, included, #load_data
Constructor Details
#initialize(raw_schema, config, uri: nil, schema_registry: {}) ⇒ OpenAPI
Returns a new instance of OpenAPI.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 8 def initialize(raw_schema, config, uri: nil, schema_registry: {}) super('#', nil, self, raw_schema) @find_object_cache = {} @path_item_finder = OpenAPIParser::PathItemFinder.new(paths) if paths # invalid definition @config = config @uri = uri @schema_registry = schema_registry # schema_registery is shared among schemas, and prevents a schema from being loaded multiple times schema_registry[uri] = self if uri end |
Instance Attribute Details
#components ⇒ Components? (readonly)
30 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 30 openapi_attr_object :components, Components, reference: false |
#info ⇒ Info? (readonly)
34 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 34 openapi_attr_object :info, Info, reference: false |
#openapi ⇒ String? (readonly)
22 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 22 openapi_attr_values :openapi |
Instance Method Details
#load_another_schema(uri) ⇒ OpenAPIParser::Schemas::OpenAPI
load another schema with shared config and schema_registry
43 44 45 46 47 48 49 50 51 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 43 def load_another_schema(uri) resolved_uri = resolve_uri(uri) return if resolved_uri.nil? loaded = @schema_registry[resolved_uri] return loaded if loaded OpenAPIParser.load_uri(resolved_uri, config: @config, schema_registry: @schema_registry) end |
#request_operation(http_method, request_path) ⇒ OpenAPIParser::RequestOperation?
37 38 39 |
# File 'lib/openapi_parser/schemas/openapi.rb', line 37 def request_operation(http_method, request_path) OpenAPIParser::RequestOperation.create(http_method, request_path, @path_item_finder, @config) end |