class OpenAPIParser::Schemas::OpenAPI
Public Class Methods
new(raw_schema, config, uri: nil, schema_registry: {})
click to toggle source
Calls superclass method
OpenAPIParser::Schemas::Base::new
# 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
Public Instance Methods
load_another_schema(uri)
click to toggle source
load another schema with shared config and schema_registry @return [OpenAPIParser::Schemas::OpenAPI]
# File lib/openapi_parser/schemas/openapi.rb, line 39 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)
click to toggle source
@return [OpenAPIParser::RequestOperation, nil]
# File lib/openapi_parser/schemas/openapi.rb, line 33 def request_operation(http_method, request_path) OpenAPIParser::RequestOperation.create(http_method, request_path, @path_item_finder, @config) end
Private Instance Methods
resolve_uri(uri)
click to toggle source
# File lib/openapi_parser/schemas/openapi.rb, line 51 def resolve_uri(uri) if uri.absolute? uri else @uri&.merge(uri) end end