mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-09 12:27:46 +00:00
Update examples for Connexion 3.0 (#1615)
This PR updates the examples for Connexion 3.0 and merges them for OpenAPI and Swagger. 2 examples required some changes to make them work: - The reverse proxy example required some fixes to the SwaggerUIMiddleware to leverage the `root_path` correctly. This is included in the PR. - The enforced defaults example requires the json validator to adapt the body and pass it on. We currently pass on the original body after validation, and I'm not sure if we should change this. I'll submit a separate PR to discuss this.
This commit is contained in:
21
examples/helloworld_async/hello.py
Executable file
21
examples/helloworld_async/hello.py
Executable file
@@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
|
||||
import connexion
|
||||
|
||||
|
||||
async def test():
|
||||
pass
|
||||
|
||||
|
||||
async def post_greeting(name: str):
|
||||
await test()
|
||||
return f"Hello {name}", 201
|
||||
|
||||
|
||||
app = connexion.AsyncApp(__name__, specification_dir="spec")
|
||||
app.add_api("openapi.yaml", arguments={"title": "Hello World Example"})
|
||||
app.add_api("swagger.yaml", arguments={"title": "Hello World Example"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(f"{Path(__file__).stem}:app", port=8080)
|
||||
Reference in New Issue
Block a user