Skip to content

Decode + as a space in query items - #223

Open
nandan-varma wants to merge 2 commits into
apple:mainfrom
nandan-varma:plus-as-space-in-query
Open

nandan-varma wants to merge 2 commits into
apple:mainfrom
nandan-varma:plus-as-space-in-query

Conversation

@nandan-varma

Copy link
Copy Markdown

Motivation

OpenAPI 3.2 says that an unencoded + in a query string should be decoded as a space.

Some clients use + when sending spaces, like Python requests, Java URLEncoder, and JavaScript URLSearchParams. This previously required QuerySpaceNormalizingMiddleware.

Fixes apple/swift-openapi-generator#965

Modifications

  • Updated the server query decoders for URI and JSON to decode + as a space.
  • Deprecated QuerySpaceNormalizingMiddleware.
  • Path parameters, headers, and client encoding are not changed.

Result

  • a+b → a b
  • a%2Bb → a+b
  • a%20b → a b

Behavior change: if a server gets an unencoded + and expects a literal +, it will now get a space.

Test Plan

Added unit tests that fail without the fix.

OpenAPI 3.2 says an unencoded + in a query string means a space.
The server now decodes it that way. %2B still decodes to +, and
%20 still decodes to a space. Path parameters and headers are not
changed.

Fixes apple/swift-openapi-generator#965
The server now decodes + as a space in query items, so this
middleware is not needed anymore. It still works, but it now shows
a deprecation warning.
@czechboy0
czechboy0 self-requested a review October 8, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decode + as a space in query items

1 participant