Class: JekyllOpenAPI::Dereferencer
- Inherits:
-
Object
- Object
- JekyllOpenAPI::Dereferencer
- Defined in:
- lib/jekyll_openapi/dereferencer.rb
Overview
Walks an OpenAPI document once and replaces every local $ref node with a
lazy Reference instead of inlining its target. The reference graph and
component names are preserved; targets are resolved on demand (see
Reference), which keeps recursion finite and reused schemas shared.
External references (other files, URLs) and unresolvable pointers surface a warning when they are first followed, not while linking.
Class Method Summary collapse
Instance Method Summary collapse
-
#dereference ⇒ Object
A deep copy of the document with every
$refreplaced by a Reference that resolves lazily against the copy. -
#initialize(root, logger: JekyllOpenAPI.logger) ⇒ Dereferencer
constructor
A new instance of Dereferencer.
Constructor Details
#initialize(root, logger: JekyllOpenAPI.logger) ⇒ Dereferencer
Returns a new instance of Dereferencer.
14 15 16 17 |
# File 'lib/jekyll_openapi/dereferencer.rb', line 14 def initialize(root, logger: JekyllOpenAPI.logger) @root = root @logger = logger end |
Class Method Details
.dereference(root, logger: JekyllOpenAPI.logger) ⇒ Object
19 20 21 |
# File 'lib/jekyll_openapi/dereferencer.rb', line 19 def self.dereference(root, logger: JekyllOpenAPI.logger) new(root, logger: logger).dereference end |
Instance Method Details
#dereference ⇒ Object
Returns a deep copy of the document with every $ref replaced by a
Reference that resolves lazily against the copy.
25 26 27 28 29 |
# File 'lib/jekyll_openapi/dereferencer.rb', line 25 def dereference context = Reference::Context.new(nil, @logger) context.root = link(@root, context) context.root end |