1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| @app.post("/post_model2/{item_id}")
async def post_model2(items: Annotated[Item2, Field(description = 'a nested parameter')],
q: Annotated[str, Query(description = '查询参数')],
item_id: Annotated[int, Path(description = '路径参数')]):
"""
POST请求与路径参数、查询参数的嵌套
curl -X 'POST' \
'http://127.0.0.1:18081/post_model2/1234?q=aaaaaaa' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "Bob",
"description": "string",
"price": 0,
"tax": 0,
"tags": [],
"gender": "male",
"flags": "test1",
"extend": {
"a": "",
"b": 0,
"c": 0.1,
"d": false,
"additionalProp1": {}
}
}'
"""
print(items)
return {
"method": "POST",
"message": items,
'query': q,
'path_item_id': item_id
}
|