Method: OpenapiFirst.parse

Defined in:
lib/openapi_first.rb

.parse(contents, only: nil, filepath: nil) ⇒ Definition

Parse a dereferenced Hash TODO: This needs to work with unresolved contents as well

Returns:



73
74
75
76
77
# File 'lib/openapi_first.rb', line 73

def self.parse(contents, only: nil, filepath: nil, &)
  contents = ::JSON.parse(::JSON.generate(contents)) # Deeply stringify keys, because of YAML. See https://github.com/ahx/openapi_first/issues/367
  contents['paths'].filter!(&->(key, _) { only.call(key) }) if only
  Definition.new(contents, filepath, &)
end