Class: OpenapiContracts::Doc::Request
- Inherits:
-
Object
- Object
- OpenapiContracts::Doc::Request
- Defined in:
- lib/openapi_contracts/doc/request.rb
Instance Method Summary collapse
-
#initialize(schema) ⇒ Request
constructor
A new instance of Request.
- #schema_for(media_type) ⇒ Object
- #supports_media_type?(media_type) ⇒ Boolean
Constructor Details
#initialize(schema) ⇒ Request
Returns a new instance of Request.
3 4 5 |
# File 'lib/openapi_contracts/doc/request.rb', line 3 def initialize(schema) @schema = schema.follow_refs end |
Instance Method Details
#schema_for(media_type) ⇒ Object
7 8 9 10 11 |
# File 'lib/openapi_contracts/doc/request.rb', line 7 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
13 14 15 |
# File 'lib/openapi_contracts/doc/request.rb', line 13 def supports_media_type?(media_type) @schema.dig('content', media_type).present? end |