Class: OpenapiContracts::Doc::Response
- Inherits:
- 
      Object
      
        - Object
- OpenapiContracts::Doc::Response
 
- Defined in:
- lib/openapi_contracts/doc/response.rb
Instance Attribute Summary collapse
- 
  
    
      #coverage  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute coverage. 
- 
  
    
      #operation  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute operation. 
- 
  
    
      #schema  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute schema. 
- 
  
    
      #status  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute status. 
Instance Method Summary collapse
- #headers ⇒ Object
- 
  
    
      #initialize(operation, status, schema)  ⇒ Response 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Response. 
- #no_content? ⇒ Boolean
- #schema_for(media_type) ⇒ Object
- #supports_media_type?(media_type) ⇒ Boolean
Constructor Details
#initialize(operation, status, schema) ⇒ Response
Returns a new instance of Response.
| 7 8 9 10 11 | # File 'lib/openapi_contracts/doc/response.rb', line 7 def initialize(operation, status, schema) @operation = operation @status = status @schema = schema.follow_refs end | 
Instance Attribute Details
#coverage ⇒ Object (readonly)
Returns the value of attribute coverage.
| 3 4 5 | # File 'lib/openapi_contracts/doc/response.rb', line 3 def coverage @coverage end | 
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
| 3 4 5 | # File 'lib/openapi_contracts/doc/response.rb', line 3 def operation @operation end | 
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
| 3 4 5 | # File 'lib/openapi_contracts/doc/response.rb', line 3 def schema @schema end | 
#status ⇒ Object (readonly)
Returns the value of attribute status.
| 3 4 5 | # File 'lib/openapi_contracts/doc/response.rb', line 3 def status @status end | 
Instance Method Details
#headers ⇒ Object
| 13 14 15 16 17 18 19 | # File 'lib/openapi_contracts/doc/response.rb', line 13 def headers return @headers if instance_variable_defined? :@headers @headers = @schema.fetch('headers', {}).map do |(key, val)| Doc::Header.new(key, val) end end | 
#no_content? ⇒ Boolean
| 27 28 29 | # File 'lib/openapi_contracts/doc/response.rb', line 27 def no_content? !@schema.key? 'content' end | 
#schema_for(media_type) ⇒ Object
| 21 22 23 24 25 | # File 'lib/openapi_contracts/doc/response.rb', line 21 def schema_for(media_type) return unless supports_media_type?(media_type) @schema.navigate('content', media_type, 'schema') end | 
#supports_media_type?(media_type) ⇒ Boolean
| 31 32 33 | # File 'lib/openapi_contracts/doc/response.rb', line 31 def supports_media_type?(media_type) @schema.dig('content', media_type).present? end |