OpenAPI deepObject serialization for query parameters
See original GitHub issueFirst check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
- After submitting this, I commit to:
- Implement a Pull Request for a confirmed bug - or implement the feature described in this issue 😃
Description
Allow usage of deepObject
serialization from OpenAPI 3.
What it could look like
from fastapi import FastAPI
app = FastAPI()
class UserQuery(BaseModel):
role: str
firstName: str
@app.get("/")
def read_root(id: Optional[UserQuery]):
return {"Hello": "World"}
Query:
/users?id[role]=admin&id[firstName]=Alex
Related
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Parameter Serialization - Swagger
OpenAPI 3.0 supports arrays and objects in operation parameters (path, query, header, ... deepObject – simple non-nested objects are serialized as ...
Read more >How to define parameters with square brackets in OpenAPI ...
The parameter serialization method should be style: deepObject and ... Support deep objects for query parameters with deepObject style ...
Read more >OpenAPI JSON Objects as Query Parameters - Baeldung
Learn how to specify JSON objects as query parameters using the OpenAPI specification.
Read more >@oats-ts/openapi-parameter-serialization - npm
Start using @oats-ts/openapi-parameter-serialization in your project by ... the following structure, that you would like to express as query parameters:.
Read more >Parameter Object - Redocly
Describes a request parameter, which excludes the request body. ... Excerpt from the OpenAPI 3.1 specification about the parameter object ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How about just
Query(style="deepObject")
?See also #283 for broader support of encoding styles.
This is the sort of issue where it’s not entirely clear if the responsibility of supporting this should be on FastAPI or Pydantic. On one hand, it has to do with value parsing and encoding, which is something FastAPI tends to fully delegate to Pydantic, but on the other hand it’s not part of JSON Schema, it’s an OpenAPI extension that only applies to route parameter objects, and most of these encoding styles don’t make sense in a JSON context (which is what pydantic is generally meant for).
I would like to see these supported as well.