-
-
Notifications
You must be signed in to change notification settings - Fork 528
Query parameter serialization for objects is not the openapi default #1533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You are right the docs are incorrect and says the default is form/explode when it’s deepObject. The docs should be fixed, but I’m unsure if the default should be changed again, because there were many issues opened about simpler serializers being used. No matter what the default is, there will always be a large number of users whose backends implement a different style. In that vein, would it be worthwhile to ship some additional querySerializers that handle alternate syntaxes? Perhaps something like: import createClient from 'openapi-fetch';
import { formExplode } from 'openapi/serializers';
createClient({
querySerializer: formExplode
}); |
Yes it is not easy. Maybe it should be more finer grained. Array and object serialization can be different. I created a serializer for formExplode for object. It may help someone.
|
I really like the idea of separating object + array serialization! I don’t think anyone’s suggested that before. Adding that would make it easier for people to customize their own serializers for sure, and that could be added in a backwards-compatible way. |
Also digging into this, I realize that we don’t support path serialization very well either, but should. Will add a minor breaking change to the library to handle this (and provide for easier overrides). Since this is a breaking change, this will probably be released in |
Description
When serializing query parameters for objects using the library, the serialization method employed does not match the OpenAPI 3.0 specification's default behavior. Specifically, the library uses a "deepObject" serialization style instead of the expected "form" serialization with explode=true, leading to an incorrect query parameter format.
Openapi spec
Reproduction
Calling the:
the url parameters are: "id[role]=admin&id[firstName]=Alex"
Expected result
the url parameters should be: "role=admin&firstName=Alex"
Checklist
The text was updated successfully, but these errors were encountered: