[Feature]Can't support list type swagger response
See original GitHub issuelike:
class Item(BaseModel):
name: str
price: float
@app.route("/", method=["POST"])
@api.validate(json=Item, resp=Response(HTTP_200=List[Item]), tags=["demo"])
def demo():
item = Item.parse_obj(request.context.json)
return [item, item, item]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:20 (12 by maintainers)
Top Results From Across the Web
Describing Responses - Swagger
An API can respond with various media types. JSON is the most common format for data exchange, but not the only one possible....
Read more >Describing Responses - Swagger
To specify the response media types, use the produces keyword on the root level or operation level. The global list can be overridden...
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
Primitive data types in the OAS are based on the types supported by the JSON ... responses: '200': description: A list of pets....
Read more >Data Types - Swagger
The data type of a schema is defined by the type keyword, for example, type: string . OpenAPI defines the following basic types:....
Read more >Media Types - Swagger
Media Types. Media type is a format of a request or response body data. Web service operations can accept and return data in...
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
One possible way is to use
__root__
pydantic root.By the way, you don’t need to parse
request.context.json
again. For the return statement, you can usereturn ItemList.parse_obj([item, item, item])
orreturn ItemList(__root__=[item, item, item])
.Has anyone undertaken this issue yet? It’s something I need and I was wondering if I should take a swing at it or if it’s already underway.