@@ -60,22 +60,41 @@ extension Converter {
6060 guard let parsedSubstring = OpenAPIMIMEType ( substring) else {
6161 throw RuntimeError . invalidAcceptSubstring ( substring)
6262 }
63- guard case . concrete( let substringType, let substringSubtype) = parsedSubstring. kind else {
64- // If the substring content type has a wildcard, just let it through.
65- // It's not well defined how such a case should behave, so be permissive.
66- return
67- }
68-
6963 // Look for the first match.
7064 for acceptValue in acceptValues {
7165 // Fast path.
7266 if acceptValue == substring { return }
7367 guard let parsedAcceptValue = OpenAPIMIMEType ( acceptValue) else {
7468 throw RuntimeError . invalidExpectedContentType ( acceptValue)
7569 }
76- switch parsedAcceptValue. kind {
77- case . any: return
78- case . anySubtype( type: let type) : if substringType. lowercased ( ) == type. lowercased ( ) { return }
70+ switch ( parsedAcceptValue. kind, parsedSubstring. kind) {
71+ case ( . any, _) :
72+ // Accept: */* always matches
73+ return
74+ case ( . anySubtype( type: let acceptType) , let substring) :
75+ switch substring {
76+ case . any:
77+ // */* as a concrete content type is NOT a match for an Accept header of foo/*
78+ break
79+ case . anySubtype( type: let substringType) :
80+ if substringType. lowercased ( ) == acceptType. lowercased ( ) {
81+ return
82+ }
83+ case . concrete( type: let substringType, subtype: let substringSubtype) :
84+ if
85+ substringType. lowercased ( ) == acceptType. lowercased ( ) &&
86+
87+ {
88+ return
89+ }
90+
91+ if accept. lowercased ( ) == substringType. lowercased ( )
92+ && subtype. lowercased ( ) == substringSubtype. lowercased ( )
93+ {
94+ return
95+ }
96+ }
97+
7998 case . concrete( type: let type, subtype: let subtype) :
8099 if type. lowercased ( ) == substringType. lowercased ( )
81100 && subtype. lowercased ( ) == substringSubtype. lowercased ( )
0 commit comments