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/customizations.rst
+26-12
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,13 @@ By default, spec dict is validated on spec creation time. Disabling the validati
15
15
Deserializers
16
16
-------------
17
17
18
-
Pass custom defined media type deserializers dictionary with supported mimetypes as a key to `RequestValidator` or `ResponseValidator` constructor:
18
+
Pass custom defined media type deserializers dictionary with supported mimetypes as a key to `MediaTypeDeserializersFactory` and then pass it to `RequestValidator` or `ResponseValidator` constructor:
19
19
20
20
.. code-block:: python
21
21
22
+
from openapi_core.deserializing.media_types.factories import MediaTypeDeserializersFactory
23
+
from openapi_core.unmarshalling.schemas import oas30_response_schema_unmarshallers_factory
24
+
22
25
defprotobuf_deserializer(message):
23
26
feature = route_guide_pb2.Feature()
24
27
feature.ParseFromString(message)
@@ -27,9 +30,14 @@ Pass custom defined media type deserializers dictionary with supported mimetypes
result = validator.validate(spec, request, response)
35
43
@@ -38,28 +46,34 @@ Formats
38
46
39
47
OpenAPI defines a ``format`` keyword that hints at how a value should be interpreted, e.g. a ``string`` with the type ``date`` should conform to the RFC 3339 date format.
40
48
41
-
Openapi-core comes with a set of built-in formatters, but it's also possible to add support for custom formatters for `RequestValidator` and `ResponseValidator`.
49
+
Openapi-core comes with a set of built-in formatters, but it's also possible to add custom formatters in `SchemaUnmarshallersFactory` and pass it to `RequestValidator` or `ResponseValidator`.
42
50
43
51
Here's how you could add support for a ``usdate`` format that handles dates of the form MM/DD/YYYY:
44
52
45
53
.. code-block:: python
46
54
47
-
from datetime import datetime
48
-
import re
55
+
from openapi_core.unmarshalling.schemas.factories import SchemaUnmarshallersFactory
56
+
from openapi_schema_validator import OAS30Validator
0 commit comments