Skip to content

Commit cdc23b5

Browse files
authored
[Generator] Improve parameter handling of MIME types in content types (#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.
1 parent e870f6b commit cdc23b5

File tree

2 files changed

+392
-114
lines changed

2 files changed

+392
-114
lines changed

Sources/_OpenAPIGeneratorCore/Translator/Content/ContentType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct ContentType: Hashable {
194194
/// The header value used when validating a content-type header.
195195
///
196196
/// This should be less strict, e.g. not require `charset`.
197-
var headerValueForValidation: String { lowercasedTypeAndSubtype }
197+
var headerValueForValidation: String { lowercasedTypeSubtypeAndParameters }
198198

199199
/// The coding strategy appropriate for this content type.
200200
var codingStrategy: CodingStrategy { category.codingStrategy }

0 commit comments

Comments
 (0)