Skip to content

Commit 82b0288

Browse files
committed
Response validation README updated
1 parent 1289711 commit 82b0288

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,31 @@ or specify request wrapper class for shortcuts
103103
validated_body = validate_body(
104104
spec, request, wrapper_class=FlaskOpenAPIRequest)
105105
106+
You can also validate responses
107+
108+
.. code-block:: python
109+
110+
from openapi_core.validators import ResponseValidator
111+
112+
validator = ResponseValidator(spec)
113+
result = validator.validate(request, response)
114+
115+
# raise errors if response invalid
116+
result.raise_for_errors()
117+
118+
# get list of errors
119+
errors = result.errors
120+
121+
and unmarshal response data from validation result
122+
123+
.. code-block:: python
124+
125+
# get headers
126+
validated_headers = result.headers
127+
128+
# get data
129+
validated_data = result.data
130+
106131
Related projects
107132
================
108133
* `openapi-spec-validator <https://github.com/p1c2u/openapi-spec-validator>`__

0 commit comments

Comments
 (0)