Server: special-case */* responses (skip Accept validation, don’t emit Content-Type: */*)#860
Open
brandonbloom wants to merge 1 commit intoapple:mainfrom
Open
Conversation
Contributor
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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