Module: OpenapiFirst::HasContent

Included in:
RequestBody, Response
Defined in:
lib/openapi_first/definition/has_content.rb

Instance Method Summary collapse

Instance Method Details

#schema_for(content_type) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/openapi_first/definition/has_content.rb', line 7

def schema_for(content_type)
  return unless content&.any?

  content_schemas&.fetch(content_type) do
    type = content_type.split(';')[0]
    content_schemas[type] || content_schemas["#{type.split('/')[0]}/*"] || content_schemas['*/*']
  end
end