Skip to content
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

Add compatibility for query params with square brackets #5

Open
frabarz opened this issue Apr 29, 2024 · 0 comments
Open

Add compatibility for query params with square brackets #5

frabarz opened this issue Apr 29, 2024 · 0 comments

Comments

@frabarz
Copy link
Collaborator

frabarz commented Apr 29, 2024

By default FastAPI has compatibility for lists in query params using multiple duplicates of the same param, without extras: q=1&q=2&q=3, however many client libraries build list parameters into query params adding square brackets to the param name: q[]=1&q[]=2&q[]=3, and even declaring the index of the value inside it if the order of the elements is relevant: q[0]=1&q[1]=2&q[2]=3.
This serialization is not standardized by any RFC, but is widely supported by client libraries like axios, which by default uses the second method here described.

It would be useful to avoid repeating code to integrate this method of parsing directly into LogicLayerModule; this is possible by subclassing the fastapi.Request and fastapi.routing.APIRoute classes. Implementations can then customize their methods by subclassing these or declaring their own Route class on the internal router object.

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

No branches or pull requests

1 participant