Sha256: 67debcfaa6f8e95a53bc8a730ad1fdf63404dd781439714191f8141c428a8475

Contents?: true

Size: 781 Bytes

Versions: 37

Compression:

Stored size: 781 Bytes

Contents

module OpenAPIParser::MediaTypeSelectable
  private

    # select media type by content_type (consider wild card definition)
    # @param [String] content_type
    # @param [Hash{String => OpenAPIParser::Schemas::MediaType}] content
    # @return [OpenAPIParser::Schemas::MediaType, nil]
    def select_media_type_from_content(content_type, content)
      return nil unless content_type
      return nil unless content

      if (media_type = content[content_type])
        return media_type
      end

      # application/json => [application, json]
      splited = content_type.split('/')

      if (media_type = content["#{splited.first}/*"])
        return media_type
      end

      if (media_type = content['*/*'])
        return media_type
      end

      nil
    end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
openapi_parser-2.2.3 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-2.2.2 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-2.2.1 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-2.2.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-2.1.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-2.0.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser_firetail-1.0.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-1.0.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-1.0.0.beta1 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.15.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.14.1 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.14.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.13.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.12.1 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.12.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.11.2 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.11.1 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.11.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.10.0 lib/openapi_parser/concerns/media_type_selectable.rb
openapi_parser-0.9.0 lib/openapi_parser/concerns/media_type_selectable.rb