Skip to content

Commit

Permalink
[Generator] Improve parameter handling of MIME types in content types (
Browse files Browse the repository at this point in the history
…#646)

### Motivation

The generator piece of
apple/swift-openapi-runtime#113.

This is needed for APIs such as Kubernetes, that has both
`application/json` and `application/json; watch=true` in a single
operation.

Currently the parameters weren't taken into account, which could lead to
incorrect matching of content types.

### Modifications

Use the full MIME type, including the parameters, for matching.

### Result

More correct behavior, now we correctly handle multiple MIME types with
the same type/subtype in an operation.

### Test Plan

Added a unit test.
  • Loading branch information
czechboy0 authored Nov 28, 2024
1 parent e870f6b commit cdc23b5
Show file tree
Hide file tree
Showing 2 changed files with 392 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct ContentType: Hashable {
/// The header value used when validating a content-type header.
///
/// This should be less strict, e.g. not require `charset`.
var headerValueForValidation: String { lowercasedTypeAndSubtype }
var headerValueForValidation: String { lowercasedTypeSubtypeAndParameters }

/// The coding strategy appropriate for this content type.
var codingStrategy: CodingStrategy { category.codingStrategy }
Expand Down
Loading

0 comments on commit cdc23b5

Please sign in to comment.