File: __init__.py

package info (click to toggle)
python-openapi-core 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,008 kB
  • sloc: python: 18,868; makefile: 47
file content (96 lines) | stat: -rw-r--r-- 3,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from collections import OrderedDict

from isodate.isodatetime import parse_datetime

from openapi_core.unmarshalling.schemas.factories import (
    SchemaUnmarshallersFactory,
)
from openapi_core.unmarshalling.schemas.unmarshallers import AnyUnmarshaller
from openapi_core.unmarshalling.schemas.unmarshallers import ArrayUnmarshaller
from openapi_core.unmarshalling.schemas.unmarshallers import (
    MultiTypeUnmarshaller,
)
from openapi_core.unmarshalling.schemas.unmarshallers import ObjectUnmarshaller
from openapi_core.unmarshalling.schemas.unmarshallers import (
    PrimitiveUnmarshaller,
)
from openapi_core.unmarshalling.schemas.unmarshallers import TypesUnmarshaller
from openapi_core.unmarshalling.schemas.util import format_byte
from openapi_core.unmarshalling.schemas.util import format_date
from openapi_core.unmarshalling.schemas.util import format_uuid
from openapi_core.validation.schemas import (
    oas30_read_schema_validators_factory,
)
from openapi_core.validation.schemas import (
    oas30_write_schema_validators_factory,
)
from openapi_core.validation.schemas import oas31_schema_validators_factory

__all__ = [
    "oas30_format_unmarshallers",
    "oas31_format_unmarshallers",
    "oas30_write_schema_unmarshallers_factory",
    "oas30_read_schema_unmarshallers_factory",
    "oas31_schema_unmarshallers_factory",
]

oas30_unmarshallers_dict = OrderedDict(
    [
        ("object", ObjectUnmarshaller),
        ("array", ArrayUnmarshaller),
        ("boolean", PrimitiveUnmarshaller),
        ("integer", PrimitiveUnmarshaller),
        ("number", PrimitiveUnmarshaller),
        ("string", PrimitiveUnmarshaller),
    ]
)
oas31_unmarshallers_dict = oas30_unmarshallers_dict.copy()
oas31_unmarshallers_dict.update(
    {
        "null": PrimitiveUnmarshaller,
    }
)

oas30_types_unmarshaller = TypesUnmarshaller(
    oas30_unmarshallers_dict,
    AnyUnmarshaller,
)
oas31_types_unmarshaller = TypesUnmarshaller(
    oas31_unmarshallers_dict,
    AnyUnmarshaller,
    multi=MultiTypeUnmarshaller,
)

oas30_format_unmarshallers = {
    # string compatible
    "date": format_date,
    "date-time": parse_datetime,
    "binary": bytes,
    "uuid": format_uuid,
    "byte": format_byte,
}
oas31_format_unmarshallers = oas30_format_unmarshallers

oas30_write_schema_unmarshallers_factory = SchemaUnmarshallersFactory(
    oas30_write_schema_validators_factory,
    oas30_types_unmarshaller,
    format_unmarshallers=oas30_format_unmarshallers,
)

oas30_read_schema_unmarshallers_factory = SchemaUnmarshallersFactory(
    oas30_read_schema_validators_factory,
    oas30_types_unmarshaller,
    format_unmarshallers=oas30_format_unmarshallers,
)

oas31_schema_unmarshallers_factory = SchemaUnmarshallersFactory(
    oas31_schema_validators_factory,
    oas31_types_unmarshaller,
    format_unmarshallers=oas31_format_unmarshallers,
)

# alias to v31 version (request/response are the same bcs no context needed)
oas31_request_schema_unmarshallers_factory = oas31_schema_unmarshallers_factory
oas31_response_schema_unmarshallers_factory = (
    oas31_schema_unmarshallers_factory
)