Class: OpenapiContracts::Doc::Response
- Inherits:
-
Object
- Object
- OpenapiContracts::Doc::Response
- Defined in:
- lib/openapi_contracts/doc/response.rb
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(data) ⇒ Response
constructor
A new instance of Response.
- #no_content? ⇒ Boolean
- #schema_for(content_type) ⇒ Object
- #supports_content_type?(content_type) ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/openapi_contracts/doc/response.rb', line 3 def initialize(data) @data = data end |
Instance Method Details
#headers ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/openapi_contracts/doc/response.rb', line 7 def headers return @headers if instance_variable_defined? :@headers @headers = @data.fetch('headers', {}).map do |(k, v)| Doc::Header.new(k, v) end end |
#no_content? ⇒ Boolean
19 20 21 |
# File 'lib/openapi_contracts/doc/response.rb', line 19 def no_content? !@data.key? 'content' end |
#schema_for(content_type) ⇒ Object
15 16 17 |
# File 'lib/openapi_contracts/doc/response.rb', line 15 def schema_for(content_type) @data.dig('content', content_type, 'schema') end |
#supports_content_type?(content_type) ⇒ Boolean
23 24 25 |
# File 'lib/openapi_contracts/doc/response.rb', line 23 def supports_content_type?(content_type) @data.dig('content', content_type).present? end |