diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java index c4d2e6f3283..6ee1131973e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFastAPIServerCodegen.java @@ -285,7 +285,7 @@ public class PythonFastAPIServerCodegen extends AbstractPythonCodegen { System.out.println("# https://opencollective.com/openapi_generator/donate #"); System.out.println("# #"); System.out.println("# This generator's contributed by Nikita Vakula (https://github.com/krjakbrjak)#"); - System.out.println("# Please support his work directly via https://paypal.me/krjakbrjaki \uD83D\uDE4F #"); + System.out.println("# Please support his work directly via https://paypal.me/krjakbrjak \uD83D\uDE4F #"); System.out.println("################################################################################"); } diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache index 6528c792026..ae8428952fd 100644 --- a/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache +++ b/modules/openapi-generator/src/main/resources/python-fastapi/README.mustache @@ -16,9 +16,9 @@ Python >= 3.6 To run the server, please execute the following from the root directory: -``` - pip3 install -r requirements.txt - uvicorn main:app --host 0.0.0.0 --port {{serverPort}} +```bash +pip3 install -r requirements.txt +uvicorn main:app --host 0.0.0.0 --port {{serverPort}} ``` and open your browser at `http://localhost:{{serverPort}}/docs/` to see the docs. @@ -30,3 +30,12 @@ To run the server on a Docker container, please execute the following from the r ```bash docker-compose up --build ``` + +## Tests + +To run the tests: + +```bash +pip3 install pytest +PYTHONPATH=src pytest tests +``` diff --git a/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache b/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache index 248f282e857..5a81aa32c60 100644 --- a/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/python-fastapi/api_test.mustache @@ -47,7 +47,8 @@ def test_{{operationId}}(client: TestClient): params=params,{{/-first}}{{/queryParams}} ) - assert response.status_code == 200 + # uncomment below to assert the status code of the HTTP response + #assert response.status_code == 200 {{/operation}} {{/operations}} diff --git a/pom.xml b/pom.xml index b968a476900..5a8c00165ef 100644 --- a/pom.xml +++ b/pom.xml @@ -1187,6 +1187,7 @@ samples/server/petstore/python-aiohttp samples/server/petstore/python-aiohttp-srclayout + samples/server/petstore/python-fastapi samples/server/petstore/python-flask