Class: OpenapiContracts::Doc::Operation
- Inherits:
- 
      Object
      
        - Object
- OpenapiContracts::Doc::Operation
 
- Includes:
- WithParameters
- Defined in:
- lib/openapi_contracts/doc/operation.rb
Instance Attribute Summary collapse
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute path. 
Instance Method Summary collapse
- 
  
    
      #initialize(path, spec)  ⇒ Operation 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Operation. 
- #request_body ⇒ Object
- #response_for_status(status) ⇒ Object
- #responses ⇒ Object
- #verb ⇒ Object
Methods included from WithParameters
Constructor Details
#initialize(path, spec) ⇒ Operation
Returns a new instance of Operation.
| 7 8 9 10 11 12 13 | # File 'lib/openapi_contracts/doc/operation.rb', line 7 def initialize(path, spec) @path = path @spec = spec @responses = spec.navigate('responses').each.to_h do |status, subspec| [status, Doc::Response.new(self, status, subspec)] end end | 
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
| 5 6 7 | # File 'lib/openapi_contracts/doc/operation.rb', line 5 def path @path end | 
Instance Method Details
#request_body ⇒ Object
| 19 20 21 22 23 | # File 'lib/openapi_contracts/doc/operation.rb', line 19 def request_body return @request_body if instance_variable_defined?(:@request_body) @request_body = @spec.navigate('requestBody').presence&.then { |s| Doc::Request.new(s) } end | 
#response_for_status(status) ⇒ Object
| 29 30 31 | # File 'lib/openapi_contracts/doc/operation.rb', line 29 def response_for_status(status) @responses[status.to_s] end | 
#responses ⇒ Object
| 25 26 27 | # File 'lib/openapi_contracts/doc/operation.rb', line 25 def responses @responses.each_value end | 
#verb ⇒ Object
| 15 16 17 | # File 'lib/openapi_contracts/doc/operation.rb', line 15 def verb @spec.pointer[2] end |