Class: OpenapiContracts::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_contracts/doc.rb

Defined Under Namespace

Classes: Header, Parser, Response

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, pointer = []) ⇒ Doc

Returns a new instance of Doc.



11
12
13
# File 'lib/openapi_contracts/doc.rb', line 11

def initialize(spec, pointer = [])
  @spec = spec
end

Class Method Details

.parse(dir) ⇒ Object



7
8
9
# File 'lib/openapi_contracts/doc.rb', line 7

def self.parse(dir)
  new Parser.call(dir)
end

Instance Method Details

#response_for(path, method, status) ⇒ Object



17
18
19
# File 'lib/openapi_contracts/doc.rb', line 17

def response_for(path, method, status)
  dig('paths', path, method, 'responses', status)&.then { |d| Response.new(d) }
end