Decode + as a space in query items
Decode + as a space in query items.
OpenAPI 3.2.0 for the first time explicitly requests that not just %20, but also + should decode as a space (previously, only form-encoded bodies explicitly used + for space).
https://spec.openapis.org/oas/v3.2.1.html#url-percent-encoding
Content in the application/x-www-form-urlencoded format, including query strings produced by Parameter Objects with in: "query", MUST also successfully parse and percent-decode using [WHATWG-URL] rules, including treating non-percent-encoded + as an escaped space character.
This means that once this lands, we should deprecate https://github.com/apple/swift-openapi-runtime/blob/49689c749c36542443e91c1bff4da2e2a5f28dc3/Sources/OpenAPIRuntime/Interface/QuerySpaceNormalizingMiddleware.swift#L44 and update the docs to point people at it being unnecessary.
@czechboy0 I can work on this. Could you assign me.
I looked into the fix, and it would go in apple/swift-openapi-runtime. The server-side query decoding in Converter+Server.swift, together with the JSON query item decoder, would treat + as a space.
-
Everything else would stay the same:
-
%20would still decode to a space. -
%2Bwould still decode to+.
Path parameters, headers, and the client side would not change.
For QuerySpaceNormalizingMiddleware, I think we can deprecate it and update the docs in a follow-up PR after this lands. We could also do it in the same PR if you prefer. Let me know how you want that.
Thanks, @nandan-varma - assigned.
Let's prepare both changes in the same PR, we want to signal that the middleware is unnecessary once we fix up the server decoding.