mirror of https://github.com/tiangolo/fastapi.git
Adapt tests to a new endpoint
Remove unused import Add entry to openapi.json Reformat openapi.json
This commit is contained in:
parent
ec624a27be
commit
23740cf524
|
|
@ -184,16 +184,16 @@ def get_query_param_required(query=Query(...)):
|
|||
return f"foo bar {query}"
|
||||
|
||||
|
||||
@app.get("/query/params")
|
||||
def get_query_params(queries: Dict[str, int] = Query({})):
|
||||
return f"foo bar {queries}"
|
||||
|
||||
|
||||
@app.get("/query/param-required/int")
|
||||
def get_query_param_required_type(query: int = Query(...)):
|
||||
return f"foo bar {query}"
|
||||
|
||||
|
||||
@app.get("/query/params")
|
||||
def get_query_params(queries: Dict[str, int] = Query({})):
|
||||
return f"foo bar {queries}"
|
||||
|
||||
|
||||
@app.get("/enum-status-code", status_code=http.HTTPStatus.CREATED)
|
||||
def get_enum_status_code():
|
||||
return "foo bar"
|
||||
|
|
|
|||
|
|
@ -1078,6 +1078,41 @@ openapi_schema = {
|
|||
],
|
||||
}
|
||||
},
|
||||
"/query/params": {
|
||||
"get": {
|
||||
"summary": "Get Query Params",
|
||||
"operationId": "get_query_params_query_params_get",
|
||||
"parameters": [
|
||||
{
|
||||
"required": False,
|
||||
"schema": {
|
||||
"title": "Queries",
|
||||
"type": "object",
|
||||
"additionalProperties": {"type": "integer"},
|
||||
"default": {},
|
||||
},
|
||||
"name": "queries",
|
||||
"in": "query",
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
"/enum-status-code": {
|
||||
"get": {
|
||||
"responses": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Dict, List, Optional, Tuple
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI, Query
|
||||
|
|
@ -39,15 +39,3 @@ def test_invalid_dict():
|
|||
@app.get("/items/")
|
||||
def read_items(q: Dict[str, Item] = Query(None)):
|
||||
pass # pragma: no cover
|
||||
|
||||
|
||||
def test_invalid_simple_dict():
|
||||
with pytest.raises(AssertionError):
|
||||
app = FastAPI()
|
||||
|
||||
class Item(BaseModel):
|
||||
title: str
|
||||
|
||||
@app.get("/items/")
|
||||
def read_items(q: Optional[dict] = Query(None)):
|
||||
pass # pragma: no cover
|
||||
|
|
|
|||
Loading…
Reference in New Issue