You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrations/django.rst
+48-27Lines changed: 48 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,9 @@ The integration supports Django from version 3.0 and above.
7
7
Middleware
8
8
----------
9
9
10
-
Django can be integrated by middleware. Add ``DjangoOpenAPIMiddleware`` to your ``MIDDLEWARE`` list and define ``OPENAPI``.
10
+
Django can be integrated by `middleware <https://docs.djangoproject.com/en/5.0/topics/http/middleware/>`__ to apply OpenAPI validation to your entire application.
11
+
12
+
Add ``DjangoOpenAPIMiddleware`` to your ``MIDDLEWARE`` list and define ``OPENAPI``.
11
13
12
14
.. code-block:: python
13
15
:emphasize-lines: 6,9
@@ -22,6 +24,30 @@ Django can be integrated by middleware. Add ``DjangoOpenAPIMiddleware`` to your
22
24
23
25
OPENAPI= OpenAPI.from_dict(spec_dict)
24
26
27
+
After that all your requests and responses will be validated.
28
+
29
+
Also you have access to unmarshal result object with all unmarshalled request data through ``openapi`` attribute of request object.
30
+
31
+
.. code-block:: python
32
+
33
+
from django.views import View
34
+
35
+
classMyView(View):
36
+
defget(self, request):
37
+
# get parameters object with path, query, cookies and headers parameters
Copy file name to clipboardExpand all lines: docs/integrations/flask.rst
+10-20Lines changed: 10 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,44 +3,34 @@ Flask
3
3
4
4
This section describes integration with `Flask <https://flask.palletsprojects.com>`__ web framework.
5
5
6
-
Decorator
7
-
---------
6
+
View decorator
7
+
--------------
8
+
9
+
Flask can be integrated by `view decorator <https://flask.palletsprojects.com/en/latest/patterns/viewdecorators/>`__ to apply OpenAPI validation to your application's specific views.
8
10
9
-
Flask views can be integrated by ``FlaskOpenAPIViewDecorator`` decorator.
11
+
Use ``FlaskOpenAPIViewDecorator`` with OpenAPI object to create the decorator.
10
12
11
13
.. code-block:: python
12
14
:emphasize-lines: 1,3,6
13
15
14
16
from openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator
Copy file name to clipboardExpand all lines: docs/integrations/starlette.rst
+34-13Lines changed: 34 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,9 @@ This section describes integration with `Starlette <https://www.starlette.io>`__
6
6
Middleware
7
7
----------
8
8
9
-
Starlette can be integrated by middleware. Add ``StarletteOpenAPIMiddleware`` with ``spec`` to your ``middleware`` list.
9
+
Starlette can be integrated by `middleware <https://www.starlette.io/middleware/>`__ to apply OpenAPI validation to your entire application.
10
+
11
+
Add ``StarletteOpenAPIMiddleware`` with OpenAPI object to your ``middleware`` list.
10
12
11
13
.. code-block:: python
12
14
:emphasize-lines: 1,6
@@ -24,21 +26,26 @@ Starlette can be integrated by middleware. Add ``StarletteOpenAPIMiddleware`` wi
24
26
middleware=middleware,
25
27
)
26
28
27
-
After that you have access to unmarshal result object with all validated request data from endpoint through ``openapi`` key of request's scope directory.
29
+
After that all your requests and responses will be validated.
30
+
31
+
Also you have access to unmarshal result object with all unmarshalled request data through ``openapi`` scope of request object.
28
32
29
33
.. code-block:: python
30
34
31
-
asyncdefget_endpoint(req):
35
+
asyncdefhomepage(request):
32
36
# get parameters object with path, query, cookies and headers parameters
0 commit comments