openapi-python-client 0.26.1__py3-none-any.whl → 0.27.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openapi_python_client/__init__.py +8 -8
- openapi_python_client/cli.py +13 -14
- openapi_python_client/config.py +17 -18
- openapi_python_client/parser/bodies.py +5 -6
- openapi_python_client/parser/errors.py +2 -3
- openapi_python_client/parser/openapi.py +22 -22
- openapi_python_client/parser/properties/const.py +2 -4
- openapi_python_client/parser/properties/enum_property.py +6 -8
- openapi_python_client/parser/properties/list_property.py +5 -7
- openapi_python_client/parser/properties/literal_enum_property.py +5 -7
- openapi_python_client/parser/properties/merge_properties.py +2 -2
- openapi_python_client/parser/properties/model_property.py +3 -9
- openapi_python_client/parser/properties/property.py +19 -20
- openapi_python_client/parser/properties/protocol.py +10 -25
- openapi_python_client/parser/properties/schemas.py +11 -11
- openapi_python_client/parser/properties/union.py +4 -7
- openapi_python_client/parser/responses.py +11 -11
- openapi_python_client/schema/openapi_schema_pydantic/components.py +9 -11
- openapi_python_client/schema/openapi_schema_pydantic/contact.py +3 -5
- openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +1 -3
- openapi_python_client/schema/openapi_schema_pydantic/encoding.py +4 -4
- openapi_python_client/schema/openapi_schema_pydantic/example.py +5 -5
- openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +1 -3
- openapi_python_client/schema/openapi_schema_pydantic/info.py +4 -6
- openapi_python_client/schema/openapi_schema_pydantic/license.py +1 -3
- openapi_python_client/schema/openapi_schema_pydantic/link.py +7 -7
- openapi_python_client/schema/openapi_schema_pydantic/media_type.py +5 -5
- openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +3 -5
- openapi_python_client/schema/openapi_schema_pydantic/oauth_flows.py +4 -6
- openapi_python_client/schema/openapi_schema_pydantic/open_api.py +4 -6
- openapi_python_client/schema/openapi_schema_pydantic/operation.py +10 -12
- openapi_python_client/schema/openapi_schema_pydantic/parameter.py +7 -7
- openapi_python_client/schema/openapi_schema_pydantic/path_item.py +14 -14
- openapi_python_client/schema/openapi_schema_pydantic/reference.py +2 -3
- openapi_python_client/schema/openapi_schema_pydantic/request_body.py +1 -3
- openapi_python_client/schema/openapi_schema_pydantic/response.py +3 -5
- openapi_python_client/schema/openapi_schema_pydantic/schema.py +33 -33
- openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +7 -9
- openapi_python_client/schema/openapi_schema_pydantic/server.py +2 -4
- openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +2 -4
- openapi_python_client/schema/openapi_schema_pydantic/tag.py +2 -4
- openapi_python_client/schema/openapi_schema_pydantic/xml.py +3 -5
- openapi_python_client/templates/client.py.jinja +5 -5
- openapi_python_client/templates/endpoint_macros.py.jinja +6 -6
- openapi_python_client/templates/endpoint_module.py.jinja +6 -6
- openapi_python_client/templates/model.py.jinja +4 -2
- openapi_python_client/templates/pyproject_pdm.toml.jinja +1 -1
- openapi_python_client/templates/pyproject_poetry.toml.jinja +1 -1
- openapi_python_client/templates/pyproject_uv.toml.jinja +1 -1
- openapi_python_client/templates/setup.py.jinja +1 -1
- openapi_python_client/templates/types.py.jinja +9 -9
- {openapi_python_client-0.26.1.dist-info → openapi_python_client-0.27.0.dist-info}/METADATA +6 -7
- {openapi_python_client-0.26.1.dist-info → openapi_python_client-0.27.0.dist-info}/RECORD +56 -56
- {openapi_python_client-0.26.1.dist-info → openapi_python_client-0.27.0.dist-info}/WHEEL +0 -0
- {openapi_python_client-0.26.1.dist-info → openapi_python_client-0.27.0.dist-info}/entry_points.txt +0 -0
- {openapi_python_client-0.26.1.dist-info → openapi_python_client-0.27.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
__all__ = ["Property"]
|
|
2
2
|
|
|
3
|
-
from typing import Union
|
|
4
3
|
|
|
5
|
-
from
|
|
4
|
+
from typing import TypeAlias
|
|
6
5
|
|
|
7
6
|
from .any import AnyProperty
|
|
8
7
|
from .boolean import BooleanProperty
|
|
@@ -21,21 +20,21 @@ from .string import StringProperty
|
|
|
21
20
|
from .union import UnionProperty
|
|
22
21
|
from .uuid import UuidProperty
|
|
23
22
|
|
|
24
|
-
Property: TypeAlias =
|
|
25
|
-
AnyProperty
|
|
26
|
-
BooleanProperty
|
|
27
|
-
ConstProperty
|
|
28
|
-
DateProperty
|
|
29
|
-
DateTimeProperty
|
|
30
|
-
EnumProperty
|
|
31
|
-
LiteralEnumProperty
|
|
32
|
-
FileProperty
|
|
33
|
-
FloatProperty
|
|
34
|
-
IntProperty
|
|
35
|
-
ListProperty
|
|
36
|
-
ModelProperty
|
|
37
|
-
NoneProperty
|
|
38
|
-
StringProperty
|
|
39
|
-
UnionProperty
|
|
40
|
-
UuidProperty
|
|
41
|
-
|
|
23
|
+
Property: TypeAlias = (
|
|
24
|
+
AnyProperty
|
|
25
|
+
| BooleanProperty
|
|
26
|
+
| ConstProperty
|
|
27
|
+
| DateProperty
|
|
28
|
+
| DateTimeProperty
|
|
29
|
+
| EnumProperty
|
|
30
|
+
| LiteralEnumProperty
|
|
31
|
+
| FileProperty
|
|
32
|
+
| FloatProperty
|
|
33
|
+
| IntProperty
|
|
34
|
+
| ListProperty
|
|
35
|
+
| ModelProperty
|
|
36
|
+
| NoneProperty
|
|
37
|
+
| StringProperty
|
|
38
|
+
| UnionProperty
|
|
39
|
+
| UuidProperty
|
|
40
|
+
)
|
|
@@ -88,20 +88,18 @@ class PropertyProtocol(Protocol):
|
|
|
88
88
|
PythonIdentifier(value=new_name, prefix=config.field_prefix, skip_snake_case=skip_snake_case),
|
|
89
89
|
)
|
|
90
90
|
|
|
91
|
-
def get_base_type_string(self
|
|
91
|
+
def get_base_type_string(self) -> str:
|
|
92
92
|
"""Get the string describing the Python type of this property. Base types no require quoting."""
|
|
93
|
-
return
|
|
93
|
+
return self._type_string
|
|
94
94
|
|
|
95
|
-
def get_base_json_type_string(self
|
|
95
|
+
def get_base_json_type_string(self) -> str:
|
|
96
96
|
"""Get the string describing the JSON type of this property. Base types no require quoting."""
|
|
97
|
-
return
|
|
97
|
+
return self._json_type_string
|
|
98
98
|
|
|
99
99
|
def get_type_string(
|
|
100
100
|
self,
|
|
101
101
|
no_optional: bool = False,
|
|
102
102
|
json: bool = False,
|
|
103
|
-
*,
|
|
104
|
-
quoted: bool = False,
|
|
105
103
|
) -> str:
|
|
106
104
|
"""
|
|
107
105
|
Get a string representation of type that should be used when declaring this property
|
|
@@ -109,20 +107,19 @@ class PropertyProtocol(Protocol):
|
|
|
109
107
|
Args:
|
|
110
108
|
no_optional: Do not include Optional or Unset even if the value is optional (needed for isinstance checks)
|
|
111
109
|
json: True if the type refers to the property after JSON serialization
|
|
112
|
-
quoted: True if the type should be wrapped in quotes (if not a base type)
|
|
113
110
|
"""
|
|
114
111
|
if json:
|
|
115
|
-
type_string = self.get_base_json_type_string(
|
|
112
|
+
type_string = self.get_base_json_type_string()
|
|
116
113
|
else:
|
|
117
|
-
type_string = self.get_base_type_string(
|
|
114
|
+
type_string = self.get_base_type_string()
|
|
118
115
|
|
|
119
116
|
if no_optional or self.required:
|
|
120
117
|
return type_string
|
|
121
|
-
return f"
|
|
118
|
+
return f"{type_string} | Unset"
|
|
122
119
|
|
|
123
120
|
def get_instance_type_string(self) -> str:
|
|
124
121
|
"""Get a string representation of runtime type that should be used for `isinstance` checks"""
|
|
125
|
-
return self.get_type_string(no_optional=True
|
|
122
|
+
return self.get_type_string(no_optional=True)
|
|
126
123
|
|
|
127
124
|
# noinspection PyUnusedLocal
|
|
128
125
|
def get_imports(self, *, prefix: str) -> set[str]:
|
|
@@ -135,7 +132,6 @@ class PropertyProtocol(Protocol):
|
|
|
135
132
|
"""
|
|
136
133
|
imports = set()
|
|
137
134
|
if not self.required:
|
|
138
|
-
imports.add("from typing import Union")
|
|
139
135
|
imports.add(f"from {prefix}types import UNSET, Unset")
|
|
140
136
|
return imports
|
|
141
137
|
|
|
@@ -159,8 +155,8 @@ class PropertyProtocol(Protocol):
|
|
|
159
155
|
default = None
|
|
160
156
|
|
|
161
157
|
if default is not None:
|
|
162
|
-
return f"{self.python_name}: {self.get_type_string(
|
|
163
|
-
return f"{self.python_name}: {self.get_type_string(
|
|
158
|
+
return f"{self.python_name}: {self.get_type_string()} = {default}"
|
|
159
|
+
return f"{self.python_name}: {self.get_type_string()}"
|
|
164
160
|
|
|
165
161
|
def to_docstring(self) -> str:
|
|
166
162
|
"""Returns property docstring"""
|
|
@@ -170,14 +166,3 @@ class PropertyProtocol(Protocol):
|
|
|
170
166
|
if self.example:
|
|
171
167
|
doc += f" Example: {self.example}."
|
|
172
168
|
return doc
|
|
173
|
-
|
|
174
|
-
@property
|
|
175
|
-
def is_base_type(self) -> bool:
|
|
176
|
-
"""Base types, represented by any other of `Property` than `ModelProperty` should not be quoted."""
|
|
177
|
-
from . import ListProperty, ModelProperty, UnionProperty # noqa: PLC0415
|
|
178
|
-
|
|
179
|
-
return self.__class__.__name__ not in {
|
|
180
|
-
ModelProperty.__name__,
|
|
181
|
-
ListProperty.__name__,
|
|
182
|
-
UnionProperty.__name__,
|
|
183
|
-
}
|
|
@@ -10,7 +10,7 @@ __all__ = [
|
|
|
10
10
|
"update_schemas_with_data",
|
|
11
11
|
]
|
|
12
12
|
|
|
13
|
-
from typing import TYPE_CHECKING, NewType,
|
|
13
|
+
from typing import TYPE_CHECKING, NewType, cast
|
|
14
14
|
from urllib.parse import urlparse
|
|
15
15
|
|
|
16
16
|
from attrs import define, evolve, field
|
|
@@ -32,7 +32,7 @@ else:
|
|
|
32
32
|
ReferencePath = NewType("ReferencePath", str)
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def parse_reference_path(ref_path_raw: str) ->
|
|
35
|
+
def parse_reference_path(ref_path_raw: str) -> ReferencePath | ParseError:
|
|
36
36
|
"""
|
|
37
37
|
Takes a raw string provided in a `$ref` and turns it into a validated `_ReferencePath` or a `ParseError` if
|
|
38
38
|
validation fails.
|
|
@@ -84,12 +84,12 @@ class Schemas:
|
|
|
84
84
|
"""Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)"""
|
|
85
85
|
|
|
86
86
|
classes_by_reference: dict[ReferencePath, Property] = field(factory=dict)
|
|
87
|
-
dependencies: dict[ReferencePath, set[
|
|
87
|
+
dependencies: dict[ReferencePath, set[ReferencePath | ClassName]] = field(factory=dict)
|
|
88
88
|
classes_by_name: dict[ClassName, Property] = field(factory=dict)
|
|
89
89
|
models_to_process: list[ModelProperty] = field(factory=list)
|
|
90
90
|
errors: list[ParseError] = field(factory=list)
|
|
91
91
|
|
|
92
|
-
def add_dependencies(self, ref_path: ReferencePath, roots: set[
|
|
92
|
+
def add_dependencies(self, ref_path: ReferencePath, roots: set[ReferencePath | ClassName]) -> None:
|
|
93
93
|
"""Record new dependencies on the given ReferencePath
|
|
94
94
|
|
|
95
95
|
Args:
|
|
@@ -102,7 +102,7 @@ class Schemas:
|
|
|
102
102
|
|
|
103
103
|
def update_schemas_with_data(
|
|
104
104
|
*, ref_path: ReferencePath, data: oai.Schema, schemas: Schemas, config: Config
|
|
105
|
-
) ->
|
|
105
|
+
) -> Schemas | PropertyError:
|
|
106
106
|
"""
|
|
107
107
|
Update a `Schemas` using some new reference.
|
|
108
108
|
|
|
@@ -120,7 +120,7 @@ def update_schemas_with_data(
|
|
|
120
120
|
"""
|
|
121
121
|
from . import property_from_data # noqa: PLC0415
|
|
122
122
|
|
|
123
|
-
prop:
|
|
123
|
+
prop: PropertyError | Property
|
|
124
124
|
prop, schemas = property_from_data(
|
|
125
125
|
data=data,
|
|
126
126
|
name=ref_path,
|
|
@@ -158,10 +158,10 @@ class Parameters:
|
|
|
158
158
|
def parameter_from_data(
|
|
159
159
|
*,
|
|
160
160
|
name: str,
|
|
161
|
-
data:
|
|
161
|
+
data: oai.Reference | oai.Parameter,
|
|
162
162
|
parameters: Parameters,
|
|
163
163
|
config: Config,
|
|
164
|
-
) -> tuple[
|
|
164
|
+
) -> tuple[Parameter | ParameterError, Parameters]:
|
|
165
165
|
"""Generates parameters from an OpenAPI Parameter spec."""
|
|
166
166
|
|
|
167
167
|
if isinstance(data, oai.Reference):
|
|
@@ -186,7 +186,7 @@ def parameter_from_data(
|
|
|
186
186
|
|
|
187
187
|
def update_parameters_with_data(
|
|
188
188
|
*, ref_path: ReferencePath, data: oai.Parameter, parameters: Parameters, config: Config
|
|
189
|
-
) ->
|
|
189
|
+
) -> Parameters | ParameterError:
|
|
190
190
|
"""
|
|
191
191
|
Update a `Parameters` using some new reference.
|
|
192
192
|
|
|
@@ -219,9 +219,9 @@ def update_parameters_with_data(
|
|
|
219
219
|
|
|
220
220
|
def parameter_from_reference(
|
|
221
221
|
*,
|
|
222
|
-
param:
|
|
222
|
+
param: oai.Reference | Parameter,
|
|
223
223
|
parameters: Parameters,
|
|
224
|
-
) ->
|
|
224
|
+
) -> Parameter | ParameterError:
|
|
225
225
|
"""
|
|
226
226
|
Returns a Parameter from a Reference or the Parameter itself if one was provided.
|
|
227
227
|
|
|
@@ -132,7 +132,6 @@ class UnionProperty(PropertyProtocol):
|
|
|
132
132
|
p.get_type_string(
|
|
133
133
|
no_optional=True,
|
|
134
134
|
json=json,
|
|
135
|
-
quoted=not p.is_base_type,
|
|
136
135
|
)
|
|
137
136
|
for p in self.inner_properties
|
|
138
137
|
}
|
|
@@ -141,12 +140,12 @@ class UnionProperty(PropertyProtocol):
|
|
|
141
140
|
def _get_type_string_from_inner_type_strings(inner_types: set[str]) -> str:
|
|
142
141
|
if len(inner_types) == 1:
|
|
143
142
|
return inner_types.pop()
|
|
144
|
-
return
|
|
143
|
+
return " | ".join(sorted(inner_types, key=lambda x: x.lower()))
|
|
145
144
|
|
|
146
|
-
def get_base_type_string(self
|
|
145
|
+
def get_base_type_string(self) -> str:
|
|
147
146
|
return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False))
|
|
148
147
|
|
|
149
|
-
def get_base_json_type_string(self
|
|
148
|
+
def get_base_json_type_string(self) -> str:
|
|
150
149
|
return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=True))
|
|
151
150
|
|
|
152
151
|
def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool) -> set[str]:
|
|
@@ -173,8 +172,6 @@ class UnionProperty(PropertyProtocol):
|
|
|
173
172
|
self,
|
|
174
173
|
no_optional: bool = False,
|
|
175
174
|
json: bool = False,
|
|
176
|
-
*,
|
|
177
|
-
quoted: bool = False,
|
|
178
175
|
) -> str:
|
|
179
176
|
"""
|
|
180
177
|
Get a string representation of type that should be used when declaring this property.
|
|
@@ -195,7 +192,7 @@ class UnionProperty(PropertyProtocol):
|
|
|
195
192
|
imports = super().get_imports(prefix=prefix)
|
|
196
193
|
for inner_prop in self.inner_properties:
|
|
197
194
|
imports.update(inner_prop.get_imports(prefix=prefix))
|
|
198
|
-
imports.add("from typing import cast
|
|
195
|
+
imports.add("from typing import cast")
|
|
199
196
|
return imports
|
|
200
197
|
|
|
201
198
|
def get_lazy_imports(self, *, prefix: str) -> set[str]:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
__all__ = ["HTTPStatusPattern", "Response", "Responses", "response_from_data"]
|
|
2
2
|
|
|
3
3
|
from collections.abc import Iterator
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import TypedDict
|
|
5
5
|
|
|
6
6
|
from attrs import define
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ from .properties import AnyProperty, Property, Schemas, property_from_data
|
|
|
18
18
|
@define
|
|
19
19
|
class Responses:
|
|
20
20
|
patterns: list["Response"]
|
|
21
|
-
default:
|
|
21
|
+
default: "Response | None"
|
|
22
22
|
|
|
23
23
|
def __iter__(self) -> Iterator["Response"]:
|
|
24
24
|
yield from self.patterns
|
|
@@ -52,15 +52,15 @@ class HTTPStatusPattern:
|
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
54
|
pattern: str
|
|
55
|
-
range:
|
|
55
|
+
range: tuple[int, int] | None
|
|
56
56
|
|
|
57
|
-
def __init__(self, *, pattern: str, code_range:
|
|
57
|
+
def __init__(self, *, pattern: str, code_range: tuple[int, int] | None):
|
|
58
58
|
"""Initialize with a range of status codes or None for the default case."""
|
|
59
59
|
self.pattern = pattern
|
|
60
60
|
self.range = code_range
|
|
61
61
|
|
|
62
62
|
@staticmethod
|
|
63
|
-
def parse(pattern: str) ->
|
|
63
|
+
def parse(pattern: str) -> "HTTPStatusPattern | ParseError":
|
|
64
64
|
"""Parse a status code pattern such as 2XX or 404"""
|
|
65
65
|
if pattern == "default":
|
|
66
66
|
return HTTPStatusPattern(pattern=pattern, code_range=None)
|
|
@@ -118,7 +118,7 @@ class Response:
|
|
|
118
118
|
status_code: HTTPStatusPattern
|
|
119
119
|
prop: Property
|
|
120
120
|
source: _ResponseSource
|
|
121
|
-
data:
|
|
121
|
+
data: oai.Response | oai.Reference # Original data which created this response, useful for custom templates
|
|
122
122
|
|
|
123
123
|
def is_default(self) -> bool:
|
|
124
124
|
return self.status_code.range is None
|
|
@@ -128,7 +128,7 @@ class Response:
|
|
|
128
128
|
return self.status_code < other.status_code
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
def _source_by_content_type(content_type: str, config: Config) ->
|
|
131
|
+
def _source_by_content_type(content_type: str, config: Config) -> _ResponseSource | None:
|
|
132
132
|
parsed_content_type = utils.get_content_type(content_type, config)
|
|
133
133
|
if parsed_content_type is None:
|
|
134
134
|
return None
|
|
@@ -152,7 +152,7 @@ def empty_response(
|
|
|
152
152
|
status_code: HTTPStatusPattern,
|
|
153
153
|
response_name: str,
|
|
154
154
|
config: Config,
|
|
155
|
-
data:
|
|
155
|
+
data: oai.Response | oai.Reference,
|
|
156
156
|
) -> Response:
|
|
157
157
|
"""Return an untyped response, for when no response type is defined"""
|
|
158
158
|
return Response(
|
|
@@ -173,12 +173,12 @@ def empty_response(
|
|
|
173
173
|
def response_from_data( # noqa: PLR0911
|
|
174
174
|
*,
|
|
175
175
|
status_code: HTTPStatusPattern,
|
|
176
|
-
data:
|
|
176
|
+
data: oai.Response | oai.Reference,
|
|
177
177
|
schemas: Schemas,
|
|
178
|
-
responses: dict[str,
|
|
178
|
+
responses: dict[str, oai.Response | oai.Reference],
|
|
179
179
|
parent_name: str,
|
|
180
180
|
config: Config,
|
|
181
|
-
) -> tuple[
|
|
181
|
+
) -> tuple[Response | ParseError, Schemas]:
|
|
182
182
|
"""Generate a Response from the OpenAPI dictionary representation of it"""
|
|
183
183
|
|
|
184
184
|
response_name = f"response_{status_code.pattern}"
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
from .callback import Callback
|
|
@@ -25,15 +23,15 @@ class Components(BaseModel):
|
|
|
25
23
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject
|
|
26
24
|
"""
|
|
27
25
|
|
|
28
|
-
schemas:
|
|
29
|
-
responses:
|
|
30
|
-
parameters:
|
|
31
|
-
examples:
|
|
32
|
-
requestBodies:
|
|
33
|
-
headers:
|
|
34
|
-
securitySchemes:
|
|
35
|
-
links:
|
|
36
|
-
callbacks:
|
|
26
|
+
schemas: dict[str, ReferenceOr[Schema]] | None = None
|
|
27
|
+
responses: dict[str, ReferenceOr[Response]] | None = None
|
|
28
|
+
parameters: dict[str, ReferenceOr[Parameter]] | None = None
|
|
29
|
+
examples: dict[str, ReferenceOr[Example]] | None = None
|
|
30
|
+
requestBodies: dict[str, ReferenceOr[RequestBody]] | None = None
|
|
31
|
+
headers: dict[str, ReferenceOr[Header]] | None = None
|
|
32
|
+
securitySchemes: dict[str, ReferenceOr[SecurityScheme]] | None = None
|
|
33
|
+
links: dict[str, ReferenceOr[Link]] | None = None
|
|
34
|
+
callbacks: dict[str, ReferenceOr[Callback]] | None = None
|
|
37
35
|
model_config = ConfigDict(
|
|
38
36
|
# `Callback` contains an unresolvable forward reference, will rebuild in `__init__.py`:
|
|
39
37
|
defer_build=True,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
|
|
@@ -11,9 +9,9 @@ class Contact(BaseModel):
|
|
|
11
9
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contactObject
|
|
12
10
|
"""
|
|
13
11
|
|
|
14
|
-
name:
|
|
15
|
-
url:
|
|
16
|
-
email:
|
|
12
|
+
name: str | None = None
|
|
13
|
+
url: str | None = None
|
|
14
|
+
email: str | None = None
|
|
17
15
|
model_config = ConfigDict(
|
|
18
16
|
extra="allow",
|
|
19
17
|
json_schema_extra={
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
|
|
@@ -19,7 +17,7 @@ class Discriminator(BaseModel):
|
|
|
19
17
|
"""
|
|
20
18
|
|
|
21
19
|
propertyName: str
|
|
22
|
-
mapping:
|
|
20
|
+
mapping: dict[str, str] | None = None
|
|
23
21
|
model_config = ConfigDict(
|
|
24
22
|
extra="allow",
|
|
25
23
|
json_schema_extra={
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, ConfigDict
|
|
4
4
|
|
|
@@ -16,9 +16,9 @@ class Encoding(BaseModel):
|
|
|
16
16
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encodingObject
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
contentType:
|
|
20
|
-
headers:
|
|
21
|
-
style:
|
|
19
|
+
contentType: str | None = None
|
|
20
|
+
headers: dict[str, ReferenceOr["Header"]] | None = None
|
|
21
|
+
style: str | None = None
|
|
22
22
|
explode: bool = False
|
|
23
23
|
allowReserved: bool = False
|
|
24
24
|
model_config = ConfigDict(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, ConfigDict
|
|
4
4
|
|
|
@@ -11,10 +11,10 @@ class Example(BaseModel):
|
|
|
11
11
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
summary:
|
|
15
|
-
description:
|
|
16
|
-
value:
|
|
17
|
-
externalValue:
|
|
14
|
+
summary: str | None = None
|
|
15
|
+
description: str | None = None
|
|
16
|
+
value: Any | None = None
|
|
17
|
+
externalValue: str | None = None
|
|
18
18
|
model_config = ConfigDict(
|
|
19
19
|
extra="allow",
|
|
20
20
|
json_schema_extra={
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
|
|
@@ -10,7 +8,7 @@ class ExternalDocumentation(BaseModel):
|
|
|
10
8
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject
|
|
11
9
|
"""
|
|
12
10
|
|
|
13
|
-
description:
|
|
11
|
+
description: str | None = None
|
|
14
12
|
url: str
|
|
15
13
|
model_config = ConfigDict(
|
|
16
14
|
extra="allow",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
from .contact import Contact
|
|
@@ -18,10 +16,10 @@ class Info(BaseModel):
|
|
|
18
16
|
"""
|
|
19
17
|
|
|
20
18
|
title: str
|
|
21
|
-
description:
|
|
22
|
-
termsOfService:
|
|
23
|
-
contact:
|
|
24
|
-
license:
|
|
19
|
+
description: str | None = None
|
|
20
|
+
termsOfService: str | None = None
|
|
21
|
+
contact: Contact | None = None
|
|
22
|
+
license: License | None = None
|
|
25
23
|
version: str
|
|
26
24
|
model_config = ConfigDict(
|
|
27
25
|
extra="allow",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
|
|
@@ -12,7 +10,7 @@ class License(BaseModel):
|
|
|
12
10
|
"""
|
|
13
11
|
|
|
14
12
|
name: str
|
|
15
|
-
url:
|
|
13
|
+
url: str | None = None
|
|
16
14
|
model_config = ConfigDict(
|
|
17
15
|
extra="allow",
|
|
18
16
|
json_schema_extra={
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, ConfigDict
|
|
4
4
|
|
|
@@ -23,12 +23,12 @@ class Link(BaseModel):
|
|
|
23
23
|
- https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#linkObject
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
operationRef:
|
|
27
|
-
operationId:
|
|
28
|
-
parameters:
|
|
29
|
-
requestBody:
|
|
30
|
-
description:
|
|
31
|
-
server:
|
|
26
|
+
operationRef: str | None = None
|
|
27
|
+
operationId: str | None = None
|
|
28
|
+
parameters: dict[str, Any] | None = None
|
|
29
|
+
requestBody: Any | None = None
|
|
30
|
+
description: str | None = None
|
|
31
|
+
server: Server | None = None
|
|
32
32
|
model_config = ConfigDict(
|
|
33
33
|
extra="allow",
|
|
34
34
|
json_schema_extra={
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, ConfigDict, Field
|
|
4
4
|
|
|
@@ -16,10 +16,10 @@ class MediaType(BaseModel):
|
|
|
16
16
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#mediaTypeObject
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
media_type_schema:
|
|
20
|
-
example:
|
|
21
|
-
examples:
|
|
22
|
-
encoding:
|
|
19
|
+
media_type_schema: ReferenceOr[Schema] | None = Field(default=None, alias="schema")
|
|
20
|
+
example: Any | None = None
|
|
21
|
+
examples: dict[str, ReferenceOr[Example]] | None = None
|
|
22
|
+
encoding: dict[str, Encoding] | None = None
|
|
23
23
|
model_config = ConfigDict(
|
|
24
24
|
# `Encoding` is not build yet, will rebuild in `__init__.py`:
|
|
25
25
|
defer_build=True,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
|
|
@@ -12,9 +10,9 @@ class OAuthFlow(BaseModel):
|
|
|
12
10
|
- https://swagger.io/docs/specification/authentication/oauth2/
|
|
13
11
|
"""
|
|
14
12
|
|
|
15
|
-
authorizationUrl:
|
|
16
|
-
tokenUrl:
|
|
17
|
-
refreshUrl:
|
|
13
|
+
authorizationUrl: str | None = None
|
|
14
|
+
tokenUrl: str | None = None
|
|
15
|
+
refreshUrl: str | None = None
|
|
18
16
|
scopes: dict[str, str]
|
|
19
17
|
model_config = ConfigDict(
|
|
20
18
|
extra="allow",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict
|
|
4
2
|
|
|
5
3
|
from .oauth_flow import OAuthFlow
|
|
@@ -14,8 +12,8 @@ class OAuthFlows(BaseModel):
|
|
|
14
12
|
- https://swagger.io/docs/specification/authentication/oauth2/
|
|
15
13
|
"""
|
|
16
14
|
|
|
17
|
-
implicit:
|
|
18
|
-
password:
|
|
19
|
-
clientCredentials:
|
|
20
|
-
authorizationCode:
|
|
15
|
+
implicit: OAuthFlow | None = None
|
|
16
|
+
password: OAuthFlow | None = None
|
|
17
|
+
clientCredentials: OAuthFlow | None = None
|
|
18
|
+
authorizationCode: OAuthFlow | None = None
|
|
21
19
|
model_config = ConfigDict(extra="allow")
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict, field_validator
|
|
4
2
|
|
|
5
3
|
from .components import Components
|
|
@@ -24,10 +22,10 @@ class OpenAPI(BaseModel):
|
|
|
24
22
|
info: Info
|
|
25
23
|
servers: list[Server] = [Server(url="/")]
|
|
26
24
|
paths: Paths
|
|
27
|
-
components:
|
|
28
|
-
security:
|
|
29
|
-
tags:
|
|
30
|
-
externalDocs:
|
|
25
|
+
components: Components | None = None
|
|
26
|
+
security: list[SecurityRequirement] | None = None
|
|
27
|
+
tags: list[Tag] | None = None
|
|
28
|
+
externalDocs: ExternalDocumentation | None = None
|
|
31
29
|
openapi: str
|
|
32
30
|
model_config = ConfigDict(
|
|
33
31
|
# `Components` is not build yet, will rebuild in `__init__.py`:
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import BaseModel, ConfigDict, Field
|
|
4
2
|
|
|
5
3
|
from .callback import Callback
|
|
@@ -20,19 +18,19 @@ class Operation(BaseModel):
|
|
|
20
18
|
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject
|
|
21
19
|
"""
|
|
22
20
|
|
|
23
|
-
tags:
|
|
24
|
-
summary:
|
|
25
|
-
description:
|
|
26
|
-
externalDocs:
|
|
27
|
-
operationId:
|
|
28
|
-
parameters:
|
|
29
|
-
request_body:
|
|
21
|
+
tags: list[str] | None = None
|
|
22
|
+
summary: str | None = None
|
|
23
|
+
description: str | None = None
|
|
24
|
+
externalDocs: ExternalDocumentation | None = None
|
|
25
|
+
operationId: str | None = None
|
|
26
|
+
parameters: list[ReferenceOr[Parameter]] | None = None
|
|
27
|
+
request_body: ReferenceOr[RequestBody] | None = Field(None, alias="requestBody")
|
|
30
28
|
responses: Responses
|
|
31
|
-
callbacks:
|
|
29
|
+
callbacks: dict[str, Callback] | None = None
|
|
32
30
|
|
|
33
31
|
deprecated: bool = False
|
|
34
|
-
security:
|
|
35
|
-
servers:
|
|
32
|
+
security: list[SecurityRequirement] | None = None
|
|
33
|
+
servers: list[Server] | None = None
|
|
36
34
|
model_config = ConfigDict(
|
|
37
35
|
# `Callback` contains an unresolvable forward reference, will rebuild in `__init__.py`:
|
|
38
36
|
defer_build=True,
|