📝 Fix code consistency in examples for Tutorial - User Guide - Path Parameters (#2158)

This commit is contained in:
nukopy 2020-11-06 07:30:09 +09:00 committed by GitHub
parent 8c5efe0b4b
commit 22a5960d36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View file

@ -12,7 +12,7 @@ class ModelName(str, Enum):
app = FastAPI() app = FastAPI()
@app.get("/model/{model_name}") @app.get("/models/{model_name}")
async def get_model(model_name: ModelName): async def get_model(model_name: ModelName):
if model_name == ModelName.alexnet: if model_name == ModelName.alexnet:
return {"model_name": model_name, "message": "Deep Learning FTW!"} return {"model_name": model_name, "message": "Deep Learning FTW!"}

View file

@ -9,7 +9,7 @@ openapi_schema = {
"openapi": "3.0.2", "openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"}, "info": {"title": "FastAPI", "version": "0.1.0"},
"paths": { "paths": {
"/model/{model_name}": { "/models/{model_name}": {
"get": { "get": {
"responses": { "responses": {
"200": { "200": {
@ -28,7 +28,7 @@ openapi_schema = {
}, },
}, },
"summary": "Get Model", "summary": "Get Model",
"operationId": "get_model_model__model_name__get", "operationId": "get_model_models__model_name__get",
"parameters": [ "parameters": [
{ {
"required": True, "required": True,
@ -80,10 +80,10 @@ openapi_schema2 = {
"openapi": "3.0.2", "openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"}, "info": {"title": "FastAPI", "version": "0.1.0"},
"paths": { "paths": {
"/model/{model_name}": { "/models/{model_name}": {
"get": { "get": {
"summary": "Get Model", "summary": "Get Model",
"operationId": "get_model_model__model_name__get", "operationId": "get_model_models__model_name__get",
"parameters": [ "parameters": [
{ {
"required": True, "required": True,
@ -160,22 +160,22 @@ def test_openapi():
"url,status_code,expected", "url,status_code,expected",
[ [
( (
"/model/alexnet", "/models/alexnet",
200, 200,
{"model_name": "alexnet", "message": "Deep Learning FTW!"}, {"model_name": "alexnet", "message": "Deep Learning FTW!"},
), ),
( (
"/model/lenet", "/models/lenet",
200, 200,
{"model_name": "lenet", "message": "LeCNN all the images"}, {"model_name": "lenet", "message": "LeCNN all the images"},
), ),
( (
"/model/resnet", "/models/resnet",
200, 200,
{"model_name": "resnet", "message": "Have some residuals"}, {"model_name": "resnet", "message": "Have some residuals"},
), ),
( (
"/model/foo", "/models/foo",
422, 422,
{ {
"detail": [ "detail": [