Update the import statements for the cookbook snippets (#1805)

Updates the import statements on
https://connexion.readthedocs.io/en/stable/cookbook.html


A few of the import statements were missing, or didn't match the example
code because they imported at the wrong depth.
This should make the code in the cookbook copy-pasteable.

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
This commit is contained in:
MatthiasDurivet
2023-11-19 22:56:28 +01:00
committed by GitHub
parent 165a91511b
commit 563fbf8e77

View File

@@ -16,13 +16,15 @@ Starlette. You can add it to your application, ideally in front of the ``Routing
:sync: AsyncApp :sync: AsyncApp
.. code-block:: python .. code-block:: python
from pathlib import Path
from connexion import AsyncApp from connexion import AsyncApp
from connexion.middleware import MiddlewarePosition from connexion.middleware import MiddlewarePosition
from starlette.middleware.cors import CORSMiddleware from starlette.middleware.cors import CORSMiddleware
app = connexion.AsyncApp(__name__) app = AsyncApp(__name__)
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
@@ -48,13 +50,15 @@ Starlette. You can add it to your application, ideally in front of the ``Routing
:sync: FlaskApp :sync: FlaskApp
.. code-block:: python .. code-block:: python
from pathlib import Path
from connexion import FlaskApp from connexion import FlaskApp
from connexion.middleware import MiddlewarePosition from connexion.middleware import MiddlewarePosition
from starlette.middleware.cors import CORSMiddleware from starlette.middleware.cors import CORSMiddleware
app = connexion.FlaskApp(__name__) app = FlaskApp(__name__)
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
@@ -80,10 +84,12 @@ Starlette. You can add it to your application, ideally in front of the ``Routing
:sync: ConnexionMiddleware :sync: ConnexionMiddleware
.. code-block:: python .. code-block:: python
from pathlib import Path
from asgi_framework import App from asgi_framework import App
from connexion import ConnexionMiddleware from connexion import ConnexionMiddleware
from connexion.lifecycle import ConnexionRequest, ConnexionResponse from starlette.middleware.cors import CORSMiddleware
app = App(__name__) app = App(__name__)
app = ConnexionMiddleware(app) app = ConnexionMiddleware(app)