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/extensions.rst
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,10 @@ Extensions
4
4
x-model
5
5
-------
6
6
7
-
By default, objects are unmarshalled to dictionaries. You can use dynamically created dataclasses.
7
+
By default, objects are unmarshalled to dictionaries. You can use dynamically created dataclasses by providing ``x-model-path`` property inside schema definition with name of the model.
8
8
9
9
.. code-block:: yaml
10
+
:emphasize-lines: 5
10
11
11
12
...
12
13
components:
@@ -23,10 +24,16 @@ By default, objects are unmarshalled to dictionaries. You can use dynamically cr
23
24
lon:
24
25
type: number
25
26
27
+
As a result of unmarshalling process, you will get ``Coordinates`` class instance with ``lat`` and ``lon`` attributes.
28
+
29
+
30
+
x-model-path
31
+
------------
26
32
27
33
You can use your own dataclasses, pydantic models or models generated by third party generators (i.e. `datamodel-code-generator <https://github.com/koxudaxi/datamodel-code-generator>`__) by providing ``x-model-path`` property inside schema definition with location of your class.
28
34
29
35
.. code-block:: yaml
36
+
:emphasize-lines: 5
30
37
31
38
...
32
39
components:
@@ -52,3 +59,5 @@ You can use your own dataclasses, pydantic models or models generated by third p
52
59
classCoordinates:
53
60
lat: float
54
61
lon: float
62
+
63
+
As a result of unmarshalling process, you will get instance of your own dataclasses or model.
0 commit comments