Server: special-case */* responses (skip Accept validation, don’t emit Content-Type: */*)#860
Server: special-case */* responses (skip Accept validation, don’t emit Content-Type: */*)#860brandonbloom wants to merge 2 commits intoapple:mainfrom
Conversation
|
Hi @brandonbloom,
It's surprising that it'd reject it, the idea is that if the client doesn't send an Are you seeing a different behavior? Is the server rejecting requests that completely omit Regarding the response |
|
You’re right that if The failing case I saw was when I updated generation so server-side
I also updated the snippet reference test to cover this case. |
Motivation
When an OpenAPI response uses
content: {'*/*': ...}to indicate an intentionally unconstrained/dynamic media type, the generated server serializer currently:converter.validateAcceptIfPresent("*/*", in: request.headerFields), which effectively forces clients to includeAccept: */*, andContent-Type: */*(viasetResponseBodyAsBinary(..., contentType: "*/*")).Both behaviors are problematic in practice.
This PR is a safe first step: it fixes the immediate incorrect strictness and avoids emitting an invalid/meaningless response
Content-Type, while keeping the generated public API unchanged.Related: #859 (kept open; follow-up can explore a richer, potentially source-breaking solution to plumb dynamic
Content-Type).Modifications
*/*to:validateAcceptIfPresent, andHTTPBodydirectly without settingContent-Type: */*.*/*response does not containvalidateAcceptIfPresent("*/*")and does not containcontentType: "*/*".Result
Generated servers no longer reject requests that omit
Accept: */*for wildcard responses, and no longer emitContent-Type: */*.Test Plan
swift test