Class: OpenapiContracts::Doc::Request

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

Instance Method Summary collapse

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

Returns:

  • (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