@aws/nx-plugin 1.0.0 → 1.0.2
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.
- package/LICENSE-THIRD-PARTY +11686 -23398
- package/README.md +18 -0
- package/generators.json +7 -0
- package/migrations.json +39 -1
- package/package.json +6 -6
- package/src/agentcore-gateway/agent-connection/generator.js +6 -0
- package/src/agentcore-gateway/agent-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/schema.json +1 -0
- package/src/agentcore-harness/generator.d.ts +1 -1
- package/src/connection/scaffold-catalog.d.ts +21 -0
- package/src/connection/scaffold-catalog.js +14 -6
- package/src/connection/scaffold-catalog.js.map +1 -1
- package/src/infra/app/generator.d.ts +1 -1
- package/src/init/generator.d.ts +1 -1
- package/src/mcp-server/guide-pipeline.d.ts +2 -1
- package/src/mcp-server/guide-pipeline.js +6 -0
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/mdx-ast.d.ts +7 -0
- package/src/mcp-server/mdx-ast.js +15 -0
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/schema-registry.d.ts +2 -2
- package/src/mcp-server/schema-registry.js +2 -2
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/migrations/latest/terraform-harness-environment-variables/metadata.json +3 -0
- package/src/migrations/latest/terraform-harness-environment-variables/migration.d.ts +6 -0
- package/src/migrations/latest/terraform-harness-environment-variables/migration.js +54 -0
- package/src/migrations/latest/terraform-harness-environment-variables/migration.js.map +1 -0
- package/src/open-api/py-client/__snapshots__/generator.additional-properties.spec.ts.snap +34 -0
- package/src/open-api/py-client/__snapshots__/generator.arrays.spec.ts.snap +1750 -0
- package/src/open-api/py-client/__snapshots__/generator.complex-types.spec.ts.snap +82 -0
- package/src/open-api/py-client/__snapshots__/generator.composite-types.spec.ts.snap +447 -0
- package/src/open-api/py-client/__snapshots__/generator.duplicate-types.spec.ts.snap +404 -0
- package/src/open-api/py-client/__snapshots__/generator.errors.spec.ts.snap +430 -0
- package/src/open-api/py-client/__snapshots__/generator.fast-api.spec.ts.snap +447 -0
- package/src/open-api/py-client/__snapshots__/generator.petstore.spec.ts.snap +3488 -0
- package/src/open-api/py-client/__snapshots__/generator.primitive-types.spec.ts.snap +1444 -0
- package/src/open-api/py-client/__snapshots__/generator.request.spec.ts.snap +390 -0
- package/src/open-api/py-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +364 -0
- package/src/open-api/py-client/__snapshots__/generator.response.spec.ts.snap +739 -0
- package/src/open-api/py-client/__snapshots__/generator.streaming.spec.ts.snap +384 -0
- package/src/open-api/py-client/__snapshots__/generator.tags.spec.ts.snap +414 -0
- package/src/open-api/py-client/files/client/__clientModuleName__.py.template +1076 -0
- package/src/open-api/py-client/files/shared/__init__.py.template +28 -0
- package/src/open-api/py-client/files/shared/errors.py.template +37 -0
- package/src/open-api/py-client/files/shared/types.py.template +319 -0
- package/src/open-api/py-client/generator.d.ts +53 -0
- package/src/open-api/py-client/generator.js +119 -0
- package/src/open-api/py-client/generator.js.map +1 -0
- package/src/open-api/py-client/schema.d.js +6 -0
- package/src/open-api/py-client/schema.d.js.map +1 -0
- package/src/open-api/py-client/schema.d.ts +12 -0
- package/src/open-api/py-client/schema.json +28 -0
- package/src/open-api/py-client/vessel-registry-spec.json +2716 -0
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +274 -0
- package/src/open-api/ts-client/petstore-spec.d.ts +6 -0
- package/src/open-api/ts-client/petstore-spec.js +1275 -0
- package/src/open-api/ts-client/petstore-spec.js.map +1 -0
- package/src/open-api/ts-hooks/generator.spec.tsx +1 -1
- package/src/open-api/utils/codegen-data/languages.d.ts +68 -2
- package/src/open-api/utils/codegen-data/languages.js +433 -21
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.d.ts +187 -0
- package/src/open-api/utils/codegen-data/types.js +10 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +40 -1
- package/src/open-api/utils/codegen-data.js +622 -17
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +175 -41
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.js +1 -1
- package/src/open-api/utils/parser.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/preset/generator.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.js +0 -3
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/generator.d.ts +1 -1
- package/src/py/agent/schema.json +2 -0
- package/src/py/fast-api/react/generator.d.ts +1 -1
- package/src/py/mcp-server/schema.json +1 -0
- package/src/sdk/open-api.d.ts +2 -0
- package/src/sdk/open-api.js +1 -0
- package/src/sdk/open-api.js.map +1 -1
- package/src/smithy/project/generator.d.ts +1 -1
- package/src/smithy/react-connection/generator.d.ts +1 -1
- package/src/terraform/project/generator.d.ts +1 -1
- package/src/trpc/react/generator.d.ts +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.js +0 -3
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +1 -1
- package/src/ts/agent/schema.json +1 -0
- package/src/ts/api/schema.json +2 -0
- package/src/ts/astro-docs/generator.d.ts +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +1 -1
- package/src/ts/lambda-function/generator.d.ts +1 -1
- package/src/ts/lib/generator.d.ts +1 -1
- package/src/ts/mcp-server/schema.json +1 -0
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.spec.ts.template +1 -1
- package/src/ts/nx-generator/generator.d.ts +1 -1
- package/src/ts/nx-migration/generator.d.ts +1 -1
- package/src/ts/nx-plugin/generator.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +1 -1
- package/src/ts/react-website/agui/generator.d.ts +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +10 -10
- package/src/ts/react-website/app/schema.json +1 -0
- package/src/ts/website/app/schema.json +1 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-harness/__nameKebabCase__/__nameKebabCase__.tf.template +1 -1
- package/src/utils/metrics-assertions.d.ts +18 -0
- package/src/utils/metrics-assertions.js +42 -0
- package/src/utils/metrics-assertions.js.map +1 -0
- package/src/utils/test/python-dependencies.d.ts +8 -0
- package/src/utils/test/python-dependencies.js +14 -0
- package/src/utils/test/python-dependencies.js.map +1 -0
- package/src/utils/test/python-worker/worker.py +703 -0
- package/src/utils/test/warm-python-cache.d.ts +18 -0
- package/src/utils/test/warm-python-cache.js +46 -0
- package/src/utils/test/warm-python-cache.js.map +1 -0
- package/src/utils/versions.d.ts +10 -9
- package/src/utils/versions.js +9 -8
- package/src/utils/versions.js.map +1 -1
|
@@ -0,0 +1,3488 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`openApiPyClientGenerator - petstore > should generate valid Python for the full petstore example > async_client.py 1`] = `
|
|
4
|
+
""""AsyncSwaggerPetstoreOpenAPI30 — AUTO-GENERATED asynchronous client."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import datetime
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Any, Literal, TypeVar
|
|
11
|
+
from urllib.parse import quote
|
|
12
|
+
|
|
13
|
+
import httpx
|
|
14
|
+
from pydantic import BaseModel, TypeAdapter, ValidationError
|
|
15
|
+
|
|
16
|
+
from . import types
|
|
17
|
+
from .errors import (
|
|
18
|
+
AddPetApiError as AddPetApiError,
|
|
19
|
+
)
|
|
20
|
+
from .errors import (
|
|
21
|
+
ApiError as ApiError,
|
|
22
|
+
)
|
|
23
|
+
from .errors import (
|
|
24
|
+
CreateUserApiError as CreateUserApiError,
|
|
25
|
+
)
|
|
26
|
+
from .errors import (
|
|
27
|
+
CreateUsersWithListInputApiError as CreateUsersWithListInputApiError,
|
|
28
|
+
)
|
|
29
|
+
from .errors import (
|
|
30
|
+
DeleteOrderApiError as DeleteOrderApiError,
|
|
31
|
+
)
|
|
32
|
+
from .errors import (
|
|
33
|
+
DeletePetApiError as DeletePetApiError,
|
|
34
|
+
)
|
|
35
|
+
from .errors import (
|
|
36
|
+
DeleteUserApiError as DeleteUserApiError,
|
|
37
|
+
)
|
|
38
|
+
from .errors import (
|
|
39
|
+
FindPetsByStatusApiError as FindPetsByStatusApiError,
|
|
40
|
+
)
|
|
41
|
+
from .errors import (
|
|
42
|
+
FindPetsByTagsApiError as FindPetsByTagsApiError,
|
|
43
|
+
)
|
|
44
|
+
from .errors import (
|
|
45
|
+
GetInventoryApiError as GetInventoryApiError,
|
|
46
|
+
)
|
|
47
|
+
from .errors import (
|
|
48
|
+
GetOrderByIdApiError as GetOrderByIdApiError,
|
|
49
|
+
)
|
|
50
|
+
from .errors import (
|
|
51
|
+
GetPetByIdApiError as GetPetByIdApiError,
|
|
52
|
+
)
|
|
53
|
+
from .errors import (
|
|
54
|
+
GetUserByNameApiError as GetUserByNameApiError,
|
|
55
|
+
)
|
|
56
|
+
from .errors import (
|
|
57
|
+
LoginUserApiError as LoginUserApiError,
|
|
58
|
+
)
|
|
59
|
+
from .errors import (
|
|
60
|
+
LogoutUserApiError as LogoutUserApiError,
|
|
61
|
+
)
|
|
62
|
+
from .errors import (
|
|
63
|
+
PlaceOrderApiError as PlaceOrderApiError,
|
|
64
|
+
)
|
|
65
|
+
from .errors import (
|
|
66
|
+
UpdatePetApiError as UpdatePetApiError,
|
|
67
|
+
)
|
|
68
|
+
from .errors import (
|
|
69
|
+
UpdatePetWithFormApiError as UpdatePetWithFormApiError,
|
|
70
|
+
)
|
|
71
|
+
from .errors import (
|
|
72
|
+
UpdateUserApiError as UpdateUserApiError,
|
|
73
|
+
)
|
|
74
|
+
from .errors import (
|
|
75
|
+
UploadFileApiError as UploadFileApiError,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
_ErrorT = TypeVar("_ErrorT", bound=BaseModel)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class AsyncSwaggerPetstoreOpenAPI30Config:
|
|
83
|
+
"""Client configuration for AsyncSwaggerPetstoreOpenAPI30."""
|
|
84
|
+
|
|
85
|
+
#: Base URL for the API.
|
|
86
|
+
url: str
|
|
87
|
+
#: Client used for every request. Supply your own to add authentication or
|
|
88
|
+
#: any other middleware — an \`\`httpx.Auth\`\` (e.g. a SigV4 signer), an event
|
|
89
|
+
#: hook, a custom transport, timeouts, retries or a proxy all apply, and the
|
|
90
|
+
#: client's own headers and query params are sent alongside each operation's.
|
|
91
|
+
#: A supplied client is never closed by this one, so it can be shared.
|
|
92
|
+
httpx_client: httpx.AsyncClient | None = None
|
|
93
|
+
#: Headers added to every request, where the operation sets none itself.
|
|
94
|
+
headers: dict[str, str] = field(default_factory=dict)
|
|
95
|
+
#: By default the client sends a Content-Type header set to the media type
|
|
96
|
+
#: the OpenAPI specification declares for the request. Set this to omit it.
|
|
97
|
+
omit_content_type_header: bool = False
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class AsyncSwaggerPetstoreOpenAPI30:
|
|
101
|
+
"""Asynchronous API client for SwaggerPetstoreOpenAPI30."""
|
|
102
|
+
|
|
103
|
+
def __init__(self, config: AsyncSwaggerPetstoreOpenAPI30Config) -> None:
|
|
104
|
+
self._config = config
|
|
105
|
+
self._client = config.httpx_client or httpx.AsyncClient()
|
|
106
|
+
self._owns_client = config.httpx_client is None
|
|
107
|
+
self._base_url = config.url.rstrip("/")
|
|
108
|
+
self.pet: _AsyncPetNamespace = _AsyncPetNamespace(self)
|
|
109
|
+
self.user: _AsyncUserNamespace = _AsyncUserNamespace(self)
|
|
110
|
+
self.store: _AsyncStoreNamespace = _AsyncStoreNamespace(self)
|
|
111
|
+
|
|
112
|
+
async def __aenter__(self) -> AsyncSwaggerPetstoreOpenAPI30:
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
async def __aexit__(self, *exc: Any) -> None:
|
|
116
|
+
await self.aclose()
|
|
117
|
+
|
|
118
|
+
async def aclose(self) -> None:
|
|
119
|
+
if self._owns_client:
|
|
120
|
+
await self._client.aclose()
|
|
121
|
+
|
|
122
|
+
def _url(
|
|
123
|
+
self,
|
|
124
|
+
path: str,
|
|
125
|
+
path_params: dict[str, Any],
|
|
126
|
+
path_styles: dict[str, tuple[str, bool]] | None = None,
|
|
127
|
+
) -> str:
|
|
128
|
+
for key, value in path_params.items():
|
|
129
|
+
style, explode = (path_styles or {}).get(key, ("simple", False))
|
|
130
|
+
# An object expands to its key,value members; a list to its items.
|
|
131
|
+
# Each is encoded on its own so the separators between them stay
|
|
132
|
+
# literal, as RFC 6570 requires.
|
|
133
|
+
dumped = self._dump(value)
|
|
134
|
+
if isinstance(dumped, dict):
|
|
135
|
+
values = [
|
|
136
|
+
part
|
|
137
|
+
for k, v in dumped.items()
|
|
138
|
+
if v is not None
|
|
139
|
+
for part in (k, self._scalar(v))
|
|
140
|
+
]
|
|
141
|
+
elif isinstance(dumped, list):
|
|
142
|
+
values = list(dumped)
|
|
143
|
+
else:
|
|
144
|
+
values = [value]
|
|
145
|
+
if style == "matrix":
|
|
146
|
+
# RFC 6570 path-style expansion: ;key=a,b (explode: ;key=a;key=b)
|
|
147
|
+
if explode:
|
|
148
|
+
rendered = "".join(
|
|
149
|
+
";" + key + "=" + quote(self._scalar(v), safe="")
|
|
150
|
+
for v in values
|
|
151
|
+
)
|
|
152
|
+
else:
|
|
153
|
+
rendered = (
|
|
154
|
+
";"
|
|
155
|
+
+ key
|
|
156
|
+
+ "="
|
|
157
|
+
+ ",".join(quote(self._scalar(v), safe="") for v in values)
|
|
158
|
+
)
|
|
159
|
+
elif style == "label":
|
|
160
|
+
# RFC 6570 label expansion: .a,b (explode: .a.b)
|
|
161
|
+
rendered = "." + ("." if explode else ",").join(
|
|
162
|
+
quote(self._scalar(v), safe="") for v in values
|
|
163
|
+
)
|
|
164
|
+
else:
|
|
165
|
+
# RFC 6570 simple expansion: a list renders comma-separated.
|
|
166
|
+
rendered = ",".join(quote(self._scalar(v), safe="") for v in values)
|
|
167
|
+
path = path.replace("{" + key + "}", rendered)
|
|
168
|
+
return self._base_url + path
|
|
169
|
+
|
|
170
|
+
def _deep_object(self, key: str, value: Any, out: dict[str, Any]) -> None:
|
|
171
|
+
if isinstance(value, BaseModel):
|
|
172
|
+
value = value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
173
|
+
if isinstance(value, dict):
|
|
174
|
+
for prop, v in value.items():
|
|
175
|
+
self._deep_object(f"{key}[{prop}]", v, out)
|
|
176
|
+
elif value is not None:
|
|
177
|
+
out[key] = value
|
|
178
|
+
|
|
179
|
+
_COLLECTION_DELIMITERS = {"csv": ",", "ssv": " ", "pipes": "|"}
|
|
180
|
+
|
|
181
|
+
#: Characters left literal in a cookie value: every RFC 6265 cookie-octet
|
|
182
|
+
#: except the \`,\` and \`;\` this client joins members on. A \`=\` stays literal
|
|
183
|
+
#: too — only the first one separates a cookie's name from its value.
|
|
184
|
+
_COOKIE_SAFE = "!#$%&'()*+-./:<>?@[]^_\`{|}~="
|
|
185
|
+
|
|
186
|
+
def _scalar(self, value: Any) -> str:
|
|
187
|
+
# The wire form of a single parameter value: JSON spellings for bools,
|
|
188
|
+
# ISO-8601 for dates, and the model's own wire shape for anything else.
|
|
189
|
+
if isinstance(value, bool):
|
|
190
|
+
return "true" if value else "false"
|
|
191
|
+
if isinstance(value, (datetime.date, datetime.datetime)):
|
|
192
|
+
return value.isoformat()
|
|
193
|
+
dumped = self._dump(value)
|
|
194
|
+
if isinstance(dumped, str):
|
|
195
|
+
return dumped
|
|
196
|
+
# RFC 6570 renders a list as its comma-joined members and an object as
|
|
197
|
+
# comma-joined key,value pairs. Python's own \`str\` would emit a repr —
|
|
198
|
+
# \`['a', 'b']\`, quotes and spaces included.
|
|
199
|
+
if isinstance(dumped, list):
|
|
200
|
+
return ",".join(self._scalar(v) for v in dumped)
|
|
201
|
+
if isinstance(dumped, dict):
|
|
202
|
+
return ",".join(
|
|
203
|
+
f"{k},{self._scalar(v)}" for k, v in dumped.items() if v is not None
|
|
204
|
+
)
|
|
205
|
+
if dumped is None:
|
|
206
|
+
return ""
|
|
207
|
+
return str(dumped)
|
|
208
|
+
|
|
209
|
+
def _query(
|
|
210
|
+
self,
|
|
211
|
+
query_params: dict[str, Any],
|
|
212
|
+
collection_formats: dict[str, str] | None = None,
|
|
213
|
+
) -> dict[str, Any]:
|
|
214
|
+
out: dict[str, Any] = {}
|
|
215
|
+
for key, value in query_params.items():
|
|
216
|
+
if value is None:
|
|
217
|
+
continue
|
|
218
|
+
fmt = (collection_formats or {}).get(key)
|
|
219
|
+
if fmt == "deepObject":
|
|
220
|
+
self._deep_object(key, value, out)
|
|
221
|
+
elif isinstance(value, list):
|
|
222
|
+
delimiter = self._COLLECTION_DELIMITERS.get(fmt or "multi")
|
|
223
|
+
if delimiter is None:
|
|
224
|
+
out[key] = [self._scalar(v) for v in value]
|
|
225
|
+
else:
|
|
226
|
+
out[key] = delimiter.join(self._scalar(v) for v in value)
|
|
227
|
+
elif self._is_object(value):
|
|
228
|
+
# OpenAPI's default query style is form/explode, under which an
|
|
229
|
+
# object expands to one parameter per property rather than
|
|
230
|
+
# being stringified.
|
|
231
|
+
for prop, prop_value in self._as_dict(value).items():
|
|
232
|
+
if prop_value is not None:
|
|
233
|
+
out[prop] = self._scalar(prop_value)
|
|
234
|
+
else:
|
|
235
|
+
out[key] = self._scalar(value)
|
|
236
|
+
return out
|
|
237
|
+
|
|
238
|
+
def _is_object(self, value: Any) -> bool:
|
|
239
|
+
return isinstance(value, (dict, BaseModel))
|
|
240
|
+
|
|
241
|
+
def _as_dict(self, value: Any) -> dict[str, Any]:
|
|
242
|
+
if isinstance(value, BaseModel):
|
|
243
|
+
return value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
244
|
+
return dict(value)
|
|
245
|
+
|
|
246
|
+
def _headers(
|
|
247
|
+
self,
|
|
248
|
+
header_params: dict[str, Any] | None = None,
|
|
249
|
+
collection_formats: dict[str, str] | None = None,
|
|
250
|
+
cookie_params: dict[str, Any] | None = None,
|
|
251
|
+
) -> list[tuple[str, str]]:
|
|
252
|
+
out: list[tuple[str, str]] = []
|
|
253
|
+
for key, value in (header_params or {}).items():
|
|
254
|
+
if value is None:
|
|
255
|
+
continue
|
|
256
|
+
if isinstance(value, list):
|
|
257
|
+
fmt = (collection_formats or {}).get(key, "csv")
|
|
258
|
+
delimiter = self._COLLECTION_DELIMITERS.get(fmt)
|
|
259
|
+
if delimiter is None:
|
|
260
|
+
for item in value:
|
|
261
|
+
out.append((key, self._scalar(item)))
|
|
262
|
+
else:
|
|
263
|
+
out.append((key, delimiter.join(self._scalar(v) for v in value)))
|
|
264
|
+
else:
|
|
265
|
+
out.append((key, self._scalar(value)))
|
|
266
|
+
# A config header only applies where the operation didn't set one:
|
|
267
|
+
# httpx comma-joins repeated names, which would corrupt the value.
|
|
268
|
+
operation_headers = {key.lower() for key, _ in out}
|
|
269
|
+
out.extend(
|
|
270
|
+
(key, value)
|
|
271
|
+
for key, value in self._config.headers.items()
|
|
272
|
+
if key.lower() not in operation_headers
|
|
273
|
+
)
|
|
274
|
+
# The operation's cookies are merged into one \`Cookie\` header alongside
|
|
275
|
+
# every other source. Passing them to httpx's \`cookies=\` instead would
|
|
276
|
+
# drop them outright whenever a \`Cookie\` header is present, since
|
|
277
|
+
# http.cookiejar skips a request that already carries one — and setting
|
|
278
|
+
# the header here would in turn shadow the caller's own jar and header,
|
|
279
|
+
# which httpx resolves in favour of the more specific value.
|
|
280
|
+
cookies = self._cookies(cookie_params or {})
|
|
281
|
+
if cookies:
|
|
282
|
+
pairs = [
|
|
283
|
+
*(
|
|
284
|
+
value
|
|
285
|
+
for source in (self._client.headers, dict(out))
|
|
286
|
+
for key, value in source.items()
|
|
287
|
+
if key.lower() == "cookie"
|
|
288
|
+
),
|
|
289
|
+
*(f"{key}={value}" for key, value in self._client.cookies.items()),
|
|
290
|
+
*(f"{key}={value}" for key, value in cookies.items()),
|
|
291
|
+
]
|
|
292
|
+
out = [(key, value) for key, value in out if key.lower() != "cookie"]
|
|
293
|
+
out.append(("Cookie", "; ".join(pairs)))
|
|
294
|
+
return out
|
|
295
|
+
|
|
296
|
+
def _default_content_type(
|
|
297
|
+
self, header_params: dict[str, Any], media_type: str
|
|
298
|
+
) -> None:
|
|
299
|
+
# The media type the specification declares, applied unless the operation
|
|
300
|
+
# takes a Content-Type of its own and the caller supplied one. Header
|
|
301
|
+
# names are case-insensitive, and a declared header the caller omitted is
|
|
302
|
+
# present holding \`None\` — neither counts as the caller setting it.
|
|
303
|
+
if any(
|
|
304
|
+
key.lower() == "content-type" and value is not None
|
|
305
|
+
for key, value in header_params.items()
|
|
306
|
+
):
|
|
307
|
+
return
|
|
308
|
+
for key in list(header_params):
|
|
309
|
+
if key.lower() == "content-type":
|
|
310
|
+
header_params[key] = media_type
|
|
311
|
+
return
|
|
312
|
+
header_params["Content-Type"] = media_type
|
|
313
|
+
|
|
314
|
+
def _cookies(self, cookie_params: dict[str, Any]) -> dict[str, str]:
|
|
315
|
+
out: dict[str, str] = {}
|
|
316
|
+
for key, value in cookie_params.items():
|
|
317
|
+
if value is None:
|
|
318
|
+
continue
|
|
319
|
+
dumped = self._dump(value)
|
|
320
|
+
# A cookie uses form-style expansion, so a list joins on \`,\` and an
|
|
321
|
+
# object on \`,\` between each key and value. Members are encoded so a
|
|
322
|
+
# \`;\` or \`,\` inside one can't be read as a delimiter, while the
|
|
323
|
+
# joining commas stay literal.
|
|
324
|
+
if isinstance(dumped, list):
|
|
325
|
+
rendered = ",".join(self._cookie_value(v) for v in dumped)
|
|
326
|
+
elif isinstance(dumped, dict):
|
|
327
|
+
rendered = ",".join(
|
|
328
|
+
self._cookie_value(k) + "," + self._cookie_value(v)
|
|
329
|
+
for k, v in dumped.items()
|
|
330
|
+
if v is not None
|
|
331
|
+
)
|
|
332
|
+
else:
|
|
333
|
+
rendered = self._cookie_value(value)
|
|
334
|
+
out[key] = rendered
|
|
335
|
+
return out
|
|
336
|
+
|
|
337
|
+
def _cookie_value(self, value: Any) -> str:
|
|
338
|
+
# Only the characters a cookie parser treats as structure are escaped, so
|
|
339
|
+
# a timestamp keeps its colons and a base64 token its \`=\` padding. Servers
|
|
340
|
+
# do not URL-decode cookies, so anything escaped here arrives escaped.
|
|
341
|
+
return quote(self._scalar(value), safe=self._COOKIE_SAFE)
|
|
342
|
+
|
|
343
|
+
def _dump(self, value: Any) -> Any:
|
|
344
|
+
if value is None:
|
|
345
|
+
return None
|
|
346
|
+
if isinstance(value, BaseModel):
|
|
347
|
+
return value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
348
|
+
if isinstance(value, (list, tuple)):
|
|
349
|
+
return [self._dump(v) for v in value]
|
|
350
|
+
if isinstance(value, dict):
|
|
351
|
+
return {k: self._dump(v) for k, v in value.items()}
|
|
352
|
+
if isinstance(value, (datetime.date, datetime.datetime)):
|
|
353
|
+
return value.isoformat()
|
|
354
|
+
return value
|
|
355
|
+
|
|
356
|
+
def _json_body(self, response: httpx.Response) -> Any:
|
|
357
|
+
# A response declaring JSON alongside another media type can arrive as
|
|
358
|
+
# either, and a declared-JSON body can arrive empty (a 200 with no
|
|
359
|
+
# content). Both would raise a bare JSONDecodeError out of the client, so
|
|
360
|
+
# the text is handed over instead.
|
|
361
|
+
if not response.content:
|
|
362
|
+
return None
|
|
363
|
+
try:
|
|
364
|
+
return response.json()
|
|
365
|
+
except ValueError:
|
|
366
|
+
return response.text
|
|
367
|
+
|
|
368
|
+
def _error_payload(self, response: httpx.Response) -> Any:
|
|
369
|
+
# An error body is whatever the server actually sent, which need not be
|
|
370
|
+
# the JSON the spec declares (a proxy's HTML page, say).
|
|
371
|
+
try:
|
|
372
|
+
return response.json()
|
|
373
|
+
except ValueError:
|
|
374
|
+
return response.text
|
|
375
|
+
|
|
376
|
+
def _error(self, wrapper: type[_ErrorT], status: int, payload: Any) -> _ErrorT:
|
|
377
|
+
# Coerce to the declared error type, falling back to the raw payload so
|
|
378
|
+
# a body that doesn't match the spec still raises the typed exception.
|
|
379
|
+
try:
|
|
380
|
+
return wrapper.model_validate({"status": status, "error": payload})
|
|
381
|
+
except ValidationError:
|
|
382
|
+
return wrapper.model_construct(status=status, error=payload)
|
|
383
|
+
|
|
384
|
+
async def _add_pet(
|
|
385
|
+
self,
|
|
386
|
+
*,
|
|
387
|
+
name: str,
|
|
388
|
+
photo_urls: list[str],
|
|
389
|
+
id: int | None = None,
|
|
390
|
+
category: types.Category | None = None,
|
|
391
|
+
tags: list[types.Tag] | None = None,
|
|
392
|
+
status: types.PetStatus | None = None,
|
|
393
|
+
) -> types.Pet:
|
|
394
|
+
"""Add a new pet to the store."""
|
|
395
|
+
header_params: dict[str, Any] = {}
|
|
396
|
+
_body_fields: dict[str, Any] = {}
|
|
397
|
+
_body_fields["name"] = name
|
|
398
|
+
_body_fields["photoUrls"] = photo_urls
|
|
399
|
+
if id is not None:
|
|
400
|
+
_body_fields["id"] = id
|
|
401
|
+
if category is not None:
|
|
402
|
+
_body_fields["category"] = category
|
|
403
|
+
if tags is not None:
|
|
404
|
+
_body_fields["tags"] = tags
|
|
405
|
+
if status is not None:
|
|
406
|
+
_body_fields["status"] = status
|
|
407
|
+
body = types.Pet.model_validate(_body_fields).model_dump(
|
|
408
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
409
|
+
)
|
|
410
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
411
|
+
if not self._config.omit_content_type_header:
|
|
412
|
+
self._default_content_type(header_params, "application/json")
|
|
413
|
+
_request_url = self._url("/pet", {})
|
|
414
|
+
response = await self._client.request(
|
|
415
|
+
"POST",
|
|
416
|
+
_request_url,
|
|
417
|
+
headers=self._headers(header_params),
|
|
418
|
+
**request_kwargs,
|
|
419
|
+
)
|
|
420
|
+
if response.status_code == 200:
|
|
421
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
422
|
+
if response.status_code == 400:
|
|
423
|
+
raise AddPetApiError(
|
|
424
|
+
response.status_code,
|
|
425
|
+
self._error(types.AddPet400Error, 400, None),
|
|
426
|
+
)
|
|
427
|
+
if response.status_code == 422:
|
|
428
|
+
raise AddPetApiError(
|
|
429
|
+
response.status_code,
|
|
430
|
+
self._error(types.AddPet422Error, 422, None),
|
|
431
|
+
)
|
|
432
|
+
raise AddPetApiError(
|
|
433
|
+
response.status_code,
|
|
434
|
+
self._error(types.AddPetDefaultError, response.status_code, None),
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
async def _create_user(
|
|
438
|
+
self,
|
|
439
|
+
*,
|
|
440
|
+
id: int | None = None,
|
|
441
|
+
username: str | None = None,
|
|
442
|
+
first_name: str | None = None,
|
|
443
|
+
last_name: str | None = None,
|
|
444
|
+
email: str | None = None,
|
|
445
|
+
password: str | None = None,
|
|
446
|
+
phone: str | None = None,
|
|
447
|
+
user_status: int | None = None,
|
|
448
|
+
) -> types.User:
|
|
449
|
+
"""This can only be done by the logged in user."""
|
|
450
|
+
header_params: dict[str, Any] = {}
|
|
451
|
+
_body_fields: dict[str, Any] = {}
|
|
452
|
+
if id is not None:
|
|
453
|
+
_body_fields["id"] = id
|
|
454
|
+
if username is not None:
|
|
455
|
+
_body_fields["username"] = username
|
|
456
|
+
if first_name is not None:
|
|
457
|
+
_body_fields["firstName"] = first_name
|
|
458
|
+
if last_name is not None:
|
|
459
|
+
_body_fields["lastName"] = last_name
|
|
460
|
+
if email is not None:
|
|
461
|
+
_body_fields["email"] = email
|
|
462
|
+
if password is not None:
|
|
463
|
+
_body_fields["password"] = password
|
|
464
|
+
if phone is not None:
|
|
465
|
+
_body_fields["phone"] = phone
|
|
466
|
+
if user_status is not None:
|
|
467
|
+
_body_fields["userStatus"] = user_status
|
|
468
|
+
body = types.User.model_validate(_body_fields).model_dump(
|
|
469
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
470
|
+
)
|
|
471
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
472
|
+
if not self._config.omit_content_type_header:
|
|
473
|
+
self._default_content_type(header_params, "application/json")
|
|
474
|
+
_request_url = self._url("/user", {})
|
|
475
|
+
response = await self._client.request(
|
|
476
|
+
"POST",
|
|
477
|
+
_request_url,
|
|
478
|
+
headers=self._headers(header_params),
|
|
479
|
+
**request_kwargs,
|
|
480
|
+
)
|
|
481
|
+
if response.status_code == 200:
|
|
482
|
+
return types.User.model_validate(self._json_body(response))
|
|
483
|
+
raise CreateUserApiError(
|
|
484
|
+
response.status_code,
|
|
485
|
+
self._error(types.CreateUserDefaultError, response.status_code, None),
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
async def _create_users_with_list_input(
|
|
489
|
+
self,
|
|
490
|
+
body: list[types.User] | None = None,
|
|
491
|
+
) -> types.User:
|
|
492
|
+
"""Creates list of users with given input array."""
|
|
493
|
+
header_params: dict[str, Any] = {}
|
|
494
|
+
body = self._dump(body)
|
|
495
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
496
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
497
|
+
self._default_content_type(header_params, "application/json")
|
|
498
|
+
_request_url = self._url("/user/createWithList", {})
|
|
499
|
+
response = await self._client.request(
|
|
500
|
+
"POST",
|
|
501
|
+
_request_url,
|
|
502
|
+
headers=self._headers(header_params),
|
|
503
|
+
**request_kwargs,
|
|
504
|
+
)
|
|
505
|
+
if response.status_code == 200:
|
|
506
|
+
return types.User.model_validate(self._json_body(response))
|
|
507
|
+
raise CreateUsersWithListInputApiError(
|
|
508
|
+
response.status_code,
|
|
509
|
+
self._error(
|
|
510
|
+
types.CreateUsersWithListInputDefaultError, response.status_code, None
|
|
511
|
+
),
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
async def _delete_order(
|
|
515
|
+
self,
|
|
516
|
+
*,
|
|
517
|
+
order_id: int,
|
|
518
|
+
) -> None:
|
|
519
|
+
"""
|
|
520
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API
|
|
521
|
+
errors.
|
|
522
|
+
"""
|
|
523
|
+
path_params: dict[str, Any] = {"orderId": order_id}
|
|
524
|
+
request_kwargs: dict[str, Any] = {}
|
|
525
|
+
_request_url = self._url("/store/order/{orderId}", path_params)
|
|
526
|
+
response = await self._client.request(
|
|
527
|
+
"DELETE",
|
|
528
|
+
_request_url,
|
|
529
|
+
headers=self._headers(),
|
|
530
|
+
**request_kwargs,
|
|
531
|
+
)
|
|
532
|
+
if response.status_code == 200:
|
|
533
|
+
return None
|
|
534
|
+
if response.status_code == 400:
|
|
535
|
+
raise DeleteOrderApiError(
|
|
536
|
+
response.status_code,
|
|
537
|
+
self._error(types.DeleteOrder400Error, 400, None),
|
|
538
|
+
)
|
|
539
|
+
if response.status_code == 404:
|
|
540
|
+
raise DeleteOrderApiError(
|
|
541
|
+
response.status_code,
|
|
542
|
+
self._error(types.DeleteOrder404Error, 404, None),
|
|
543
|
+
)
|
|
544
|
+
raise DeleteOrderApiError(
|
|
545
|
+
response.status_code,
|
|
546
|
+
self._error(types.DeleteOrderDefaultError, response.status_code, None),
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
async def _delete_pet(
|
|
550
|
+
self,
|
|
551
|
+
*,
|
|
552
|
+
pet_id: int,
|
|
553
|
+
api_key: str | None = None,
|
|
554
|
+
) -> None:
|
|
555
|
+
"""Delete a pet."""
|
|
556
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
557
|
+
header_params: dict[str, Any] = {"api_key": api_key}
|
|
558
|
+
header_formats: dict[str, str] | None = {"api_key": "csv"}
|
|
559
|
+
request_kwargs: dict[str, Any] = {}
|
|
560
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
561
|
+
response = await self._client.request(
|
|
562
|
+
"DELETE",
|
|
563
|
+
_request_url,
|
|
564
|
+
headers=self._headers(header_params, collection_formats=header_formats),
|
|
565
|
+
**request_kwargs,
|
|
566
|
+
)
|
|
567
|
+
if response.status_code == 200:
|
|
568
|
+
return None
|
|
569
|
+
if response.status_code == 400:
|
|
570
|
+
raise DeletePetApiError(
|
|
571
|
+
response.status_code,
|
|
572
|
+
self._error(types.DeletePet400Error, 400, None),
|
|
573
|
+
)
|
|
574
|
+
raise DeletePetApiError(
|
|
575
|
+
response.status_code,
|
|
576
|
+
self._error(types.DeletePetDefaultError, response.status_code, None),
|
|
577
|
+
)
|
|
578
|
+
|
|
579
|
+
async def _delete_user(
|
|
580
|
+
self,
|
|
581
|
+
*,
|
|
582
|
+
username: str,
|
|
583
|
+
) -> None:
|
|
584
|
+
"""This can only be done by the logged in user."""
|
|
585
|
+
path_params: dict[str, Any] = {"username": username}
|
|
586
|
+
request_kwargs: dict[str, Any] = {}
|
|
587
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
588
|
+
response = await self._client.request(
|
|
589
|
+
"DELETE",
|
|
590
|
+
_request_url,
|
|
591
|
+
headers=self._headers(),
|
|
592
|
+
**request_kwargs,
|
|
593
|
+
)
|
|
594
|
+
if response.status_code == 200:
|
|
595
|
+
return None
|
|
596
|
+
if response.status_code == 400:
|
|
597
|
+
raise DeleteUserApiError(
|
|
598
|
+
response.status_code,
|
|
599
|
+
self._error(types.DeleteUser400Error, 400, None),
|
|
600
|
+
)
|
|
601
|
+
if response.status_code == 404:
|
|
602
|
+
raise DeleteUserApiError(
|
|
603
|
+
response.status_code,
|
|
604
|
+
self._error(types.DeleteUser404Error, 404, None),
|
|
605
|
+
)
|
|
606
|
+
raise DeleteUserApiError(
|
|
607
|
+
response.status_code,
|
|
608
|
+
self._error(types.DeleteUserDefaultError, response.status_code, None),
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
async def _find_pets_by_status(
|
|
612
|
+
self,
|
|
613
|
+
*,
|
|
614
|
+
status: Literal["available", "pending", "sold"] | None = None,
|
|
615
|
+
) -> list[types.Pet]:
|
|
616
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
617
|
+
query_params: dict[str, Any] = {"status": status}
|
|
618
|
+
query_formats: dict[str, str] | None = {"status": "multi"}
|
|
619
|
+
request_kwargs: dict[str, Any] = {}
|
|
620
|
+
_request_url = self._url("/pet/findByStatus", {})
|
|
621
|
+
response = await self._client.request(
|
|
622
|
+
"GET",
|
|
623
|
+
_request_url,
|
|
624
|
+
params=self._query(query_params, query_formats),
|
|
625
|
+
headers=self._headers(),
|
|
626
|
+
**request_kwargs,
|
|
627
|
+
)
|
|
628
|
+
if response.status_code == 200:
|
|
629
|
+
return TypeAdapter(list[types.Pet]).validate_python(
|
|
630
|
+
self._json_body(response)
|
|
631
|
+
)
|
|
632
|
+
if response.status_code == 400:
|
|
633
|
+
raise FindPetsByStatusApiError(
|
|
634
|
+
response.status_code,
|
|
635
|
+
self._error(types.FindPetsByStatus400Error, 400, None),
|
|
636
|
+
)
|
|
637
|
+
raise FindPetsByStatusApiError(
|
|
638
|
+
response.status_code,
|
|
639
|
+
self._error(types.FindPetsByStatusDefaultError, response.status_code, None),
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
async def _find_pets_by_tags(
|
|
643
|
+
self,
|
|
644
|
+
*,
|
|
645
|
+
tags: list[str] | None = None,
|
|
646
|
+
) -> list[types.Pet]:
|
|
647
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
648
|
+
query_params: dict[str, Any] = {"tags": tags}
|
|
649
|
+
query_formats: dict[str, str] | None = {"tags": "multi"}
|
|
650
|
+
request_kwargs: dict[str, Any] = {}
|
|
651
|
+
_request_url = self._url("/pet/findByTags", {})
|
|
652
|
+
response = await self._client.request(
|
|
653
|
+
"GET",
|
|
654
|
+
_request_url,
|
|
655
|
+
params=self._query(query_params, query_formats),
|
|
656
|
+
headers=self._headers(),
|
|
657
|
+
**request_kwargs,
|
|
658
|
+
)
|
|
659
|
+
if response.status_code == 200:
|
|
660
|
+
return TypeAdapter(list[types.Pet]).validate_python(
|
|
661
|
+
self._json_body(response)
|
|
662
|
+
)
|
|
663
|
+
if response.status_code == 400:
|
|
664
|
+
raise FindPetsByTagsApiError(
|
|
665
|
+
response.status_code,
|
|
666
|
+
self._error(types.FindPetsByTags400Error, 400, None),
|
|
667
|
+
)
|
|
668
|
+
raise FindPetsByTagsApiError(
|
|
669
|
+
response.status_code,
|
|
670
|
+
self._error(types.FindPetsByTagsDefaultError, response.status_code, None),
|
|
671
|
+
)
|
|
672
|
+
|
|
673
|
+
async def _get_inventory(
|
|
674
|
+
self,
|
|
675
|
+
) -> types.GetInventory200Response:
|
|
676
|
+
"""Returns a map of status codes to quantities."""
|
|
677
|
+
request_kwargs: dict[str, Any] = {}
|
|
678
|
+
_request_url = self._url("/store/inventory", {})
|
|
679
|
+
response = await self._client.request(
|
|
680
|
+
"GET",
|
|
681
|
+
_request_url,
|
|
682
|
+
headers=self._headers(),
|
|
683
|
+
**request_kwargs,
|
|
684
|
+
)
|
|
685
|
+
if response.status_code == 200:
|
|
686
|
+
return TypeAdapter(types.GetInventory200Response).validate_python(
|
|
687
|
+
response.json()
|
|
688
|
+
)
|
|
689
|
+
raise GetInventoryApiError(
|
|
690
|
+
response.status_code,
|
|
691
|
+
self._error(types.GetInventoryDefaultError, response.status_code, None),
|
|
692
|
+
)
|
|
693
|
+
|
|
694
|
+
async def _get_order_by_id(
|
|
695
|
+
self,
|
|
696
|
+
*,
|
|
697
|
+
order_id: int,
|
|
698
|
+
) -> types.Order:
|
|
699
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
700
|
+
path_params: dict[str, Any] = {"orderId": order_id}
|
|
701
|
+
request_kwargs: dict[str, Any] = {}
|
|
702
|
+
_request_url = self._url("/store/order/{orderId}", path_params)
|
|
703
|
+
response = await self._client.request(
|
|
704
|
+
"GET",
|
|
705
|
+
_request_url,
|
|
706
|
+
headers=self._headers(),
|
|
707
|
+
**request_kwargs,
|
|
708
|
+
)
|
|
709
|
+
if response.status_code == 200:
|
|
710
|
+
return types.Order.model_validate(self._json_body(response))
|
|
711
|
+
if response.status_code == 400:
|
|
712
|
+
raise GetOrderByIdApiError(
|
|
713
|
+
response.status_code,
|
|
714
|
+
self._error(types.GetOrderById400Error, 400, None),
|
|
715
|
+
)
|
|
716
|
+
if response.status_code == 404:
|
|
717
|
+
raise GetOrderByIdApiError(
|
|
718
|
+
response.status_code,
|
|
719
|
+
self._error(types.GetOrderById404Error, 404, None),
|
|
720
|
+
)
|
|
721
|
+
raise GetOrderByIdApiError(
|
|
722
|
+
response.status_code,
|
|
723
|
+
self._error(types.GetOrderByIdDefaultError, response.status_code, None),
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
async def _get_pet_by_id(
|
|
727
|
+
self,
|
|
728
|
+
*,
|
|
729
|
+
pet_id: int,
|
|
730
|
+
) -> types.Pet:
|
|
731
|
+
"""Returns a single pet."""
|
|
732
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
733
|
+
request_kwargs: dict[str, Any] = {}
|
|
734
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
735
|
+
response = await self._client.request(
|
|
736
|
+
"GET",
|
|
737
|
+
_request_url,
|
|
738
|
+
headers=self._headers(),
|
|
739
|
+
**request_kwargs,
|
|
740
|
+
)
|
|
741
|
+
if response.status_code == 200:
|
|
742
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
743
|
+
if response.status_code == 400:
|
|
744
|
+
raise GetPetByIdApiError(
|
|
745
|
+
response.status_code,
|
|
746
|
+
self._error(types.GetPetById400Error, 400, None),
|
|
747
|
+
)
|
|
748
|
+
if response.status_code == 404:
|
|
749
|
+
raise GetPetByIdApiError(
|
|
750
|
+
response.status_code,
|
|
751
|
+
self._error(types.GetPetById404Error, 404, None),
|
|
752
|
+
)
|
|
753
|
+
raise GetPetByIdApiError(
|
|
754
|
+
response.status_code,
|
|
755
|
+
self._error(types.GetPetByIdDefaultError, response.status_code, None),
|
|
756
|
+
)
|
|
757
|
+
|
|
758
|
+
async def _get_user_by_name(
|
|
759
|
+
self,
|
|
760
|
+
*,
|
|
761
|
+
username: str,
|
|
762
|
+
) -> types.User:
|
|
763
|
+
"""Get user detail based on username."""
|
|
764
|
+
path_params: dict[str, Any] = {"username": username}
|
|
765
|
+
request_kwargs: dict[str, Any] = {}
|
|
766
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
767
|
+
response = await self._client.request(
|
|
768
|
+
"GET",
|
|
769
|
+
_request_url,
|
|
770
|
+
headers=self._headers(),
|
|
771
|
+
**request_kwargs,
|
|
772
|
+
)
|
|
773
|
+
if response.status_code == 200:
|
|
774
|
+
return types.User.model_validate(self._json_body(response))
|
|
775
|
+
if response.status_code == 400:
|
|
776
|
+
raise GetUserByNameApiError(
|
|
777
|
+
response.status_code,
|
|
778
|
+
self._error(types.GetUserByName400Error, 400, None),
|
|
779
|
+
)
|
|
780
|
+
if response.status_code == 404:
|
|
781
|
+
raise GetUserByNameApiError(
|
|
782
|
+
response.status_code,
|
|
783
|
+
self._error(types.GetUserByName404Error, 404, None),
|
|
784
|
+
)
|
|
785
|
+
raise GetUserByNameApiError(
|
|
786
|
+
response.status_code,
|
|
787
|
+
self._error(types.GetUserByNameDefaultError, response.status_code, None),
|
|
788
|
+
)
|
|
789
|
+
|
|
790
|
+
async def _login_user(
|
|
791
|
+
self,
|
|
792
|
+
*,
|
|
793
|
+
username: str | None = None,
|
|
794
|
+
password: str | None = None,
|
|
795
|
+
) -> str:
|
|
796
|
+
"""Log into the system."""
|
|
797
|
+
query_params: dict[str, Any] = {"username": username, "password": password}
|
|
798
|
+
query_formats: dict[str, str] | None = {
|
|
799
|
+
"username": "multi",
|
|
800
|
+
"password": "multi",
|
|
801
|
+
}
|
|
802
|
+
request_kwargs: dict[str, Any] = {}
|
|
803
|
+
_request_url = self._url("/user/login", {})
|
|
804
|
+
response = await self._client.request(
|
|
805
|
+
"GET",
|
|
806
|
+
_request_url,
|
|
807
|
+
params=self._query(query_params, query_formats),
|
|
808
|
+
headers=self._headers(),
|
|
809
|
+
**request_kwargs,
|
|
810
|
+
)
|
|
811
|
+
if response.status_code == 200:
|
|
812
|
+
return self._json_body(response)
|
|
813
|
+
if response.status_code == 400:
|
|
814
|
+
raise LoginUserApiError(
|
|
815
|
+
response.status_code,
|
|
816
|
+
self._error(types.LoginUser400Error, 400, None),
|
|
817
|
+
)
|
|
818
|
+
raise LoginUserApiError(
|
|
819
|
+
response.status_code,
|
|
820
|
+
self._error(types.LoginUserDefaultError, response.status_code, None),
|
|
821
|
+
)
|
|
822
|
+
|
|
823
|
+
async def _logout_user(
|
|
824
|
+
self,
|
|
825
|
+
) -> None:
|
|
826
|
+
"""Log user out of the system."""
|
|
827
|
+
request_kwargs: dict[str, Any] = {}
|
|
828
|
+
_request_url = self._url("/user/logout", {})
|
|
829
|
+
response = await self._client.request(
|
|
830
|
+
"GET",
|
|
831
|
+
_request_url,
|
|
832
|
+
headers=self._headers(),
|
|
833
|
+
**request_kwargs,
|
|
834
|
+
)
|
|
835
|
+
if response.status_code == 200:
|
|
836
|
+
return None
|
|
837
|
+
raise LogoutUserApiError(
|
|
838
|
+
response.status_code,
|
|
839
|
+
self._error(types.LogoutUserDefaultError, response.status_code, None),
|
|
840
|
+
)
|
|
841
|
+
|
|
842
|
+
async def _place_order(
|
|
843
|
+
self,
|
|
844
|
+
*,
|
|
845
|
+
id: int | None = None,
|
|
846
|
+
pet_id: int | None = None,
|
|
847
|
+
quantity: int | None = None,
|
|
848
|
+
ship_date: datetime.datetime | None = None,
|
|
849
|
+
status: types.OrderStatus | None = None,
|
|
850
|
+
complete: bool | None = None,
|
|
851
|
+
) -> types.Order:
|
|
852
|
+
"""Place a new order in the store."""
|
|
853
|
+
header_params: dict[str, Any] = {}
|
|
854
|
+
_body_fields: dict[str, Any] = {}
|
|
855
|
+
if id is not None:
|
|
856
|
+
_body_fields["id"] = id
|
|
857
|
+
if pet_id is not None:
|
|
858
|
+
_body_fields["petId"] = pet_id
|
|
859
|
+
if quantity is not None:
|
|
860
|
+
_body_fields["quantity"] = quantity
|
|
861
|
+
if ship_date is not None:
|
|
862
|
+
_body_fields["shipDate"] = ship_date
|
|
863
|
+
if status is not None:
|
|
864
|
+
_body_fields["status"] = status
|
|
865
|
+
if complete is not None:
|
|
866
|
+
_body_fields["complete"] = complete
|
|
867
|
+
body = types.Order.model_validate(_body_fields).model_dump(
|
|
868
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
869
|
+
)
|
|
870
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
871
|
+
if not self._config.omit_content_type_header:
|
|
872
|
+
self._default_content_type(header_params, "application/json")
|
|
873
|
+
_request_url = self._url("/store/order", {})
|
|
874
|
+
response = await self._client.request(
|
|
875
|
+
"POST",
|
|
876
|
+
_request_url,
|
|
877
|
+
headers=self._headers(header_params),
|
|
878
|
+
**request_kwargs,
|
|
879
|
+
)
|
|
880
|
+
if response.status_code == 200:
|
|
881
|
+
return types.Order.model_validate(response.json())
|
|
882
|
+
if response.status_code == 400:
|
|
883
|
+
raise PlaceOrderApiError(
|
|
884
|
+
response.status_code,
|
|
885
|
+
self._error(types.PlaceOrder400Error, 400, None),
|
|
886
|
+
)
|
|
887
|
+
if response.status_code == 422:
|
|
888
|
+
raise PlaceOrderApiError(
|
|
889
|
+
response.status_code,
|
|
890
|
+
self._error(types.PlaceOrder422Error, 422, None),
|
|
891
|
+
)
|
|
892
|
+
raise PlaceOrderApiError(
|
|
893
|
+
response.status_code,
|
|
894
|
+
self._error(types.PlaceOrderDefaultError, response.status_code, None),
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
async def _update_pet(
|
|
898
|
+
self,
|
|
899
|
+
*,
|
|
900
|
+
name: str,
|
|
901
|
+
photo_urls: list[str],
|
|
902
|
+
id: int | None = None,
|
|
903
|
+
category: types.Category | None = None,
|
|
904
|
+
tags: list[types.Tag] | None = None,
|
|
905
|
+
status: types.PetStatus | None = None,
|
|
906
|
+
) -> types.Pet:
|
|
907
|
+
"""Update an existing pet by Id."""
|
|
908
|
+
header_params: dict[str, Any] = {}
|
|
909
|
+
_body_fields: dict[str, Any] = {}
|
|
910
|
+
_body_fields["name"] = name
|
|
911
|
+
_body_fields["photoUrls"] = photo_urls
|
|
912
|
+
if id is not None:
|
|
913
|
+
_body_fields["id"] = id
|
|
914
|
+
if category is not None:
|
|
915
|
+
_body_fields["category"] = category
|
|
916
|
+
if tags is not None:
|
|
917
|
+
_body_fields["tags"] = tags
|
|
918
|
+
if status is not None:
|
|
919
|
+
_body_fields["status"] = status
|
|
920
|
+
body = types.Pet.model_validate(_body_fields).model_dump(
|
|
921
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
922
|
+
)
|
|
923
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
924
|
+
if not self._config.omit_content_type_header:
|
|
925
|
+
self._default_content_type(header_params, "application/json")
|
|
926
|
+
_request_url = self._url("/pet", {})
|
|
927
|
+
response = await self._client.request(
|
|
928
|
+
"PUT",
|
|
929
|
+
_request_url,
|
|
930
|
+
headers=self._headers(header_params),
|
|
931
|
+
**request_kwargs,
|
|
932
|
+
)
|
|
933
|
+
if response.status_code == 200:
|
|
934
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
935
|
+
if response.status_code == 400:
|
|
936
|
+
raise UpdatePetApiError(
|
|
937
|
+
response.status_code,
|
|
938
|
+
self._error(types.UpdatePet400Error, 400, None),
|
|
939
|
+
)
|
|
940
|
+
if response.status_code == 404:
|
|
941
|
+
raise UpdatePetApiError(
|
|
942
|
+
response.status_code,
|
|
943
|
+
self._error(types.UpdatePet404Error, 404, None),
|
|
944
|
+
)
|
|
945
|
+
if response.status_code == 422:
|
|
946
|
+
raise UpdatePetApiError(
|
|
947
|
+
response.status_code,
|
|
948
|
+
self._error(types.UpdatePet422Error, 422, None),
|
|
949
|
+
)
|
|
950
|
+
raise UpdatePetApiError(
|
|
951
|
+
response.status_code,
|
|
952
|
+
self._error(types.UpdatePetDefaultError, response.status_code, None),
|
|
953
|
+
)
|
|
954
|
+
|
|
955
|
+
async def _update_pet_with_form(
|
|
956
|
+
self,
|
|
957
|
+
*,
|
|
958
|
+
pet_id: int,
|
|
959
|
+
name: str | None = None,
|
|
960
|
+
status: str | None = None,
|
|
961
|
+
) -> types.Pet:
|
|
962
|
+
"""Updates a pet resource based on the form data."""
|
|
963
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
964
|
+
query_params: dict[str, Any] = {"name": name, "status": status}
|
|
965
|
+
query_formats: dict[str, str] | None = {"name": "multi", "status": "multi"}
|
|
966
|
+
request_kwargs: dict[str, Any] = {}
|
|
967
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
968
|
+
response = await self._client.request(
|
|
969
|
+
"POST",
|
|
970
|
+
_request_url,
|
|
971
|
+
params=self._query(query_params, query_formats),
|
|
972
|
+
headers=self._headers(),
|
|
973
|
+
**request_kwargs,
|
|
974
|
+
)
|
|
975
|
+
if response.status_code == 200:
|
|
976
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
977
|
+
if response.status_code == 400:
|
|
978
|
+
raise UpdatePetWithFormApiError(
|
|
979
|
+
response.status_code,
|
|
980
|
+
self._error(types.UpdatePetWithForm400Error, 400, None),
|
|
981
|
+
)
|
|
982
|
+
raise UpdatePetWithFormApiError(
|
|
983
|
+
response.status_code,
|
|
984
|
+
self._error(
|
|
985
|
+
types.UpdatePetWithFormDefaultError, response.status_code, None
|
|
986
|
+
),
|
|
987
|
+
)
|
|
988
|
+
|
|
989
|
+
async def _update_user(
|
|
990
|
+
self,
|
|
991
|
+
*,
|
|
992
|
+
username: str,
|
|
993
|
+
body: types.User | None = None,
|
|
994
|
+
) -> None:
|
|
995
|
+
"""This can only be done by the logged in user."""
|
|
996
|
+
path_params: dict[str, Any] = {"username": username}
|
|
997
|
+
header_params: dict[str, Any] = {}
|
|
998
|
+
body = self._dump(body)
|
|
999
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
1000
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
1001
|
+
self._default_content_type(header_params, "application/json")
|
|
1002
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
1003
|
+
response = await self._client.request(
|
|
1004
|
+
"PUT",
|
|
1005
|
+
_request_url,
|
|
1006
|
+
headers=self._headers(header_params),
|
|
1007
|
+
**request_kwargs,
|
|
1008
|
+
)
|
|
1009
|
+
if response.status_code == 200:
|
|
1010
|
+
return None
|
|
1011
|
+
if response.status_code == 400:
|
|
1012
|
+
raise UpdateUserApiError(
|
|
1013
|
+
response.status_code,
|
|
1014
|
+
self._error(types.UpdateUser400Error, 400, None),
|
|
1015
|
+
)
|
|
1016
|
+
if response.status_code == 404:
|
|
1017
|
+
raise UpdateUserApiError(
|
|
1018
|
+
response.status_code,
|
|
1019
|
+
self._error(types.UpdateUser404Error, 404, None),
|
|
1020
|
+
)
|
|
1021
|
+
raise UpdateUserApiError(
|
|
1022
|
+
response.status_code,
|
|
1023
|
+
self._error(types.UpdateUserDefaultError, response.status_code, None),
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
async def _upload_file(
|
|
1027
|
+
self,
|
|
1028
|
+
*,
|
|
1029
|
+
pet_id: int,
|
|
1030
|
+
additional_metadata: str | None = None,
|
|
1031
|
+
body: bytes | None = None,
|
|
1032
|
+
) -> types.ApiResponse:
|
|
1033
|
+
"""Upload image of the pet."""
|
|
1034
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
1035
|
+
query_params: dict[str, Any] = {"additionalMetadata": additional_metadata}
|
|
1036
|
+
header_params: dict[str, Any] = {}
|
|
1037
|
+
query_formats: dict[str, str] | None = {"additionalMetadata": "multi"}
|
|
1038
|
+
body = body
|
|
1039
|
+
request_kwargs: dict[str, Any] = {"content": body}
|
|
1040
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
1041
|
+
self._default_content_type(header_params, "application/octet-stream")
|
|
1042
|
+
_request_url = self._url("/pet/{petId}/uploadImage", path_params)
|
|
1043
|
+
response = await self._client.request(
|
|
1044
|
+
"POST",
|
|
1045
|
+
_request_url,
|
|
1046
|
+
params=self._query(query_params, query_formats),
|
|
1047
|
+
headers=self._headers(header_params),
|
|
1048
|
+
**request_kwargs,
|
|
1049
|
+
)
|
|
1050
|
+
if response.status_code == 200:
|
|
1051
|
+
return types.ApiResponse.model_validate(response.json())
|
|
1052
|
+
if response.status_code == 400:
|
|
1053
|
+
raise UploadFileApiError(
|
|
1054
|
+
response.status_code,
|
|
1055
|
+
self._error(types.UploadFile400Error, 400, None),
|
|
1056
|
+
)
|
|
1057
|
+
if response.status_code == 404:
|
|
1058
|
+
raise UploadFileApiError(
|
|
1059
|
+
response.status_code,
|
|
1060
|
+
self._error(types.UploadFile404Error, 404, None),
|
|
1061
|
+
)
|
|
1062
|
+
raise UploadFileApiError(
|
|
1063
|
+
response.status_code,
|
|
1064
|
+
self._error(types.UploadFileDefaultError, response.status_code, None),
|
|
1065
|
+
)
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
class _AsyncPetNamespace:
|
|
1069
|
+
"""\`pet\` operations."""
|
|
1070
|
+
|
|
1071
|
+
def __init__(self, parent: AsyncSwaggerPetstoreOpenAPI30) -> None:
|
|
1072
|
+
self._parent = parent
|
|
1073
|
+
|
|
1074
|
+
async def add_pet(
|
|
1075
|
+
self,
|
|
1076
|
+
*,
|
|
1077
|
+
name: str,
|
|
1078
|
+
photo_urls: list[str],
|
|
1079
|
+
id: int | None = None,
|
|
1080
|
+
category: types.Category | None = None,
|
|
1081
|
+
tags: list[types.Tag] | None = None,
|
|
1082
|
+
status: types.PetStatus | None = None,
|
|
1083
|
+
) -> types.Pet:
|
|
1084
|
+
"""Add a new pet to the store."""
|
|
1085
|
+
return await self._parent._add_pet(
|
|
1086
|
+
name=name,
|
|
1087
|
+
photo_urls=photo_urls,
|
|
1088
|
+
id=id,
|
|
1089
|
+
category=category,
|
|
1090
|
+
tags=tags,
|
|
1091
|
+
status=status,
|
|
1092
|
+
)
|
|
1093
|
+
|
|
1094
|
+
async def delete_pet(
|
|
1095
|
+
self,
|
|
1096
|
+
*,
|
|
1097
|
+
pet_id: int,
|
|
1098
|
+
api_key: str | None = None,
|
|
1099
|
+
) -> None:
|
|
1100
|
+
"""Delete a pet."""
|
|
1101
|
+
return await self._parent._delete_pet(
|
|
1102
|
+
pet_id=pet_id,
|
|
1103
|
+
api_key=api_key,
|
|
1104
|
+
)
|
|
1105
|
+
|
|
1106
|
+
async def find_pets_by_status(
|
|
1107
|
+
self,
|
|
1108
|
+
*,
|
|
1109
|
+
status: Literal["available", "pending", "sold"] | None = None,
|
|
1110
|
+
) -> list[types.Pet]:
|
|
1111
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
1112
|
+
return await self._parent._find_pets_by_status(
|
|
1113
|
+
status=status,
|
|
1114
|
+
)
|
|
1115
|
+
|
|
1116
|
+
async def find_pets_by_tags(
|
|
1117
|
+
self,
|
|
1118
|
+
*,
|
|
1119
|
+
tags: list[str] | None = None,
|
|
1120
|
+
) -> list[types.Pet]:
|
|
1121
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
1122
|
+
return await self._parent._find_pets_by_tags(
|
|
1123
|
+
tags=tags,
|
|
1124
|
+
)
|
|
1125
|
+
|
|
1126
|
+
async def get_pet_by_id(
|
|
1127
|
+
self,
|
|
1128
|
+
*,
|
|
1129
|
+
pet_id: int,
|
|
1130
|
+
) -> types.Pet:
|
|
1131
|
+
"""Returns a single pet."""
|
|
1132
|
+
return await self._parent._get_pet_by_id(
|
|
1133
|
+
pet_id=pet_id,
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
async def update_pet(
|
|
1137
|
+
self,
|
|
1138
|
+
*,
|
|
1139
|
+
name: str,
|
|
1140
|
+
photo_urls: list[str],
|
|
1141
|
+
id: int | None = None,
|
|
1142
|
+
category: types.Category | None = None,
|
|
1143
|
+
tags: list[types.Tag] | None = None,
|
|
1144
|
+
status: types.PetStatus | None = None,
|
|
1145
|
+
) -> types.Pet:
|
|
1146
|
+
"""Update an existing pet by Id."""
|
|
1147
|
+
return await self._parent._update_pet(
|
|
1148
|
+
name=name,
|
|
1149
|
+
photo_urls=photo_urls,
|
|
1150
|
+
id=id,
|
|
1151
|
+
category=category,
|
|
1152
|
+
tags=tags,
|
|
1153
|
+
status=status,
|
|
1154
|
+
)
|
|
1155
|
+
|
|
1156
|
+
async def update_pet_with_form(
|
|
1157
|
+
self,
|
|
1158
|
+
*,
|
|
1159
|
+
pet_id: int,
|
|
1160
|
+
name: str | None = None,
|
|
1161
|
+
status: str | None = None,
|
|
1162
|
+
) -> types.Pet:
|
|
1163
|
+
"""Updates a pet resource based on the form data."""
|
|
1164
|
+
return await self._parent._update_pet_with_form(
|
|
1165
|
+
pet_id=pet_id,
|
|
1166
|
+
name=name,
|
|
1167
|
+
status=status,
|
|
1168
|
+
)
|
|
1169
|
+
|
|
1170
|
+
async def upload_file(
|
|
1171
|
+
self,
|
|
1172
|
+
*,
|
|
1173
|
+
pet_id: int,
|
|
1174
|
+
additional_metadata: str | None = None,
|
|
1175
|
+
body: bytes | None = None,
|
|
1176
|
+
) -> types.ApiResponse:
|
|
1177
|
+
"""Upload image of the pet."""
|
|
1178
|
+
return await self._parent._upload_file(
|
|
1179
|
+
pet_id=pet_id,
|
|
1180
|
+
additional_metadata=additional_metadata,
|
|
1181
|
+
body=body,
|
|
1182
|
+
)
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
class _AsyncUserNamespace:
|
|
1186
|
+
"""\`user\` operations."""
|
|
1187
|
+
|
|
1188
|
+
def __init__(self, parent: AsyncSwaggerPetstoreOpenAPI30) -> None:
|
|
1189
|
+
self._parent = parent
|
|
1190
|
+
|
|
1191
|
+
async def create_user(
|
|
1192
|
+
self,
|
|
1193
|
+
*,
|
|
1194
|
+
id: int | None = None,
|
|
1195
|
+
username: str | None = None,
|
|
1196
|
+
first_name: str | None = None,
|
|
1197
|
+
last_name: str | None = None,
|
|
1198
|
+
email: str | None = None,
|
|
1199
|
+
password: str | None = None,
|
|
1200
|
+
phone: str | None = None,
|
|
1201
|
+
user_status: int | None = None,
|
|
1202
|
+
) -> types.User:
|
|
1203
|
+
"""This can only be done by the logged in user."""
|
|
1204
|
+
return await self._parent._create_user(
|
|
1205
|
+
id=id,
|
|
1206
|
+
username=username,
|
|
1207
|
+
first_name=first_name,
|
|
1208
|
+
last_name=last_name,
|
|
1209
|
+
email=email,
|
|
1210
|
+
password=password,
|
|
1211
|
+
phone=phone,
|
|
1212
|
+
user_status=user_status,
|
|
1213
|
+
)
|
|
1214
|
+
|
|
1215
|
+
async def create_users_with_list_input(
|
|
1216
|
+
self,
|
|
1217
|
+
body: list[types.User] | None = None,
|
|
1218
|
+
) -> types.User:
|
|
1219
|
+
"""Creates list of users with given input array."""
|
|
1220
|
+
return await self._parent._create_users_with_list_input(
|
|
1221
|
+
body,
|
|
1222
|
+
)
|
|
1223
|
+
|
|
1224
|
+
async def delete_user(
|
|
1225
|
+
self,
|
|
1226
|
+
*,
|
|
1227
|
+
username: str,
|
|
1228
|
+
) -> None:
|
|
1229
|
+
"""This can only be done by the logged in user."""
|
|
1230
|
+
return await self._parent._delete_user(
|
|
1231
|
+
username=username,
|
|
1232
|
+
)
|
|
1233
|
+
|
|
1234
|
+
async def get_user_by_name(
|
|
1235
|
+
self,
|
|
1236
|
+
*,
|
|
1237
|
+
username: str,
|
|
1238
|
+
) -> types.User:
|
|
1239
|
+
"""Get user detail based on username."""
|
|
1240
|
+
return await self._parent._get_user_by_name(
|
|
1241
|
+
username=username,
|
|
1242
|
+
)
|
|
1243
|
+
|
|
1244
|
+
async def login_user(
|
|
1245
|
+
self,
|
|
1246
|
+
*,
|
|
1247
|
+
username: str | None = None,
|
|
1248
|
+
password: str | None = None,
|
|
1249
|
+
) -> str:
|
|
1250
|
+
"""Log into the system."""
|
|
1251
|
+
return await self._parent._login_user(
|
|
1252
|
+
username=username,
|
|
1253
|
+
password=password,
|
|
1254
|
+
)
|
|
1255
|
+
|
|
1256
|
+
async def logout_user(
|
|
1257
|
+
self,
|
|
1258
|
+
) -> None:
|
|
1259
|
+
"""Log user out of the system."""
|
|
1260
|
+
return await self._parent._logout_user()
|
|
1261
|
+
|
|
1262
|
+
async def update_user(
|
|
1263
|
+
self,
|
|
1264
|
+
*,
|
|
1265
|
+
username: str,
|
|
1266
|
+
body: types.User | None = None,
|
|
1267
|
+
) -> None:
|
|
1268
|
+
"""This can only be done by the logged in user."""
|
|
1269
|
+
return await self._parent._update_user(
|
|
1270
|
+
username=username,
|
|
1271
|
+
body=body,
|
|
1272
|
+
)
|
|
1273
|
+
|
|
1274
|
+
|
|
1275
|
+
class _AsyncStoreNamespace:
|
|
1276
|
+
"""\`store\` operations."""
|
|
1277
|
+
|
|
1278
|
+
def __init__(self, parent: AsyncSwaggerPetstoreOpenAPI30) -> None:
|
|
1279
|
+
self._parent = parent
|
|
1280
|
+
|
|
1281
|
+
async def delete_order(
|
|
1282
|
+
self,
|
|
1283
|
+
*,
|
|
1284
|
+
order_id: int,
|
|
1285
|
+
) -> None:
|
|
1286
|
+
"""
|
|
1287
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API
|
|
1288
|
+
errors.
|
|
1289
|
+
"""
|
|
1290
|
+
return await self._parent._delete_order(
|
|
1291
|
+
order_id=order_id,
|
|
1292
|
+
)
|
|
1293
|
+
|
|
1294
|
+
async def get_inventory(
|
|
1295
|
+
self,
|
|
1296
|
+
) -> types.GetInventory200Response:
|
|
1297
|
+
"""Returns a map of status codes to quantities."""
|
|
1298
|
+
return await self._parent._get_inventory()
|
|
1299
|
+
|
|
1300
|
+
async def get_order_by_id(
|
|
1301
|
+
self,
|
|
1302
|
+
*,
|
|
1303
|
+
order_id: int,
|
|
1304
|
+
) -> types.Order:
|
|
1305
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
1306
|
+
return await self._parent._get_order_by_id(
|
|
1307
|
+
order_id=order_id,
|
|
1308
|
+
)
|
|
1309
|
+
|
|
1310
|
+
async def place_order(
|
|
1311
|
+
self,
|
|
1312
|
+
*,
|
|
1313
|
+
id: int | None = None,
|
|
1314
|
+
pet_id: int | None = None,
|
|
1315
|
+
quantity: int | None = None,
|
|
1316
|
+
ship_date: datetime.datetime | None = None,
|
|
1317
|
+
status: types.OrderStatus | None = None,
|
|
1318
|
+
complete: bool | None = None,
|
|
1319
|
+
) -> types.Order:
|
|
1320
|
+
"""Place a new order in the store."""
|
|
1321
|
+
return await self._parent._place_order(
|
|
1322
|
+
id=id,
|
|
1323
|
+
pet_id=pet_id,
|
|
1324
|
+
quantity=quantity,
|
|
1325
|
+
ship_date=ship_date,
|
|
1326
|
+
status=status,
|
|
1327
|
+
complete=complete,
|
|
1328
|
+
)
|
|
1329
|
+
"
|
|
1330
|
+
`;
|
|
1331
|
+
|
|
1332
|
+
exports[`openApiPyClientGenerator - petstore > should generate valid Python for the full petstore example > client.py 1`] = `
|
|
1333
|
+
""""SwaggerPetstoreOpenAPI30 — AUTO-GENERATED synchronous client."""
|
|
1334
|
+
|
|
1335
|
+
from __future__ import annotations
|
|
1336
|
+
|
|
1337
|
+
import datetime
|
|
1338
|
+
from dataclasses import dataclass, field
|
|
1339
|
+
from typing import Any, Literal, TypeVar
|
|
1340
|
+
from urllib.parse import quote
|
|
1341
|
+
|
|
1342
|
+
import httpx
|
|
1343
|
+
from pydantic import BaseModel, TypeAdapter, ValidationError
|
|
1344
|
+
|
|
1345
|
+
from . import types
|
|
1346
|
+
from .errors import (
|
|
1347
|
+
AddPetApiError as AddPetApiError,
|
|
1348
|
+
)
|
|
1349
|
+
from .errors import (
|
|
1350
|
+
ApiError as ApiError,
|
|
1351
|
+
)
|
|
1352
|
+
from .errors import (
|
|
1353
|
+
CreateUserApiError as CreateUserApiError,
|
|
1354
|
+
)
|
|
1355
|
+
from .errors import (
|
|
1356
|
+
CreateUsersWithListInputApiError as CreateUsersWithListInputApiError,
|
|
1357
|
+
)
|
|
1358
|
+
from .errors import (
|
|
1359
|
+
DeleteOrderApiError as DeleteOrderApiError,
|
|
1360
|
+
)
|
|
1361
|
+
from .errors import (
|
|
1362
|
+
DeletePetApiError as DeletePetApiError,
|
|
1363
|
+
)
|
|
1364
|
+
from .errors import (
|
|
1365
|
+
DeleteUserApiError as DeleteUserApiError,
|
|
1366
|
+
)
|
|
1367
|
+
from .errors import (
|
|
1368
|
+
FindPetsByStatusApiError as FindPetsByStatusApiError,
|
|
1369
|
+
)
|
|
1370
|
+
from .errors import (
|
|
1371
|
+
FindPetsByTagsApiError as FindPetsByTagsApiError,
|
|
1372
|
+
)
|
|
1373
|
+
from .errors import (
|
|
1374
|
+
GetInventoryApiError as GetInventoryApiError,
|
|
1375
|
+
)
|
|
1376
|
+
from .errors import (
|
|
1377
|
+
GetOrderByIdApiError as GetOrderByIdApiError,
|
|
1378
|
+
)
|
|
1379
|
+
from .errors import (
|
|
1380
|
+
GetPetByIdApiError as GetPetByIdApiError,
|
|
1381
|
+
)
|
|
1382
|
+
from .errors import (
|
|
1383
|
+
GetUserByNameApiError as GetUserByNameApiError,
|
|
1384
|
+
)
|
|
1385
|
+
from .errors import (
|
|
1386
|
+
LoginUserApiError as LoginUserApiError,
|
|
1387
|
+
)
|
|
1388
|
+
from .errors import (
|
|
1389
|
+
LogoutUserApiError as LogoutUserApiError,
|
|
1390
|
+
)
|
|
1391
|
+
from .errors import (
|
|
1392
|
+
PlaceOrderApiError as PlaceOrderApiError,
|
|
1393
|
+
)
|
|
1394
|
+
from .errors import (
|
|
1395
|
+
UpdatePetApiError as UpdatePetApiError,
|
|
1396
|
+
)
|
|
1397
|
+
from .errors import (
|
|
1398
|
+
UpdatePetWithFormApiError as UpdatePetWithFormApiError,
|
|
1399
|
+
)
|
|
1400
|
+
from .errors import (
|
|
1401
|
+
UpdateUserApiError as UpdateUserApiError,
|
|
1402
|
+
)
|
|
1403
|
+
from .errors import (
|
|
1404
|
+
UploadFileApiError as UploadFileApiError,
|
|
1405
|
+
)
|
|
1406
|
+
|
|
1407
|
+
_ErrorT = TypeVar("_ErrorT", bound=BaseModel)
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
@dataclass
|
|
1411
|
+
class SwaggerPetstoreOpenAPI30Config:
|
|
1412
|
+
"""Client configuration for SwaggerPetstoreOpenAPI30."""
|
|
1413
|
+
|
|
1414
|
+
#: Base URL for the API.
|
|
1415
|
+
url: str
|
|
1416
|
+
#: Client used for every request. Supply your own to add authentication or
|
|
1417
|
+
#: any other middleware — an \`\`httpx.Auth\`\` (e.g. a SigV4 signer), an event
|
|
1418
|
+
#: hook, a custom transport, timeouts, retries or a proxy all apply, and the
|
|
1419
|
+
#: client's own headers and query params are sent alongside each operation's.
|
|
1420
|
+
#: A supplied client is never closed by this one, so it can be shared.
|
|
1421
|
+
httpx_client: httpx.Client | None = None
|
|
1422
|
+
#: Headers added to every request, where the operation sets none itself.
|
|
1423
|
+
headers: dict[str, str] = field(default_factory=dict)
|
|
1424
|
+
#: By default the client sends a Content-Type header set to the media type
|
|
1425
|
+
#: the OpenAPI specification declares for the request. Set this to omit it.
|
|
1426
|
+
omit_content_type_header: bool = False
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
class SwaggerPetstoreOpenAPI30:
|
|
1430
|
+
"""Synchronous API client for SwaggerPetstoreOpenAPI30."""
|
|
1431
|
+
|
|
1432
|
+
def __init__(self, config: SwaggerPetstoreOpenAPI30Config) -> None:
|
|
1433
|
+
self._config = config
|
|
1434
|
+
self._client = config.httpx_client or httpx.Client()
|
|
1435
|
+
self._owns_client = config.httpx_client is None
|
|
1436
|
+
self._base_url = config.url.rstrip("/")
|
|
1437
|
+
self.pet: _PetNamespace = _PetNamespace(self)
|
|
1438
|
+
self.user: _UserNamespace = _UserNamespace(self)
|
|
1439
|
+
self.store: _StoreNamespace = _StoreNamespace(self)
|
|
1440
|
+
|
|
1441
|
+
def __enter__(self) -> SwaggerPetstoreOpenAPI30:
|
|
1442
|
+
return self
|
|
1443
|
+
|
|
1444
|
+
def __exit__(self, *exc: Any) -> None:
|
|
1445
|
+
self.close()
|
|
1446
|
+
|
|
1447
|
+
def close(self) -> None:
|
|
1448
|
+
if self._owns_client:
|
|
1449
|
+
self._client.close()
|
|
1450
|
+
|
|
1451
|
+
def _url(
|
|
1452
|
+
self,
|
|
1453
|
+
path: str,
|
|
1454
|
+
path_params: dict[str, Any],
|
|
1455
|
+
path_styles: dict[str, tuple[str, bool]] | None = None,
|
|
1456
|
+
) -> str:
|
|
1457
|
+
for key, value in path_params.items():
|
|
1458
|
+
style, explode = (path_styles or {}).get(key, ("simple", False))
|
|
1459
|
+
# An object expands to its key,value members; a list to its items.
|
|
1460
|
+
# Each is encoded on its own so the separators between them stay
|
|
1461
|
+
# literal, as RFC 6570 requires.
|
|
1462
|
+
dumped = self._dump(value)
|
|
1463
|
+
if isinstance(dumped, dict):
|
|
1464
|
+
values = [
|
|
1465
|
+
part
|
|
1466
|
+
for k, v in dumped.items()
|
|
1467
|
+
if v is not None
|
|
1468
|
+
for part in (k, self._scalar(v))
|
|
1469
|
+
]
|
|
1470
|
+
elif isinstance(dumped, list):
|
|
1471
|
+
values = list(dumped)
|
|
1472
|
+
else:
|
|
1473
|
+
values = [value]
|
|
1474
|
+
if style == "matrix":
|
|
1475
|
+
# RFC 6570 path-style expansion: ;key=a,b (explode: ;key=a;key=b)
|
|
1476
|
+
if explode:
|
|
1477
|
+
rendered = "".join(
|
|
1478
|
+
";" + key + "=" + quote(self._scalar(v), safe="")
|
|
1479
|
+
for v in values
|
|
1480
|
+
)
|
|
1481
|
+
else:
|
|
1482
|
+
rendered = (
|
|
1483
|
+
";"
|
|
1484
|
+
+ key
|
|
1485
|
+
+ "="
|
|
1486
|
+
+ ",".join(quote(self._scalar(v), safe="") for v in values)
|
|
1487
|
+
)
|
|
1488
|
+
elif style == "label":
|
|
1489
|
+
# RFC 6570 label expansion: .a,b (explode: .a.b)
|
|
1490
|
+
rendered = "." + ("." if explode else ",").join(
|
|
1491
|
+
quote(self._scalar(v), safe="") for v in values
|
|
1492
|
+
)
|
|
1493
|
+
else:
|
|
1494
|
+
# RFC 6570 simple expansion: a list renders comma-separated.
|
|
1495
|
+
rendered = ",".join(quote(self._scalar(v), safe="") for v in values)
|
|
1496
|
+
path = path.replace("{" + key + "}", rendered)
|
|
1497
|
+
return self._base_url + path
|
|
1498
|
+
|
|
1499
|
+
def _deep_object(self, key: str, value: Any, out: dict[str, Any]) -> None:
|
|
1500
|
+
if isinstance(value, BaseModel):
|
|
1501
|
+
value = value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
1502
|
+
if isinstance(value, dict):
|
|
1503
|
+
for prop, v in value.items():
|
|
1504
|
+
self._deep_object(f"{key}[{prop}]", v, out)
|
|
1505
|
+
elif value is not None:
|
|
1506
|
+
out[key] = value
|
|
1507
|
+
|
|
1508
|
+
_COLLECTION_DELIMITERS = {"csv": ",", "ssv": " ", "pipes": "|"}
|
|
1509
|
+
|
|
1510
|
+
#: Characters left literal in a cookie value: every RFC 6265 cookie-octet
|
|
1511
|
+
#: except the \`,\` and \`;\` this client joins members on. A \`=\` stays literal
|
|
1512
|
+
#: too — only the first one separates a cookie's name from its value.
|
|
1513
|
+
_COOKIE_SAFE = "!#$%&'()*+-./:<>?@[]^_\`{|}~="
|
|
1514
|
+
|
|
1515
|
+
def _scalar(self, value: Any) -> str:
|
|
1516
|
+
# The wire form of a single parameter value: JSON spellings for bools,
|
|
1517
|
+
# ISO-8601 for dates, and the model's own wire shape for anything else.
|
|
1518
|
+
if isinstance(value, bool):
|
|
1519
|
+
return "true" if value else "false"
|
|
1520
|
+
if isinstance(value, (datetime.date, datetime.datetime)):
|
|
1521
|
+
return value.isoformat()
|
|
1522
|
+
dumped = self._dump(value)
|
|
1523
|
+
if isinstance(dumped, str):
|
|
1524
|
+
return dumped
|
|
1525
|
+
# RFC 6570 renders a list as its comma-joined members and an object as
|
|
1526
|
+
# comma-joined key,value pairs. Python's own \`str\` would emit a repr —
|
|
1527
|
+
# \`['a', 'b']\`, quotes and spaces included.
|
|
1528
|
+
if isinstance(dumped, list):
|
|
1529
|
+
return ",".join(self._scalar(v) for v in dumped)
|
|
1530
|
+
if isinstance(dumped, dict):
|
|
1531
|
+
return ",".join(
|
|
1532
|
+
f"{k},{self._scalar(v)}" for k, v in dumped.items() if v is not None
|
|
1533
|
+
)
|
|
1534
|
+
if dumped is None:
|
|
1535
|
+
return ""
|
|
1536
|
+
return str(dumped)
|
|
1537
|
+
|
|
1538
|
+
def _query(
|
|
1539
|
+
self,
|
|
1540
|
+
query_params: dict[str, Any],
|
|
1541
|
+
collection_formats: dict[str, str] | None = None,
|
|
1542
|
+
) -> dict[str, Any]:
|
|
1543
|
+
out: dict[str, Any] = {}
|
|
1544
|
+
for key, value in query_params.items():
|
|
1545
|
+
if value is None:
|
|
1546
|
+
continue
|
|
1547
|
+
fmt = (collection_formats or {}).get(key)
|
|
1548
|
+
if fmt == "deepObject":
|
|
1549
|
+
self._deep_object(key, value, out)
|
|
1550
|
+
elif isinstance(value, list):
|
|
1551
|
+
delimiter = self._COLLECTION_DELIMITERS.get(fmt or "multi")
|
|
1552
|
+
if delimiter is None:
|
|
1553
|
+
out[key] = [self._scalar(v) for v in value]
|
|
1554
|
+
else:
|
|
1555
|
+
out[key] = delimiter.join(self._scalar(v) for v in value)
|
|
1556
|
+
elif self._is_object(value):
|
|
1557
|
+
# OpenAPI's default query style is form/explode, under which an
|
|
1558
|
+
# object expands to one parameter per property rather than
|
|
1559
|
+
# being stringified.
|
|
1560
|
+
for prop, prop_value in self._as_dict(value).items():
|
|
1561
|
+
if prop_value is not None:
|
|
1562
|
+
out[prop] = self._scalar(prop_value)
|
|
1563
|
+
else:
|
|
1564
|
+
out[key] = self._scalar(value)
|
|
1565
|
+
return out
|
|
1566
|
+
|
|
1567
|
+
def _is_object(self, value: Any) -> bool:
|
|
1568
|
+
return isinstance(value, (dict, BaseModel))
|
|
1569
|
+
|
|
1570
|
+
def _as_dict(self, value: Any) -> dict[str, Any]:
|
|
1571
|
+
if isinstance(value, BaseModel):
|
|
1572
|
+
return value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
1573
|
+
return dict(value)
|
|
1574
|
+
|
|
1575
|
+
def _headers(
|
|
1576
|
+
self,
|
|
1577
|
+
header_params: dict[str, Any] | None = None,
|
|
1578
|
+
collection_formats: dict[str, str] | None = None,
|
|
1579
|
+
cookie_params: dict[str, Any] | None = None,
|
|
1580
|
+
) -> list[tuple[str, str]]:
|
|
1581
|
+
out: list[tuple[str, str]] = []
|
|
1582
|
+
for key, value in (header_params or {}).items():
|
|
1583
|
+
if value is None:
|
|
1584
|
+
continue
|
|
1585
|
+
if isinstance(value, list):
|
|
1586
|
+
fmt = (collection_formats or {}).get(key, "csv")
|
|
1587
|
+
delimiter = self._COLLECTION_DELIMITERS.get(fmt)
|
|
1588
|
+
if delimiter is None:
|
|
1589
|
+
for item in value:
|
|
1590
|
+
out.append((key, self._scalar(item)))
|
|
1591
|
+
else:
|
|
1592
|
+
out.append((key, delimiter.join(self._scalar(v) for v in value)))
|
|
1593
|
+
else:
|
|
1594
|
+
out.append((key, self._scalar(value)))
|
|
1595
|
+
# A config header only applies where the operation didn't set one:
|
|
1596
|
+
# httpx comma-joins repeated names, which would corrupt the value.
|
|
1597
|
+
operation_headers = {key.lower() for key, _ in out}
|
|
1598
|
+
out.extend(
|
|
1599
|
+
(key, value)
|
|
1600
|
+
for key, value in self._config.headers.items()
|
|
1601
|
+
if key.lower() not in operation_headers
|
|
1602
|
+
)
|
|
1603
|
+
# The operation's cookies are merged into one \`Cookie\` header alongside
|
|
1604
|
+
# every other source. Passing them to httpx's \`cookies=\` instead would
|
|
1605
|
+
# drop them outright whenever a \`Cookie\` header is present, since
|
|
1606
|
+
# http.cookiejar skips a request that already carries one — and setting
|
|
1607
|
+
# the header here would in turn shadow the caller's own jar and header,
|
|
1608
|
+
# which httpx resolves in favour of the more specific value.
|
|
1609
|
+
cookies = self._cookies(cookie_params or {})
|
|
1610
|
+
if cookies:
|
|
1611
|
+
pairs = [
|
|
1612
|
+
*(
|
|
1613
|
+
value
|
|
1614
|
+
for source in (self._client.headers, dict(out))
|
|
1615
|
+
for key, value in source.items()
|
|
1616
|
+
if key.lower() == "cookie"
|
|
1617
|
+
),
|
|
1618
|
+
*(f"{key}={value}" for key, value in self._client.cookies.items()),
|
|
1619
|
+
*(f"{key}={value}" for key, value in cookies.items()),
|
|
1620
|
+
]
|
|
1621
|
+
out = [(key, value) for key, value in out if key.lower() != "cookie"]
|
|
1622
|
+
out.append(("Cookie", "; ".join(pairs)))
|
|
1623
|
+
return out
|
|
1624
|
+
|
|
1625
|
+
def _default_content_type(
|
|
1626
|
+
self, header_params: dict[str, Any], media_type: str
|
|
1627
|
+
) -> None:
|
|
1628
|
+
# The media type the specification declares, applied unless the operation
|
|
1629
|
+
# takes a Content-Type of its own and the caller supplied one. Header
|
|
1630
|
+
# names are case-insensitive, and a declared header the caller omitted is
|
|
1631
|
+
# present holding \`None\` — neither counts as the caller setting it.
|
|
1632
|
+
if any(
|
|
1633
|
+
key.lower() == "content-type" and value is not None
|
|
1634
|
+
for key, value in header_params.items()
|
|
1635
|
+
):
|
|
1636
|
+
return
|
|
1637
|
+
for key in list(header_params):
|
|
1638
|
+
if key.lower() == "content-type":
|
|
1639
|
+
header_params[key] = media_type
|
|
1640
|
+
return
|
|
1641
|
+
header_params["Content-Type"] = media_type
|
|
1642
|
+
|
|
1643
|
+
def _cookies(self, cookie_params: dict[str, Any]) -> dict[str, str]:
|
|
1644
|
+
out: dict[str, str] = {}
|
|
1645
|
+
for key, value in cookie_params.items():
|
|
1646
|
+
if value is None:
|
|
1647
|
+
continue
|
|
1648
|
+
dumped = self._dump(value)
|
|
1649
|
+
# A cookie uses form-style expansion, so a list joins on \`,\` and an
|
|
1650
|
+
# object on \`,\` between each key and value. Members are encoded so a
|
|
1651
|
+
# \`;\` or \`,\` inside one can't be read as a delimiter, while the
|
|
1652
|
+
# joining commas stay literal.
|
|
1653
|
+
if isinstance(dumped, list):
|
|
1654
|
+
rendered = ",".join(self._cookie_value(v) for v in dumped)
|
|
1655
|
+
elif isinstance(dumped, dict):
|
|
1656
|
+
rendered = ",".join(
|
|
1657
|
+
self._cookie_value(k) + "," + self._cookie_value(v)
|
|
1658
|
+
for k, v in dumped.items()
|
|
1659
|
+
if v is not None
|
|
1660
|
+
)
|
|
1661
|
+
else:
|
|
1662
|
+
rendered = self._cookie_value(value)
|
|
1663
|
+
out[key] = rendered
|
|
1664
|
+
return out
|
|
1665
|
+
|
|
1666
|
+
def _cookie_value(self, value: Any) -> str:
|
|
1667
|
+
# Only the characters a cookie parser treats as structure are escaped, so
|
|
1668
|
+
# a timestamp keeps its colons and a base64 token its \`=\` padding. Servers
|
|
1669
|
+
# do not URL-decode cookies, so anything escaped here arrives escaped.
|
|
1670
|
+
return quote(self._scalar(value), safe=self._COOKIE_SAFE)
|
|
1671
|
+
|
|
1672
|
+
def _dump(self, value: Any) -> Any:
|
|
1673
|
+
if value is None:
|
|
1674
|
+
return None
|
|
1675
|
+
if isinstance(value, BaseModel):
|
|
1676
|
+
return value.model_dump(mode="json", by_alias=True, exclude_unset=True)
|
|
1677
|
+
if isinstance(value, (list, tuple)):
|
|
1678
|
+
return [self._dump(v) for v in value]
|
|
1679
|
+
if isinstance(value, dict):
|
|
1680
|
+
return {k: self._dump(v) for k, v in value.items()}
|
|
1681
|
+
if isinstance(value, (datetime.date, datetime.datetime)):
|
|
1682
|
+
return value.isoformat()
|
|
1683
|
+
return value
|
|
1684
|
+
|
|
1685
|
+
def _json_body(self, response: httpx.Response) -> Any:
|
|
1686
|
+
# A response declaring JSON alongside another media type can arrive as
|
|
1687
|
+
# either, and a declared-JSON body can arrive empty (a 200 with no
|
|
1688
|
+
# content). Both would raise a bare JSONDecodeError out of the client, so
|
|
1689
|
+
# the text is handed over instead.
|
|
1690
|
+
if not response.content:
|
|
1691
|
+
return None
|
|
1692
|
+
try:
|
|
1693
|
+
return response.json()
|
|
1694
|
+
except ValueError:
|
|
1695
|
+
return response.text
|
|
1696
|
+
|
|
1697
|
+
def _error_payload(self, response: httpx.Response) -> Any:
|
|
1698
|
+
# An error body is whatever the server actually sent, which need not be
|
|
1699
|
+
# the JSON the spec declares (a proxy's HTML page, say).
|
|
1700
|
+
try:
|
|
1701
|
+
return response.json()
|
|
1702
|
+
except ValueError:
|
|
1703
|
+
return response.text
|
|
1704
|
+
|
|
1705
|
+
def _error(self, wrapper: type[_ErrorT], status: int, payload: Any) -> _ErrorT:
|
|
1706
|
+
# Coerce to the declared error type, falling back to the raw payload so
|
|
1707
|
+
# a body that doesn't match the spec still raises the typed exception.
|
|
1708
|
+
try:
|
|
1709
|
+
return wrapper.model_validate({"status": status, "error": payload})
|
|
1710
|
+
except ValidationError:
|
|
1711
|
+
return wrapper.model_construct(status=status, error=payload)
|
|
1712
|
+
|
|
1713
|
+
def _add_pet(
|
|
1714
|
+
self,
|
|
1715
|
+
*,
|
|
1716
|
+
name: str,
|
|
1717
|
+
photo_urls: list[str],
|
|
1718
|
+
id: int | None = None,
|
|
1719
|
+
category: types.Category | None = None,
|
|
1720
|
+
tags: list[types.Tag] | None = None,
|
|
1721
|
+
status: types.PetStatus | None = None,
|
|
1722
|
+
) -> types.Pet:
|
|
1723
|
+
"""Add a new pet to the store."""
|
|
1724
|
+
header_params: dict[str, Any] = {}
|
|
1725
|
+
_body_fields: dict[str, Any] = {}
|
|
1726
|
+
_body_fields["name"] = name
|
|
1727
|
+
_body_fields["photoUrls"] = photo_urls
|
|
1728
|
+
if id is not None:
|
|
1729
|
+
_body_fields["id"] = id
|
|
1730
|
+
if category is not None:
|
|
1731
|
+
_body_fields["category"] = category
|
|
1732
|
+
if tags is not None:
|
|
1733
|
+
_body_fields["tags"] = tags
|
|
1734
|
+
if status is not None:
|
|
1735
|
+
_body_fields["status"] = status
|
|
1736
|
+
body = types.Pet.model_validate(_body_fields).model_dump(
|
|
1737
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
1738
|
+
)
|
|
1739
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
1740
|
+
if not self._config.omit_content_type_header:
|
|
1741
|
+
self._default_content_type(header_params, "application/json")
|
|
1742
|
+
_request_url = self._url("/pet", {})
|
|
1743
|
+
response = self._client.request(
|
|
1744
|
+
"POST",
|
|
1745
|
+
_request_url,
|
|
1746
|
+
headers=self._headers(header_params),
|
|
1747
|
+
**request_kwargs,
|
|
1748
|
+
)
|
|
1749
|
+
if response.status_code == 200:
|
|
1750
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
1751
|
+
if response.status_code == 400:
|
|
1752
|
+
raise AddPetApiError(
|
|
1753
|
+
response.status_code,
|
|
1754
|
+
self._error(types.AddPet400Error, 400, None),
|
|
1755
|
+
)
|
|
1756
|
+
if response.status_code == 422:
|
|
1757
|
+
raise AddPetApiError(
|
|
1758
|
+
response.status_code,
|
|
1759
|
+
self._error(types.AddPet422Error, 422, None),
|
|
1760
|
+
)
|
|
1761
|
+
raise AddPetApiError(
|
|
1762
|
+
response.status_code,
|
|
1763
|
+
self._error(types.AddPetDefaultError, response.status_code, None),
|
|
1764
|
+
)
|
|
1765
|
+
|
|
1766
|
+
def _create_user(
|
|
1767
|
+
self,
|
|
1768
|
+
*,
|
|
1769
|
+
id: int | None = None,
|
|
1770
|
+
username: str | None = None,
|
|
1771
|
+
first_name: str | None = None,
|
|
1772
|
+
last_name: str | None = None,
|
|
1773
|
+
email: str | None = None,
|
|
1774
|
+
password: str | None = None,
|
|
1775
|
+
phone: str | None = None,
|
|
1776
|
+
user_status: int | None = None,
|
|
1777
|
+
) -> types.User:
|
|
1778
|
+
"""This can only be done by the logged in user."""
|
|
1779
|
+
header_params: dict[str, Any] = {}
|
|
1780
|
+
_body_fields: dict[str, Any] = {}
|
|
1781
|
+
if id is not None:
|
|
1782
|
+
_body_fields["id"] = id
|
|
1783
|
+
if username is not None:
|
|
1784
|
+
_body_fields["username"] = username
|
|
1785
|
+
if first_name is not None:
|
|
1786
|
+
_body_fields["firstName"] = first_name
|
|
1787
|
+
if last_name is not None:
|
|
1788
|
+
_body_fields["lastName"] = last_name
|
|
1789
|
+
if email is not None:
|
|
1790
|
+
_body_fields["email"] = email
|
|
1791
|
+
if password is not None:
|
|
1792
|
+
_body_fields["password"] = password
|
|
1793
|
+
if phone is not None:
|
|
1794
|
+
_body_fields["phone"] = phone
|
|
1795
|
+
if user_status is not None:
|
|
1796
|
+
_body_fields["userStatus"] = user_status
|
|
1797
|
+
body = types.User.model_validate(_body_fields).model_dump(
|
|
1798
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
1799
|
+
)
|
|
1800
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
1801
|
+
if not self._config.omit_content_type_header:
|
|
1802
|
+
self._default_content_type(header_params, "application/json")
|
|
1803
|
+
_request_url = self._url("/user", {})
|
|
1804
|
+
response = self._client.request(
|
|
1805
|
+
"POST",
|
|
1806
|
+
_request_url,
|
|
1807
|
+
headers=self._headers(header_params),
|
|
1808
|
+
**request_kwargs,
|
|
1809
|
+
)
|
|
1810
|
+
if response.status_code == 200:
|
|
1811
|
+
return types.User.model_validate(self._json_body(response))
|
|
1812
|
+
raise CreateUserApiError(
|
|
1813
|
+
response.status_code,
|
|
1814
|
+
self._error(types.CreateUserDefaultError, response.status_code, None),
|
|
1815
|
+
)
|
|
1816
|
+
|
|
1817
|
+
def _create_users_with_list_input(
|
|
1818
|
+
self,
|
|
1819
|
+
body: list[types.User] | None = None,
|
|
1820
|
+
) -> types.User:
|
|
1821
|
+
"""Creates list of users with given input array."""
|
|
1822
|
+
header_params: dict[str, Any] = {}
|
|
1823
|
+
body = self._dump(body)
|
|
1824
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
1825
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
1826
|
+
self._default_content_type(header_params, "application/json")
|
|
1827
|
+
_request_url = self._url("/user/createWithList", {})
|
|
1828
|
+
response = self._client.request(
|
|
1829
|
+
"POST",
|
|
1830
|
+
_request_url,
|
|
1831
|
+
headers=self._headers(header_params),
|
|
1832
|
+
**request_kwargs,
|
|
1833
|
+
)
|
|
1834
|
+
if response.status_code == 200:
|
|
1835
|
+
return types.User.model_validate(self._json_body(response))
|
|
1836
|
+
raise CreateUsersWithListInputApiError(
|
|
1837
|
+
response.status_code,
|
|
1838
|
+
self._error(
|
|
1839
|
+
types.CreateUsersWithListInputDefaultError, response.status_code, None
|
|
1840
|
+
),
|
|
1841
|
+
)
|
|
1842
|
+
|
|
1843
|
+
def _delete_order(
|
|
1844
|
+
self,
|
|
1845
|
+
*,
|
|
1846
|
+
order_id: int,
|
|
1847
|
+
) -> None:
|
|
1848
|
+
"""
|
|
1849
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API
|
|
1850
|
+
errors.
|
|
1851
|
+
"""
|
|
1852
|
+
path_params: dict[str, Any] = {"orderId": order_id}
|
|
1853
|
+
request_kwargs: dict[str, Any] = {}
|
|
1854
|
+
_request_url = self._url("/store/order/{orderId}", path_params)
|
|
1855
|
+
response = self._client.request(
|
|
1856
|
+
"DELETE",
|
|
1857
|
+
_request_url,
|
|
1858
|
+
headers=self._headers(),
|
|
1859
|
+
**request_kwargs,
|
|
1860
|
+
)
|
|
1861
|
+
if response.status_code == 200:
|
|
1862
|
+
return None
|
|
1863
|
+
if response.status_code == 400:
|
|
1864
|
+
raise DeleteOrderApiError(
|
|
1865
|
+
response.status_code,
|
|
1866
|
+
self._error(types.DeleteOrder400Error, 400, None),
|
|
1867
|
+
)
|
|
1868
|
+
if response.status_code == 404:
|
|
1869
|
+
raise DeleteOrderApiError(
|
|
1870
|
+
response.status_code,
|
|
1871
|
+
self._error(types.DeleteOrder404Error, 404, None),
|
|
1872
|
+
)
|
|
1873
|
+
raise DeleteOrderApiError(
|
|
1874
|
+
response.status_code,
|
|
1875
|
+
self._error(types.DeleteOrderDefaultError, response.status_code, None),
|
|
1876
|
+
)
|
|
1877
|
+
|
|
1878
|
+
def _delete_pet(
|
|
1879
|
+
self,
|
|
1880
|
+
*,
|
|
1881
|
+
pet_id: int,
|
|
1882
|
+
api_key: str | None = None,
|
|
1883
|
+
) -> None:
|
|
1884
|
+
"""Delete a pet."""
|
|
1885
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
1886
|
+
header_params: dict[str, Any] = {"api_key": api_key}
|
|
1887
|
+
header_formats: dict[str, str] | None = {"api_key": "csv"}
|
|
1888
|
+
request_kwargs: dict[str, Any] = {}
|
|
1889
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
1890
|
+
response = self._client.request(
|
|
1891
|
+
"DELETE",
|
|
1892
|
+
_request_url,
|
|
1893
|
+
headers=self._headers(header_params, collection_formats=header_formats),
|
|
1894
|
+
**request_kwargs,
|
|
1895
|
+
)
|
|
1896
|
+
if response.status_code == 200:
|
|
1897
|
+
return None
|
|
1898
|
+
if response.status_code == 400:
|
|
1899
|
+
raise DeletePetApiError(
|
|
1900
|
+
response.status_code,
|
|
1901
|
+
self._error(types.DeletePet400Error, 400, None),
|
|
1902
|
+
)
|
|
1903
|
+
raise DeletePetApiError(
|
|
1904
|
+
response.status_code,
|
|
1905
|
+
self._error(types.DeletePetDefaultError, response.status_code, None),
|
|
1906
|
+
)
|
|
1907
|
+
|
|
1908
|
+
def _delete_user(
|
|
1909
|
+
self,
|
|
1910
|
+
*,
|
|
1911
|
+
username: str,
|
|
1912
|
+
) -> None:
|
|
1913
|
+
"""This can only be done by the logged in user."""
|
|
1914
|
+
path_params: dict[str, Any] = {"username": username}
|
|
1915
|
+
request_kwargs: dict[str, Any] = {}
|
|
1916
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
1917
|
+
response = self._client.request(
|
|
1918
|
+
"DELETE",
|
|
1919
|
+
_request_url,
|
|
1920
|
+
headers=self._headers(),
|
|
1921
|
+
**request_kwargs,
|
|
1922
|
+
)
|
|
1923
|
+
if response.status_code == 200:
|
|
1924
|
+
return None
|
|
1925
|
+
if response.status_code == 400:
|
|
1926
|
+
raise DeleteUserApiError(
|
|
1927
|
+
response.status_code,
|
|
1928
|
+
self._error(types.DeleteUser400Error, 400, None),
|
|
1929
|
+
)
|
|
1930
|
+
if response.status_code == 404:
|
|
1931
|
+
raise DeleteUserApiError(
|
|
1932
|
+
response.status_code,
|
|
1933
|
+
self._error(types.DeleteUser404Error, 404, None),
|
|
1934
|
+
)
|
|
1935
|
+
raise DeleteUserApiError(
|
|
1936
|
+
response.status_code,
|
|
1937
|
+
self._error(types.DeleteUserDefaultError, response.status_code, None),
|
|
1938
|
+
)
|
|
1939
|
+
|
|
1940
|
+
def _find_pets_by_status(
|
|
1941
|
+
self,
|
|
1942
|
+
*,
|
|
1943
|
+
status: Literal["available", "pending", "sold"] | None = None,
|
|
1944
|
+
) -> list[types.Pet]:
|
|
1945
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
1946
|
+
query_params: dict[str, Any] = {"status": status}
|
|
1947
|
+
query_formats: dict[str, str] | None = {"status": "multi"}
|
|
1948
|
+
request_kwargs: dict[str, Any] = {}
|
|
1949
|
+
_request_url = self._url("/pet/findByStatus", {})
|
|
1950
|
+
response = self._client.request(
|
|
1951
|
+
"GET",
|
|
1952
|
+
_request_url,
|
|
1953
|
+
params=self._query(query_params, query_formats),
|
|
1954
|
+
headers=self._headers(),
|
|
1955
|
+
**request_kwargs,
|
|
1956
|
+
)
|
|
1957
|
+
if response.status_code == 200:
|
|
1958
|
+
return TypeAdapter(list[types.Pet]).validate_python(
|
|
1959
|
+
self._json_body(response)
|
|
1960
|
+
)
|
|
1961
|
+
if response.status_code == 400:
|
|
1962
|
+
raise FindPetsByStatusApiError(
|
|
1963
|
+
response.status_code,
|
|
1964
|
+
self._error(types.FindPetsByStatus400Error, 400, None),
|
|
1965
|
+
)
|
|
1966
|
+
raise FindPetsByStatusApiError(
|
|
1967
|
+
response.status_code,
|
|
1968
|
+
self._error(types.FindPetsByStatusDefaultError, response.status_code, None),
|
|
1969
|
+
)
|
|
1970
|
+
|
|
1971
|
+
def _find_pets_by_tags(
|
|
1972
|
+
self,
|
|
1973
|
+
*,
|
|
1974
|
+
tags: list[str] | None = None,
|
|
1975
|
+
) -> list[types.Pet]:
|
|
1976
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
1977
|
+
query_params: dict[str, Any] = {"tags": tags}
|
|
1978
|
+
query_formats: dict[str, str] | None = {"tags": "multi"}
|
|
1979
|
+
request_kwargs: dict[str, Any] = {}
|
|
1980
|
+
_request_url = self._url("/pet/findByTags", {})
|
|
1981
|
+
response = self._client.request(
|
|
1982
|
+
"GET",
|
|
1983
|
+
_request_url,
|
|
1984
|
+
params=self._query(query_params, query_formats),
|
|
1985
|
+
headers=self._headers(),
|
|
1986
|
+
**request_kwargs,
|
|
1987
|
+
)
|
|
1988
|
+
if response.status_code == 200:
|
|
1989
|
+
return TypeAdapter(list[types.Pet]).validate_python(
|
|
1990
|
+
self._json_body(response)
|
|
1991
|
+
)
|
|
1992
|
+
if response.status_code == 400:
|
|
1993
|
+
raise FindPetsByTagsApiError(
|
|
1994
|
+
response.status_code,
|
|
1995
|
+
self._error(types.FindPetsByTags400Error, 400, None),
|
|
1996
|
+
)
|
|
1997
|
+
raise FindPetsByTagsApiError(
|
|
1998
|
+
response.status_code,
|
|
1999
|
+
self._error(types.FindPetsByTagsDefaultError, response.status_code, None),
|
|
2000
|
+
)
|
|
2001
|
+
|
|
2002
|
+
def _get_inventory(
|
|
2003
|
+
self,
|
|
2004
|
+
) -> types.GetInventory200Response:
|
|
2005
|
+
"""Returns a map of status codes to quantities."""
|
|
2006
|
+
request_kwargs: dict[str, Any] = {}
|
|
2007
|
+
_request_url = self._url("/store/inventory", {})
|
|
2008
|
+
response = self._client.request(
|
|
2009
|
+
"GET",
|
|
2010
|
+
_request_url,
|
|
2011
|
+
headers=self._headers(),
|
|
2012
|
+
**request_kwargs,
|
|
2013
|
+
)
|
|
2014
|
+
if response.status_code == 200:
|
|
2015
|
+
return TypeAdapter(types.GetInventory200Response).validate_python(
|
|
2016
|
+
response.json()
|
|
2017
|
+
)
|
|
2018
|
+
raise GetInventoryApiError(
|
|
2019
|
+
response.status_code,
|
|
2020
|
+
self._error(types.GetInventoryDefaultError, response.status_code, None),
|
|
2021
|
+
)
|
|
2022
|
+
|
|
2023
|
+
def _get_order_by_id(
|
|
2024
|
+
self,
|
|
2025
|
+
*,
|
|
2026
|
+
order_id: int,
|
|
2027
|
+
) -> types.Order:
|
|
2028
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
2029
|
+
path_params: dict[str, Any] = {"orderId": order_id}
|
|
2030
|
+
request_kwargs: dict[str, Any] = {}
|
|
2031
|
+
_request_url = self._url("/store/order/{orderId}", path_params)
|
|
2032
|
+
response = self._client.request(
|
|
2033
|
+
"GET",
|
|
2034
|
+
_request_url,
|
|
2035
|
+
headers=self._headers(),
|
|
2036
|
+
**request_kwargs,
|
|
2037
|
+
)
|
|
2038
|
+
if response.status_code == 200:
|
|
2039
|
+
return types.Order.model_validate(self._json_body(response))
|
|
2040
|
+
if response.status_code == 400:
|
|
2041
|
+
raise GetOrderByIdApiError(
|
|
2042
|
+
response.status_code,
|
|
2043
|
+
self._error(types.GetOrderById400Error, 400, None),
|
|
2044
|
+
)
|
|
2045
|
+
if response.status_code == 404:
|
|
2046
|
+
raise GetOrderByIdApiError(
|
|
2047
|
+
response.status_code,
|
|
2048
|
+
self._error(types.GetOrderById404Error, 404, None),
|
|
2049
|
+
)
|
|
2050
|
+
raise GetOrderByIdApiError(
|
|
2051
|
+
response.status_code,
|
|
2052
|
+
self._error(types.GetOrderByIdDefaultError, response.status_code, None),
|
|
2053
|
+
)
|
|
2054
|
+
|
|
2055
|
+
def _get_pet_by_id(
|
|
2056
|
+
self,
|
|
2057
|
+
*,
|
|
2058
|
+
pet_id: int,
|
|
2059
|
+
) -> types.Pet:
|
|
2060
|
+
"""Returns a single pet."""
|
|
2061
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
2062
|
+
request_kwargs: dict[str, Any] = {}
|
|
2063
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
2064
|
+
response = self._client.request(
|
|
2065
|
+
"GET",
|
|
2066
|
+
_request_url,
|
|
2067
|
+
headers=self._headers(),
|
|
2068
|
+
**request_kwargs,
|
|
2069
|
+
)
|
|
2070
|
+
if response.status_code == 200:
|
|
2071
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
2072
|
+
if response.status_code == 400:
|
|
2073
|
+
raise GetPetByIdApiError(
|
|
2074
|
+
response.status_code,
|
|
2075
|
+
self._error(types.GetPetById400Error, 400, None),
|
|
2076
|
+
)
|
|
2077
|
+
if response.status_code == 404:
|
|
2078
|
+
raise GetPetByIdApiError(
|
|
2079
|
+
response.status_code,
|
|
2080
|
+
self._error(types.GetPetById404Error, 404, None),
|
|
2081
|
+
)
|
|
2082
|
+
raise GetPetByIdApiError(
|
|
2083
|
+
response.status_code,
|
|
2084
|
+
self._error(types.GetPetByIdDefaultError, response.status_code, None),
|
|
2085
|
+
)
|
|
2086
|
+
|
|
2087
|
+
def _get_user_by_name(
|
|
2088
|
+
self,
|
|
2089
|
+
*,
|
|
2090
|
+
username: str,
|
|
2091
|
+
) -> types.User:
|
|
2092
|
+
"""Get user detail based on username."""
|
|
2093
|
+
path_params: dict[str, Any] = {"username": username}
|
|
2094
|
+
request_kwargs: dict[str, Any] = {}
|
|
2095
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
2096
|
+
response = self._client.request(
|
|
2097
|
+
"GET",
|
|
2098
|
+
_request_url,
|
|
2099
|
+
headers=self._headers(),
|
|
2100
|
+
**request_kwargs,
|
|
2101
|
+
)
|
|
2102
|
+
if response.status_code == 200:
|
|
2103
|
+
return types.User.model_validate(self._json_body(response))
|
|
2104
|
+
if response.status_code == 400:
|
|
2105
|
+
raise GetUserByNameApiError(
|
|
2106
|
+
response.status_code,
|
|
2107
|
+
self._error(types.GetUserByName400Error, 400, None),
|
|
2108
|
+
)
|
|
2109
|
+
if response.status_code == 404:
|
|
2110
|
+
raise GetUserByNameApiError(
|
|
2111
|
+
response.status_code,
|
|
2112
|
+
self._error(types.GetUserByName404Error, 404, None),
|
|
2113
|
+
)
|
|
2114
|
+
raise GetUserByNameApiError(
|
|
2115
|
+
response.status_code,
|
|
2116
|
+
self._error(types.GetUserByNameDefaultError, response.status_code, None),
|
|
2117
|
+
)
|
|
2118
|
+
|
|
2119
|
+
def _login_user(
|
|
2120
|
+
self,
|
|
2121
|
+
*,
|
|
2122
|
+
username: str | None = None,
|
|
2123
|
+
password: str | None = None,
|
|
2124
|
+
) -> str:
|
|
2125
|
+
"""Log into the system."""
|
|
2126
|
+
query_params: dict[str, Any] = {"username": username, "password": password}
|
|
2127
|
+
query_formats: dict[str, str] | None = {
|
|
2128
|
+
"username": "multi",
|
|
2129
|
+
"password": "multi",
|
|
2130
|
+
}
|
|
2131
|
+
request_kwargs: dict[str, Any] = {}
|
|
2132
|
+
_request_url = self._url("/user/login", {})
|
|
2133
|
+
response = self._client.request(
|
|
2134
|
+
"GET",
|
|
2135
|
+
_request_url,
|
|
2136
|
+
params=self._query(query_params, query_formats),
|
|
2137
|
+
headers=self._headers(),
|
|
2138
|
+
**request_kwargs,
|
|
2139
|
+
)
|
|
2140
|
+
if response.status_code == 200:
|
|
2141
|
+
return self._json_body(response)
|
|
2142
|
+
if response.status_code == 400:
|
|
2143
|
+
raise LoginUserApiError(
|
|
2144
|
+
response.status_code,
|
|
2145
|
+
self._error(types.LoginUser400Error, 400, None),
|
|
2146
|
+
)
|
|
2147
|
+
raise LoginUserApiError(
|
|
2148
|
+
response.status_code,
|
|
2149
|
+
self._error(types.LoginUserDefaultError, response.status_code, None),
|
|
2150
|
+
)
|
|
2151
|
+
|
|
2152
|
+
def _logout_user(
|
|
2153
|
+
self,
|
|
2154
|
+
) -> None:
|
|
2155
|
+
"""Log user out of the system."""
|
|
2156
|
+
request_kwargs: dict[str, Any] = {}
|
|
2157
|
+
_request_url = self._url("/user/logout", {})
|
|
2158
|
+
response = self._client.request(
|
|
2159
|
+
"GET",
|
|
2160
|
+
_request_url,
|
|
2161
|
+
headers=self._headers(),
|
|
2162
|
+
**request_kwargs,
|
|
2163
|
+
)
|
|
2164
|
+
if response.status_code == 200:
|
|
2165
|
+
return None
|
|
2166
|
+
raise LogoutUserApiError(
|
|
2167
|
+
response.status_code,
|
|
2168
|
+
self._error(types.LogoutUserDefaultError, response.status_code, None),
|
|
2169
|
+
)
|
|
2170
|
+
|
|
2171
|
+
def _place_order(
|
|
2172
|
+
self,
|
|
2173
|
+
*,
|
|
2174
|
+
id: int | None = None,
|
|
2175
|
+
pet_id: int | None = None,
|
|
2176
|
+
quantity: int | None = None,
|
|
2177
|
+
ship_date: datetime.datetime | None = None,
|
|
2178
|
+
status: types.OrderStatus | None = None,
|
|
2179
|
+
complete: bool | None = None,
|
|
2180
|
+
) -> types.Order:
|
|
2181
|
+
"""Place a new order in the store."""
|
|
2182
|
+
header_params: dict[str, Any] = {}
|
|
2183
|
+
_body_fields: dict[str, Any] = {}
|
|
2184
|
+
if id is not None:
|
|
2185
|
+
_body_fields["id"] = id
|
|
2186
|
+
if pet_id is not None:
|
|
2187
|
+
_body_fields["petId"] = pet_id
|
|
2188
|
+
if quantity is not None:
|
|
2189
|
+
_body_fields["quantity"] = quantity
|
|
2190
|
+
if ship_date is not None:
|
|
2191
|
+
_body_fields["shipDate"] = ship_date
|
|
2192
|
+
if status is not None:
|
|
2193
|
+
_body_fields["status"] = status
|
|
2194
|
+
if complete is not None:
|
|
2195
|
+
_body_fields["complete"] = complete
|
|
2196
|
+
body = types.Order.model_validate(_body_fields).model_dump(
|
|
2197
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
2198
|
+
)
|
|
2199
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
2200
|
+
if not self._config.omit_content_type_header:
|
|
2201
|
+
self._default_content_type(header_params, "application/json")
|
|
2202
|
+
_request_url = self._url("/store/order", {})
|
|
2203
|
+
response = self._client.request(
|
|
2204
|
+
"POST",
|
|
2205
|
+
_request_url,
|
|
2206
|
+
headers=self._headers(header_params),
|
|
2207
|
+
**request_kwargs,
|
|
2208
|
+
)
|
|
2209
|
+
if response.status_code == 200:
|
|
2210
|
+
return types.Order.model_validate(response.json())
|
|
2211
|
+
if response.status_code == 400:
|
|
2212
|
+
raise PlaceOrderApiError(
|
|
2213
|
+
response.status_code,
|
|
2214
|
+
self._error(types.PlaceOrder400Error, 400, None),
|
|
2215
|
+
)
|
|
2216
|
+
if response.status_code == 422:
|
|
2217
|
+
raise PlaceOrderApiError(
|
|
2218
|
+
response.status_code,
|
|
2219
|
+
self._error(types.PlaceOrder422Error, 422, None),
|
|
2220
|
+
)
|
|
2221
|
+
raise PlaceOrderApiError(
|
|
2222
|
+
response.status_code,
|
|
2223
|
+
self._error(types.PlaceOrderDefaultError, response.status_code, None),
|
|
2224
|
+
)
|
|
2225
|
+
|
|
2226
|
+
def _update_pet(
|
|
2227
|
+
self,
|
|
2228
|
+
*,
|
|
2229
|
+
name: str,
|
|
2230
|
+
photo_urls: list[str],
|
|
2231
|
+
id: int | None = None,
|
|
2232
|
+
category: types.Category | None = None,
|
|
2233
|
+
tags: list[types.Tag] | None = None,
|
|
2234
|
+
status: types.PetStatus | None = None,
|
|
2235
|
+
) -> types.Pet:
|
|
2236
|
+
"""Update an existing pet by Id."""
|
|
2237
|
+
header_params: dict[str, Any] = {}
|
|
2238
|
+
_body_fields: dict[str, Any] = {}
|
|
2239
|
+
_body_fields["name"] = name
|
|
2240
|
+
_body_fields["photoUrls"] = photo_urls
|
|
2241
|
+
if id is not None:
|
|
2242
|
+
_body_fields["id"] = id
|
|
2243
|
+
if category is not None:
|
|
2244
|
+
_body_fields["category"] = category
|
|
2245
|
+
if tags is not None:
|
|
2246
|
+
_body_fields["tags"] = tags
|
|
2247
|
+
if status is not None:
|
|
2248
|
+
_body_fields["status"] = status
|
|
2249
|
+
body = types.Pet.model_validate(_body_fields).model_dump(
|
|
2250
|
+
mode="json", by_alias=True, exclude_unset=True
|
|
2251
|
+
)
|
|
2252
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
2253
|
+
if not self._config.omit_content_type_header:
|
|
2254
|
+
self._default_content_type(header_params, "application/json")
|
|
2255
|
+
_request_url = self._url("/pet", {})
|
|
2256
|
+
response = self._client.request(
|
|
2257
|
+
"PUT",
|
|
2258
|
+
_request_url,
|
|
2259
|
+
headers=self._headers(header_params),
|
|
2260
|
+
**request_kwargs,
|
|
2261
|
+
)
|
|
2262
|
+
if response.status_code == 200:
|
|
2263
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
2264
|
+
if response.status_code == 400:
|
|
2265
|
+
raise UpdatePetApiError(
|
|
2266
|
+
response.status_code,
|
|
2267
|
+
self._error(types.UpdatePet400Error, 400, None),
|
|
2268
|
+
)
|
|
2269
|
+
if response.status_code == 404:
|
|
2270
|
+
raise UpdatePetApiError(
|
|
2271
|
+
response.status_code,
|
|
2272
|
+
self._error(types.UpdatePet404Error, 404, None),
|
|
2273
|
+
)
|
|
2274
|
+
if response.status_code == 422:
|
|
2275
|
+
raise UpdatePetApiError(
|
|
2276
|
+
response.status_code,
|
|
2277
|
+
self._error(types.UpdatePet422Error, 422, None),
|
|
2278
|
+
)
|
|
2279
|
+
raise UpdatePetApiError(
|
|
2280
|
+
response.status_code,
|
|
2281
|
+
self._error(types.UpdatePetDefaultError, response.status_code, None),
|
|
2282
|
+
)
|
|
2283
|
+
|
|
2284
|
+
def _update_pet_with_form(
|
|
2285
|
+
self,
|
|
2286
|
+
*,
|
|
2287
|
+
pet_id: int,
|
|
2288
|
+
name: str | None = None,
|
|
2289
|
+
status: str | None = None,
|
|
2290
|
+
) -> types.Pet:
|
|
2291
|
+
"""Updates a pet resource based on the form data."""
|
|
2292
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
2293
|
+
query_params: dict[str, Any] = {"name": name, "status": status}
|
|
2294
|
+
query_formats: dict[str, str] | None = {"name": "multi", "status": "multi"}
|
|
2295
|
+
request_kwargs: dict[str, Any] = {}
|
|
2296
|
+
_request_url = self._url("/pet/{petId}", path_params)
|
|
2297
|
+
response = self._client.request(
|
|
2298
|
+
"POST",
|
|
2299
|
+
_request_url,
|
|
2300
|
+
params=self._query(query_params, query_formats),
|
|
2301
|
+
headers=self._headers(),
|
|
2302
|
+
**request_kwargs,
|
|
2303
|
+
)
|
|
2304
|
+
if response.status_code == 200:
|
|
2305
|
+
return types.Pet.model_validate(self._json_body(response))
|
|
2306
|
+
if response.status_code == 400:
|
|
2307
|
+
raise UpdatePetWithFormApiError(
|
|
2308
|
+
response.status_code,
|
|
2309
|
+
self._error(types.UpdatePetWithForm400Error, 400, None),
|
|
2310
|
+
)
|
|
2311
|
+
raise UpdatePetWithFormApiError(
|
|
2312
|
+
response.status_code,
|
|
2313
|
+
self._error(
|
|
2314
|
+
types.UpdatePetWithFormDefaultError, response.status_code, None
|
|
2315
|
+
),
|
|
2316
|
+
)
|
|
2317
|
+
|
|
2318
|
+
def _update_user(
|
|
2319
|
+
self,
|
|
2320
|
+
*,
|
|
2321
|
+
username: str,
|
|
2322
|
+
body: types.User | None = None,
|
|
2323
|
+
) -> None:
|
|
2324
|
+
"""This can only be done by the logged in user."""
|
|
2325
|
+
path_params: dict[str, Any] = {"username": username}
|
|
2326
|
+
header_params: dict[str, Any] = {}
|
|
2327
|
+
body = self._dump(body)
|
|
2328
|
+
request_kwargs: dict[str, Any] = {"json": body}
|
|
2329
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
2330
|
+
self._default_content_type(header_params, "application/json")
|
|
2331
|
+
_request_url = self._url("/user/{username}", path_params)
|
|
2332
|
+
response = self._client.request(
|
|
2333
|
+
"PUT",
|
|
2334
|
+
_request_url,
|
|
2335
|
+
headers=self._headers(header_params),
|
|
2336
|
+
**request_kwargs,
|
|
2337
|
+
)
|
|
2338
|
+
if response.status_code == 200:
|
|
2339
|
+
return None
|
|
2340
|
+
if response.status_code == 400:
|
|
2341
|
+
raise UpdateUserApiError(
|
|
2342
|
+
response.status_code,
|
|
2343
|
+
self._error(types.UpdateUser400Error, 400, None),
|
|
2344
|
+
)
|
|
2345
|
+
if response.status_code == 404:
|
|
2346
|
+
raise UpdateUserApiError(
|
|
2347
|
+
response.status_code,
|
|
2348
|
+
self._error(types.UpdateUser404Error, 404, None),
|
|
2349
|
+
)
|
|
2350
|
+
raise UpdateUserApiError(
|
|
2351
|
+
response.status_code,
|
|
2352
|
+
self._error(types.UpdateUserDefaultError, response.status_code, None),
|
|
2353
|
+
)
|
|
2354
|
+
|
|
2355
|
+
def _upload_file(
|
|
2356
|
+
self,
|
|
2357
|
+
*,
|
|
2358
|
+
pet_id: int,
|
|
2359
|
+
additional_metadata: str | None = None,
|
|
2360
|
+
body: bytes | None = None,
|
|
2361
|
+
) -> types.ApiResponse:
|
|
2362
|
+
"""Upload image of the pet."""
|
|
2363
|
+
path_params: dict[str, Any] = {"petId": pet_id}
|
|
2364
|
+
query_params: dict[str, Any] = {"additionalMetadata": additional_metadata}
|
|
2365
|
+
header_params: dict[str, Any] = {}
|
|
2366
|
+
query_formats: dict[str, str] | None = {"additionalMetadata": "multi"}
|
|
2367
|
+
body = body
|
|
2368
|
+
request_kwargs: dict[str, Any] = {"content": body}
|
|
2369
|
+
if body is not None and not self._config.omit_content_type_header:
|
|
2370
|
+
self._default_content_type(header_params, "application/octet-stream")
|
|
2371
|
+
_request_url = self._url("/pet/{petId}/uploadImage", path_params)
|
|
2372
|
+
response = self._client.request(
|
|
2373
|
+
"POST",
|
|
2374
|
+
_request_url,
|
|
2375
|
+
params=self._query(query_params, query_formats),
|
|
2376
|
+
headers=self._headers(header_params),
|
|
2377
|
+
**request_kwargs,
|
|
2378
|
+
)
|
|
2379
|
+
if response.status_code == 200:
|
|
2380
|
+
return types.ApiResponse.model_validate(response.json())
|
|
2381
|
+
if response.status_code == 400:
|
|
2382
|
+
raise UploadFileApiError(
|
|
2383
|
+
response.status_code,
|
|
2384
|
+
self._error(types.UploadFile400Error, 400, None),
|
|
2385
|
+
)
|
|
2386
|
+
if response.status_code == 404:
|
|
2387
|
+
raise UploadFileApiError(
|
|
2388
|
+
response.status_code,
|
|
2389
|
+
self._error(types.UploadFile404Error, 404, None),
|
|
2390
|
+
)
|
|
2391
|
+
raise UploadFileApiError(
|
|
2392
|
+
response.status_code,
|
|
2393
|
+
self._error(types.UploadFileDefaultError, response.status_code, None),
|
|
2394
|
+
)
|
|
2395
|
+
|
|
2396
|
+
|
|
2397
|
+
class _PetNamespace:
|
|
2398
|
+
"""\`pet\` operations."""
|
|
2399
|
+
|
|
2400
|
+
def __init__(self, parent: SwaggerPetstoreOpenAPI30) -> None:
|
|
2401
|
+
self._parent = parent
|
|
2402
|
+
|
|
2403
|
+
def add_pet(
|
|
2404
|
+
self,
|
|
2405
|
+
*,
|
|
2406
|
+
name: str,
|
|
2407
|
+
photo_urls: list[str],
|
|
2408
|
+
id: int | None = None,
|
|
2409
|
+
category: types.Category | None = None,
|
|
2410
|
+
tags: list[types.Tag] | None = None,
|
|
2411
|
+
status: types.PetStatus | None = None,
|
|
2412
|
+
) -> types.Pet:
|
|
2413
|
+
"""Add a new pet to the store."""
|
|
2414
|
+
return self._parent._add_pet(
|
|
2415
|
+
name=name,
|
|
2416
|
+
photo_urls=photo_urls,
|
|
2417
|
+
id=id,
|
|
2418
|
+
category=category,
|
|
2419
|
+
tags=tags,
|
|
2420
|
+
status=status,
|
|
2421
|
+
)
|
|
2422
|
+
|
|
2423
|
+
def delete_pet(
|
|
2424
|
+
self,
|
|
2425
|
+
*,
|
|
2426
|
+
pet_id: int,
|
|
2427
|
+
api_key: str | None = None,
|
|
2428
|
+
) -> None:
|
|
2429
|
+
"""Delete a pet."""
|
|
2430
|
+
return self._parent._delete_pet(
|
|
2431
|
+
pet_id=pet_id,
|
|
2432
|
+
api_key=api_key,
|
|
2433
|
+
)
|
|
2434
|
+
|
|
2435
|
+
def find_pets_by_status(
|
|
2436
|
+
self,
|
|
2437
|
+
*,
|
|
2438
|
+
status: Literal["available", "pending", "sold"] | None = None,
|
|
2439
|
+
) -> list[types.Pet]:
|
|
2440
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
2441
|
+
return self._parent._find_pets_by_status(
|
|
2442
|
+
status=status,
|
|
2443
|
+
)
|
|
2444
|
+
|
|
2445
|
+
def find_pets_by_tags(
|
|
2446
|
+
self,
|
|
2447
|
+
*,
|
|
2448
|
+
tags: list[str] | None = None,
|
|
2449
|
+
) -> list[types.Pet]:
|
|
2450
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
2451
|
+
return self._parent._find_pets_by_tags(
|
|
2452
|
+
tags=tags,
|
|
2453
|
+
)
|
|
2454
|
+
|
|
2455
|
+
def get_pet_by_id(
|
|
2456
|
+
self,
|
|
2457
|
+
*,
|
|
2458
|
+
pet_id: int,
|
|
2459
|
+
) -> types.Pet:
|
|
2460
|
+
"""Returns a single pet."""
|
|
2461
|
+
return self._parent._get_pet_by_id(
|
|
2462
|
+
pet_id=pet_id,
|
|
2463
|
+
)
|
|
2464
|
+
|
|
2465
|
+
def update_pet(
|
|
2466
|
+
self,
|
|
2467
|
+
*,
|
|
2468
|
+
name: str,
|
|
2469
|
+
photo_urls: list[str],
|
|
2470
|
+
id: int | None = None,
|
|
2471
|
+
category: types.Category | None = None,
|
|
2472
|
+
tags: list[types.Tag] | None = None,
|
|
2473
|
+
status: types.PetStatus | None = None,
|
|
2474
|
+
) -> types.Pet:
|
|
2475
|
+
"""Update an existing pet by Id."""
|
|
2476
|
+
return self._parent._update_pet(
|
|
2477
|
+
name=name,
|
|
2478
|
+
photo_urls=photo_urls,
|
|
2479
|
+
id=id,
|
|
2480
|
+
category=category,
|
|
2481
|
+
tags=tags,
|
|
2482
|
+
status=status,
|
|
2483
|
+
)
|
|
2484
|
+
|
|
2485
|
+
def update_pet_with_form(
|
|
2486
|
+
self,
|
|
2487
|
+
*,
|
|
2488
|
+
pet_id: int,
|
|
2489
|
+
name: str | None = None,
|
|
2490
|
+
status: str | None = None,
|
|
2491
|
+
) -> types.Pet:
|
|
2492
|
+
"""Updates a pet resource based on the form data."""
|
|
2493
|
+
return self._parent._update_pet_with_form(
|
|
2494
|
+
pet_id=pet_id,
|
|
2495
|
+
name=name,
|
|
2496
|
+
status=status,
|
|
2497
|
+
)
|
|
2498
|
+
|
|
2499
|
+
def upload_file(
|
|
2500
|
+
self,
|
|
2501
|
+
*,
|
|
2502
|
+
pet_id: int,
|
|
2503
|
+
additional_metadata: str | None = None,
|
|
2504
|
+
body: bytes | None = None,
|
|
2505
|
+
) -> types.ApiResponse:
|
|
2506
|
+
"""Upload image of the pet."""
|
|
2507
|
+
return self._parent._upload_file(
|
|
2508
|
+
pet_id=pet_id,
|
|
2509
|
+
additional_metadata=additional_metadata,
|
|
2510
|
+
body=body,
|
|
2511
|
+
)
|
|
2512
|
+
|
|
2513
|
+
|
|
2514
|
+
class _UserNamespace:
|
|
2515
|
+
"""\`user\` operations."""
|
|
2516
|
+
|
|
2517
|
+
def __init__(self, parent: SwaggerPetstoreOpenAPI30) -> None:
|
|
2518
|
+
self._parent = parent
|
|
2519
|
+
|
|
2520
|
+
def create_user(
|
|
2521
|
+
self,
|
|
2522
|
+
*,
|
|
2523
|
+
id: int | None = None,
|
|
2524
|
+
username: str | None = None,
|
|
2525
|
+
first_name: str | None = None,
|
|
2526
|
+
last_name: str | None = None,
|
|
2527
|
+
email: str | None = None,
|
|
2528
|
+
password: str | None = None,
|
|
2529
|
+
phone: str | None = None,
|
|
2530
|
+
user_status: int | None = None,
|
|
2531
|
+
) -> types.User:
|
|
2532
|
+
"""This can only be done by the logged in user."""
|
|
2533
|
+
return self._parent._create_user(
|
|
2534
|
+
id=id,
|
|
2535
|
+
username=username,
|
|
2536
|
+
first_name=first_name,
|
|
2537
|
+
last_name=last_name,
|
|
2538
|
+
email=email,
|
|
2539
|
+
password=password,
|
|
2540
|
+
phone=phone,
|
|
2541
|
+
user_status=user_status,
|
|
2542
|
+
)
|
|
2543
|
+
|
|
2544
|
+
def create_users_with_list_input(
|
|
2545
|
+
self,
|
|
2546
|
+
body: list[types.User] | None = None,
|
|
2547
|
+
) -> types.User:
|
|
2548
|
+
"""Creates list of users with given input array."""
|
|
2549
|
+
return self._parent._create_users_with_list_input(
|
|
2550
|
+
body,
|
|
2551
|
+
)
|
|
2552
|
+
|
|
2553
|
+
def delete_user(
|
|
2554
|
+
self,
|
|
2555
|
+
*,
|
|
2556
|
+
username: str,
|
|
2557
|
+
) -> None:
|
|
2558
|
+
"""This can only be done by the logged in user."""
|
|
2559
|
+
return self._parent._delete_user(
|
|
2560
|
+
username=username,
|
|
2561
|
+
)
|
|
2562
|
+
|
|
2563
|
+
def get_user_by_name(
|
|
2564
|
+
self,
|
|
2565
|
+
*,
|
|
2566
|
+
username: str,
|
|
2567
|
+
) -> types.User:
|
|
2568
|
+
"""Get user detail based on username."""
|
|
2569
|
+
return self._parent._get_user_by_name(
|
|
2570
|
+
username=username,
|
|
2571
|
+
)
|
|
2572
|
+
|
|
2573
|
+
def login_user(
|
|
2574
|
+
self,
|
|
2575
|
+
*,
|
|
2576
|
+
username: str | None = None,
|
|
2577
|
+
password: str | None = None,
|
|
2578
|
+
) -> str:
|
|
2579
|
+
"""Log into the system."""
|
|
2580
|
+
return self._parent._login_user(
|
|
2581
|
+
username=username,
|
|
2582
|
+
password=password,
|
|
2583
|
+
)
|
|
2584
|
+
|
|
2585
|
+
def logout_user(
|
|
2586
|
+
self,
|
|
2587
|
+
) -> None:
|
|
2588
|
+
"""Log user out of the system."""
|
|
2589
|
+
return self._parent._logout_user()
|
|
2590
|
+
|
|
2591
|
+
def update_user(
|
|
2592
|
+
self,
|
|
2593
|
+
*,
|
|
2594
|
+
username: str,
|
|
2595
|
+
body: types.User | None = None,
|
|
2596
|
+
) -> None:
|
|
2597
|
+
"""This can only be done by the logged in user."""
|
|
2598
|
+
return self._parent._update_user(
|
|
2599
|
+
username=username,
|
|
2600
|
+
body=body,
|
|
2601
|
+
)
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
class _StoreNamespace:
|
|
2605
|
+
"""\`store\` operations."""
|
|
2606
|
+
|
|
2607
|
+
def __init__(self, parent: SwaggerPetstoreOpenAPI30) -> None:
|
|
2608
|
+
self._parent = parent
|
|
2609
|
+
|
|
2610
|
+
def delete_order(
|
|
2611
|
+
self,
|
|
2612
|
+
*,
|
|
2613
|
+
order_id: int,
|
|
2614
|
+
) -> None:
|
|
2615
|
+
"""
|
|
2616
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API
|
|
2617
|
+
errors.
|
|
2618
|
+
"""
|
|
2619
|
+
return self._parent._delete_order(
|
|
2620
|
+
order_id=order_id,
|
|
2621
|
+
)
|
|
2622
|
+
|
|
2623
|
+
def get_inventory(
|
|
2624
|
+
self,
|
|
2625
|
+
) -> types.GetInventory200Response:
|
|
2626
|
+
"""Returns a map of status codes to quantities."""
|
|
2627
|
+
return self._parent._get_inventory()
|
|
2628
|
+
|
|
2629
|
+
def get_order_by_id(
|
|
2630
|
+
self,
|
|
2631
|
+
*,
|
|
2632
|
+
order_id: int,
|
|
2633
|
+
) -> types.Order:
|
|
2634
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
2635
|
+
return self._parent._get_order_by_id(
|
|
2636
|
+
order_id=order_id,
|
|
2637
|
+
)
|
|
2638
|
+
|
|
2639
|
+
def place_order(
|
|
2640
|
+
self,
|
|
2641
|
+
*,
|
|
2642
|
+
id: int | None = None,
|
|
2643
|
+
pet_id: int | None = None,
|
|
2644
|
+
quantity: int | None = None,
|
|
2645
|
+
ship_date: datetime.datetime | None = None,
|
|
2646
|
+
status: types.OrderStatus | None = None,
|
|
2647
|
+
complete: bool | None = None,
|
|
2648
|
+
) -> types.Order:
|
|
2649
|
+
"""Place a new order in the store."""
|
|
2650
|
+
return self._parent._place_order(
|
|
2651
|
+
id=id,
|
|
2652
|
+
pet_id=pet_id,
|
|
2653
|
+
quantity=quantity,
|
|
2654
|
+
ship_date=ship_date,
|
|
2655
|
+
status=status,
|
|
2656
|
+
complete=complete,
|
|
2657
|
+
)
|
|
2658
|
+
"
|
|
2659
|
+
`;
|
|
2660
|
+
|
|
2661
|
+
exports[`openApiPyClientGenerator - petstore > should generate valid Python for the full petstore example > types.py 1`] = `
|
|
2662
|
+
""""Types for SwaggerPetstoreOpenAPI30 — AUTO-GENERATED, do not edit."""
|
|
2663
|
+
|
|
2664
|
+
from __future__ import annotations
|
|
2665
|
+
|
|
2666
|
+
import datetime
|
|
2667
|
+
from typing import Literal, TypedDict
|
|
2668
|
+
|
|
2669
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
2670
|
+
|
|
2671
|
+
|
|
2672
|
+
class ApiResponse(BaseModel):
|
|
2673
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2674
|
+
|
|
2675
|
+
code: int | None = None
|
|
2676
|
+
var_type: str | None = Field(default=None, alias="type")
|
|
2677
|
+
message: str | None = None
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
class Category(BaseModel):
|
|
2681
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2682
|
+
|
|
2683
|
+
id: int | None = None
|
|
2684
|
+
name: str | None = None
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
class DeleteOrderRequestPathParameters(BaseModel):
|
|
2688
|
+
"""
|
|
2689
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
|
|
2690
|
+
"""
|
|
2691
|
+
|
|
2692
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2693
|
+
|
|
2694
|
+
order_id: int = Field(
|
|
2695
|
+
alias="orderId", description="ID of the order that needs to be deleted"
|
|
2696
|
+
)
|
|
2697
|
+
|
|
2698
|
+
|
|
2699
|
+
class DeletePetRequestHeaderParameters(BaseModel):
|
|
2700
|
+
"""Delete a pet."""
|
|
2701
|
+
|
|
2702
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2703
|
+
|
|
2704
|
+
api_key: str | None = None
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
class DeletePetRequestPathParameters(BaseModel):
|
|
2708
|
+
"""Delete a pet."""
|
|
2709
|
+
|
|
2710
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2711
|
+
|
|
2712
|
+
pet_id: int = Field(alias="petId", description="Pet id to delete")
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
class DeleteUserRequestPathParameters(BaseModel):
|
|
2716
|
+
"""This can only be done by the logged in user."""
|
|
2717
|
+
|
|
2718
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2719
|
+
|
|
2720
|
+
username: str = Field(description="The name that needs to be deleted")
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
class FindPetsByStatusRequestQueryParameters(BaseModel):
|
|
2724
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
2725
|
+
|
|
2726
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2727
|
+
|
|
2728
|
+
status: Literal["available", "pending", "sold"] | None = Field(
|
|
2729
|
+
default=None, description="Status values that need to be considered for filter"
|
|
2730
|
+
)
|
|
2731
|
+
|
|
2732
|
+
|
|
2733
|
+
class FindPetsByTagsRequestQueryParameters(BaseModel):
|
|
2734
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
2735
|
+
|
|
2736
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2737
|
+
|
|
2738
|
+
tags: list[str] | None = Field(default=None, description="Tags to filter by")
|
|
2739
|
+
|
|
2740
|
+
|
|
2741
|
+
class GetOrderByIdRequestPathParameters(BaseModel):
|
|
2742
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
2743
|
+
|
|
2744
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2745
|
+
|
|
2746
|
+
order_id: int = Field(
|
|
2747
|
+
alias="orderId", description="ID of order that needs to be fetched"
|
|
2748
|
+
)
|
|
2749
|
+
|
|
2750
|
+
|
|
2751
|
+
class GetPetByIdRequestPathParameters(BaseModel):
|
|
2752
|
+
"""Returns a single pet."""
|
|
2753
|
+
|
|
2754
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2755
|
+
|
|
2756
|
+
pet_id: int = Field(alias="petId", description="ID of pet to return")
|
|
2757
|
+
|
|
2758
|
+
|
|
2759
|
+
class GetUserByNameRequestPathParameters(BaseModel):
|
|
2760
|
+
"""Get user detail based on username."""
|
|
2761
|
+
|
|
2762
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2763
|
+
|
|
2764
|
+
username: str = Field(
|
|
2765
|
+
description="The name that needs to be fetched. Use user1 for testing"
|
|
2766
|
+
)
|
|
2767
|
+
|
|
2768
|
+
|
|
2769
|
+
class LoginUserRequestQueryParameters(BaseModel):
|
|
2770
|
+
"""Log into the system."""
|
|
2771
|
+
|
|
2772
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2773
|
+
|
|
2774
|
+
username: str | None = Field(default=None, description="The user name for login")
|
|
2775
|
+
password: str | None = Field(
|
|
2776
|
+
default=None, description="The password for login in clear text"
|
|
2777
|
+
)
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
class Order(BaseModel):
|
|
2781
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2782
|
+
|
|
2783
|
+
id: int | None = None
|
|
2784
|
+
pet_id: int | None = Field(default=None, alias="petId")
|
|
2785
|
+
quantity: int | None = None
|
|
2786
|
+
ship_date: datetime.datetime | None = Field(default=None, alias="shipDate")
|
|
2787
|
+
status: OrderStatus | None = None
|
|
2788
|
+
complete: bool | None = None
|
|
2789
|
+
|
|
2790
|
+
|
|
2791
|
+
class Pet(BaseModel):
|
|
2792
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2793
|
+
|
|
2794
|
+
id: int | None = None
|
|
2795
|
+
name: str
|
|
2796
|
+
category: Category | None = None
|
|
2797
|
+
photo_urls: list[str] = Field(alias="photoUrls")
|
|
2798
|
+
tags: list[Tag] | None = None
|
|
2799
|
+
status: PetStatus | None = None
|
|
2800
|
+
|
|
2801
|
+
|
|
2802
|
+
class Tag(BaseModel):
|
|
2803
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2804
|
+
|
|
2805
|
+
id: int | None = None
|
|
2806
|
+
name: str | None = None
|
|
2807
|
+
|
|
2808
|
+
|
|
2809
|
+
class UpdatePetWithFormRequestPathParameters(BaseModel):
|
|
2810
|
+
"""Updates a pet resource based on the form data."""
|
|
2811
|
+
|
|
2812
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2813
|
+
|
|
2814
|
+
pet_id: int = Field(alias="petId", description="ID of pet that needs to be updated")
|
|
2815
|
+
|
|
2816
|
+
|
|
2817
|
+
class UpdatePetWithFormRequestQueryParameters(BaseModel):
|
|
2818
|
+
"""Updates a pet resource based on the form data."""
|
|
2819
|
+
|
|
2820
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2821
|
+
|
|
2822
|
+
name: str | None = Field(
|
|
2823
|
+
default=None, description="Name of pet that needs to be updated"
|
|
2824
|
+
)
|
|
2825
|
+
status: str | None = Field(
|
|
2826
|
+
default=None, description="Status of pet that needs to be updated"
|
|
2827
|
+
)
|
|
2828
|
+
|
|
2829
|
+
|
|
2830
|
+
class UpdateUserRequestBodyParameters(BaseModel):
|
|
2831
|
+
"""This can only be done by the logged in user."""
|
|
2832
|
+
|
|
2833
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2834
|
+
|
|
2835
|
+
body: User | None = Field(
|
|
2836
|
+
default=None, description="Update an existent user in the store"
|
|
2837
|
+
)
|
|
2838
|
+
|
|
2839
|
+
|
|
2840
|
+
class UpdateUserRequestPathParameters(BaseModel):
|
|
2841
|
+
"""This can only be done by the logged in user."""
|
|
2842
|
+
|
|
2843
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2844
|
+
|
|
2845
|
+
username: str = Field(description="name that need to be deleted")
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
class UploadFileRequestBodyParameters(BaseModel):
|
|
2849
|
+
"""Upload image of the pet."""
|
|
2850
|
+
|
|
2851
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2852
|
+
|
|
2853
|
+
body: bytes | None = None
|
|
2854
|
+
|
|
2855
|
+
|
|
2856
|
+
class UploadFileRequestPathParameters(BaseModel):
|
|
2857
|
+
"""Upload image of the pet."""
|
|
2858
|
+
|
|
2859
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2860
|
+
|
|
2861
|
+
pet_id: int = Field(alias="petId", description="ID of pet to update")
|
|
2862
|
+
|
|
2863
|
+
|
|
2864
|
+
class UploadFileRequestQueryParameters(BaseModel):
|
|
2865
|
+
"""Upload image of the pet."""
|
|
2866
|
+
|
|
2867
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2868
|
+
|
|
2869
|
+
additional_metadata: str | None = Field(
|
|
2870
|
+
default=None, alias="additionalMetadata", description="Additional Metadata"
|
|
2871
|
+
)
|
|
2872
|
+
|
|
2873
|
+
|
|
2874
|
+
class User(BaseModel):
|
|
2875
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
2876
|
+
|
|
2877
|
+
id: int | None = None
|
|
2878
|
+
username: str | None = None
|
|
2879
|
+
first_name: str | None = Field(default=None, alias="firstName")
|
|
2880
|
+
last_name: str | None = Field(default=None, alias="lastName")
|
|
2881
|
+
email: str | None = None
|
|
2882
|
+
password: str | None = None
|
|
2883
|
+
phone: str | None = None
|
|
2884
|
+
user_status: int | None = Field(
|
|
2885
|
+
default=None, alias="userStatus", description="User Status"
|
|
2886
|
+
)
|
|
2887
|
+
|
|
2888
|
+
|
|
2889
|
+
GetInventory200Response = dict[str, int]
|
|
2890
|
+
|
|
2891
|
+
OrderStatus = Literal["placed", "approved", "delivered"]
|
|
2892
|
+
"""Order Status"""
|
|
2893
|
+
|
|
2894
|
+
PetStatus = Literal["available", "pending", "sold"]
|
|
2895
|
+
"""pet status in the store"""
|
|
2896
|
+
|
|
2897
|
+
|
|
2898
|
+
class AddPetRequest(TypedDict):
|
|
2899
|
+
"""Add a new pet to the store."""
|
|
2900
|
+
|
|
2901
|
+
body: Pet
|
|
2902
|
+
|
|
2903
|
+
|
|
2904
|
+
class CreateUserRequest(TypedDict, total=False):
|
|
2905
|
+
"""This can only be done by the logged in user."""
|
|
2906
|
+
|
|
2907
|
+
body: User
|
|
2908
|
+
|
|
2909
|
+
|
|
2910
|
+
class CreateUsersWithListInputRequest(TypedDict, total=False):
|
|
2911
|
+
"""Creates list of users with given input array."""
|
|
2912
|
+
|
|
2913
|
+
body: list[User]
|
|
2914
|
+
|
|
2915
|
+
|
|
2916
|
+
class DeleteOrderRequest(TypedDict):
|
|
2917
|
+
"""
|
|
2918
|
+
For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
|
|
2919
|
+
"""
|
|
2920
|
+
|
|
2921
|
+
order_id: int
|
|
2922
|
+
|
|
2923
|
+
|
|
2924
|
+
class DeletePetRequestRequired(TypedDict):
|
|
2925
|
+
pet_id: int
|
|
2926
|
+
|
|
2927
|
+
|
|
2928
|
+
class DeletePetRequest(DeletePetRequestRequired, total=False):
|
|
2929
|
+
"""Delete a pet."""
|
|
2930
|
+
|
|
2931
|
+
api_key: str
|
|
2932
|
+
|
|
2933
|
+
|
|
2934
|
+
class DeleteUserRequest(TypedDict):
|
|
2935
|
+
"""This can only be done by the logged in user."""
|
|
2936
|
+
|
|
2937
|
+
username: str
|
|
2938
|
+
|
|
2939
|
+
|
|
2940
|
+
class FindPetsByStatusRequest(TypedDict, total=False):
|
|
2941
|
+
"""Multiple status values can be provided with comma separated strings."""
|
|
2942
|
+
|
|
2943
|
+
status: Literal["available", "pending", "sold"]
|
|
2944
|
+
|
|
2945
|
+
|
|
2946
|
+
class FindPetsByTagsRequest(TypedDict, total=False):
|
|
2947
|
+
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
|
|
2948
|
+
|
|
2949
|
+
tags: list[str]
|
|
2950
|
+
|
|
2951
|
+
|
|
2952
|
+
class GetOrderByIdRequest(TypedDict):
|
|
2953
|
+
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions."""
|
|
2954
|
+
|
|
2955
|
+
order_id: int
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
class GetPetByIdRequest(TypedDict):
|
|
2959
|
+
"""Returns a single pet."""
|
|
2960
|
+
|
|
2961
|
+
pet_id: int
|
|
2962
|
+
|
|
2963
|
+
|
|
2964
|
+
class GetUserByNameRequest(TypedDict):
|
|
2965
|
+
"""Get user detail based on username."""
|
|
2966
|
+
|
|
2967
|
+
username: str
|
|
2968
|
+
|
|
2969
|
+
|
|
2970
|
+
class LoginUserRequest(TypedDict, total=False):
|
|
2971
|
+
"""Log into the system."""
|
|
2972
|
+
|
|
2973
|
+
username: str
|
|
2974
|
+
password: str
|
|
2975
|
+
|
|
2976
|
+
|
|
2977
|
+
class PlaceOrderRequest(TypedDict, total=False):
|
|
2978
|
+
"""Place a new order in the store."""
|
|
2979
|
+
|
|
2980
|
+
body: Order
|
|
2981
|
+
|
|
2982
|
+
|
|
2983
|
+
class UpdatePetRequest(TypedDict):
|
|
2984
|
+
"""Update an existing pet by Id."""
|
|
2985
|
+
|
|
2986
|
+
body: Pet
|
|
2987
|
+
|
|
2988
|
+
|
|
2989
|
+
class UpdatePetWithFormRequestRequired(TypedDict):
|
|
2990
|
+
pet_id: int
|
|
2991
|
+
|
|
2992
|
+
|
|
2993
|
+
class UpdatePetWithFormRequest(UpdatePetWithFormRequestRequired, total=False):
|
|
2994
|
+
"""Updates a pet resource based on the form data."""
|
|
2995
|
+
|
|
2996
|
+
name: str
|
|
2997
|
+
status: str
|
|
2998
|
+
|
|
2999
|
+
|
|
3000
|
+
class UpdateUserRequestRequired(TypedDict):
|
|
3001
|
+
username: str
|
|
3002
|
+
|
|
3003
|
+
|
|
3004
|
+
class UpdateUserRequest(UpdateUserRequestRequired, total=False):
|
|
3005
|
+
"""This can only be done by the logged in user."""
|
|
3006
|
+
|
|
3007
|
+
body: User
|
|
3008
|
+
|
|
3009
|
+
|
|
3010
|
+
class UploadFileRequestRequired(TypedDict):
|
|
3011
|
+
pet_id: int
|
|
3012
|
+
|
|
3013
|
+
|
|
3014
|
+
class UploadFileRequest(UploadFileRequestRequired, total=False):
|
|
3015
|
+
"""Upload image of the pet."""
|
|
3016
|
+
|
|
3017
|
+
additional_metadata: str
|
|
3018
|
+
body: bytes
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
class AddPet400Error(BaseModel):
|
|
3022
|
+
"""Error wrapper for AddPet status 400."""
|
|
3023
|
+
|
|
3024
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3025
|
+
|
|
3026
|
+
status: Literal[400]
|
|
3027
|
+
error: None
|
|
3028
|
+
|
|
3029
|
+
|
|
3030
|
+
class AddPet422Error(BaseModel):
|
|
3031
|
+
"""Error wrapper for AddPet status 422."""
|
|
3032
|
+
|
|
3033
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3034
|
+
|
|
3035
|
+
status: Literal[422]
|
|
3036
|
+
error: None
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
class AddPetDefaultError(BaseModel):
|
|
3040
|
+
"""Error wrapper for AddPet status default."""
|
|
3041
|
+
|
|
3042
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3043
|
+
|
|
3044
|
+
status: int
|
|
3045
|
+
error: None
|
|
3046
|
+
|
|
3047
|
+
|
|
3048
|
+
AddPetError = AddPet400Error | AddPet422Error | AddPetDefaultError
|
|
3049
|
+
|
|
3050
|
+
|
|
3051
|
+
class CreateUserDefaultError(BaseModel):
|
|
3052
|
+
"""Error wrapper for CreateUser status default."""
|
|
3053
|
+
|
|
3054
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3055
|
+
|
|
3056
|
+
status: int
|
|
3057
|
+
error: None
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
CreateUserError = CreateUserDefaultError
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
class CreateUsersWithListInputDefaultError(BaseModel):
|
|
3064
|
+
"""Error wrapper for CreateUsersWithListInput status default."""
|
|
3065
|
+
|
|
3066
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3067
|
+
|
|
3068
|
+
status: int
|
|
3069
|
+
error: None
|
|
3070
|
+
|
|
3071
|
+
|
|
3072
|
+
CreateUsersWithListInputError = CreateUsersWithListInputDefaultError
|
|
3073
|
+
|
|
3074
|
+
|
|
3075
|
+
class DeleteOrder400Error(BaseModel):
|
|
3076
|
+
"""Error wrapper for DeleteOrder status 400."""
|
|
3077
|
+
|
|
3078
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3079
|
+
|
|
3080
|
+
status: Literal[400]
|
|
3081
|
+
error: None
|
|
3082
|
+
|
|
3083
|
+
|
|
3084
|
+
class DeleteOrder404Error(BaseModel):
|
|
3085
|
+
"""Error wrapper for DeleteOrder status 404."""
|
|
3086
|
+
|
|
3087
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3088
|
+
|
|
3089
|
+
status: Literal[404]
|
|
3090
|
+
error: None
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
class DeleteOrderDefaultError(BaseModel):
|
|
3094
|
+
"""Error wrapper for DeleteOrder status default."""
|
|
3095
|
+
|
|
3096
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3097
|
+
|
|
3098
|
+
status: int
|
|
3099
|
+
error: None
|
|
3100
|
+
|
|
3101
|
+
|
|
3102
|
+
DeleteOrderError = DeleteOrder400Error | DeleteOrder404Error | DeleteOrderDefaultError
|
|
3103
|
+
|
|
3104
|
+
|
|
3105
|
+
class DeletePet400Error(BaseModel):
|
|
3106
|
+
"""Error wrapper for DeletePet status 400."""
|
|
3107
|
+
|
|
3108
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3109
|
+
|
|
3110
|
+
status: Literal[400]
|
|
3111
|
+
error: None
|
|
3112
|
+
|
|
3113
|
+
|
|
3114
|
+
class DeletePetDefaultError(BaseModel):
|
|
3115
|
+
"""Error wrapper for DeletePet status default."""
|
|
3116
|
+
|
|
3117
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3118
|
+
|
|
3119
|
+
status: int
|
|
3120
|
+
error: None
|
|
3121
|
+
|
|
3122
|
+
|
|
3123
|
+
DeletePetError = DeletePet400Error | DeletePetDefaultError
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
class DeleteUser400Error(BaseModel):
|
|
3127
|
+
"""Error wrapper for DeleteUser status 400."""
|
|
3128
|
+
|
|
3129
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3130
|
+
|
|
3131
|
+
status: Literal[400]
|
|
3132
|
+
error: None
|
|
3133
|
+
|
|
3134
|
+
|
|
3135
|
+
class DeleteUser404Error(BaseModel):
|
|
3136
|
+
"""Error wrapper for DeleteUser status 404."""
|
|
3137
|
+
|
|
3138
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3139
|
+
|
|
3140
|
+
status: Literal[404]
|
|
3141
|
+
error: None
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
class DeleteUserDefaultError(BaseModel):
|
|
3145
|
+
"""Error wrapper for DeleteUser status default."""
|
|
3146
|
+
|
|
3147
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3148
|
+
|
|
3149
|
+
status: int
|
|
3150
|
+
error: None
|
|
3151
|
+
|
|
3152
|
+
|
|
3153
|
+
DeleteUserError = DeleteUser400Error | DeleteUser404Error | DeleteUserDefaultError
|
|
3154
|
+
|
|
3155
|
+
|
|
3156
|
+
class FindPetsByStatus400Error(BaseModel):
|
|
3157
|
+
"""Error wrapper for FindPetsByStatus status 400."""
|
|
3158
|
+
|
|
3159
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3160
|
+
|
|
3161
|
+
status: Literal[400]
|
|
3162
|
+
error: None
|
|
3163
|
+
|
|
3164
|
+
|
|
3165
|
+
class FindPetsByStatusDefaultError(BaseModel):
|
|
3166
|
+
"""Error wrapper for FindPetsByStatus status default."""
|
|
3167
|
+
|
|
3168
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3169
|
+
|
|
3170
|
+
status: int
|
|
3171
|
+
error: None
|
|
3172
|
+
|
|
3173
|
+
|
|
3174
|
+
FindPetsByStatusError = FindPetsByStatus400Error | FindPetsByStatusDefaultError
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
class FindPetsByTags400Error(BaseModel):
|
|
3178
|
+
"""Error wrapper for FindPetsByTags status 400."""
|
|
3179
|
+
|
|
3180
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3181
|
+
|
|
3182
|
+
status: Literal[400]
|
|
3183
|
+
error: None
|
|
3184
|
+
|
|
3185
|
+
|
|
3186
|
+
class FindPetsByTagsDefaultError(BaseModel):
|
|
3187
|
+
"""Error wrapper for FindPetsByTags status default."""
|
|
3188
|
+
|
|
3189
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3190
|
+
|
|
3191
|
+
status: int
|
|
3192
|
+
error: None
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
FindPetsByTagsError = FindPetsByTags400Error | FindPetsByTagsDefaultError
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
class GetInventoryDefaultError(BaseModel):
|
|
3199
|
+
"""Error wrapper for GetInventory status default."""
|
|
3200
|
+
|
|
3201
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3202
|
+
|
|
3203
|
+
status: int
|
|
3204
|
+
error: None
|
|
3205
|
+
|
|
3206
|
+
|
|
3207
|
+
GetInventoryError = GetInventoryDefaultError
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
class GetOrderById400Error(BaseModel):
|
|
3211
|
+
"""Error wrapper for GetOrderById status 400."""
|
|
3212
|
+
|
|
3213
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3214
|
+
|
|
3215
|
+
status: Literal[400]
|
|
3216
|
+
error: None
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
class GetOrderById404Error(BaseModel):
|
|
3220
|
+
"""Error wrapper for GetOrderById status 404."""
|
|
3221
|
+
|
|
3222
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3223
|
+
|
|
3224
|
+
status: Literal[404]
|
|
3225
|
+
error: None
|
|
3226
|
+
|
|
3227
|
+
|
|
3228
|
+
class GetOrderByIdDefaultError(BaseModel):
|
|
3229
|
+
"""Error wrapper for GetOrderById status default."""
|
|
3230
|
+
|
|
3231
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3232
|
+
|
|
3233
|
+
status: int
|
|
3234
|
+
error: None
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
GetOrderByIdError = (
|
|
3238
|
+
GetOrderById400Error | GetOrderById404Error | GetOrderByIdDefaultError
|
|
3239
|
+
)
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
class GetPetById400Error(BaseModel):
|
|
3243
|
+
"""Error wrapper for GetPetById status 400."""
|
|
3244
|
+
|
|
3245
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3246
|
+
|
|
3247
|
+
status: Literal[400]
|
|
3248
|
+
error: None
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
class GetPetById404Error(BaseModel):
|
|
3252
|
+
"""Error wrapper for GetPetById status 404."""
|
|
3253
|
+
|
|
3254
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3255
|
+
|
|
3256
|
+
status: Literal[404]
|
|
3257
|
+
error: None
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
class GetPetByIdDefaultError(BaseModel):
|
|
3261
|
+
"""Error wrapper for GetPetById status default."""
|
|
3262
|
+
|
|
3263
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3264
|
+
|
|
3265
|
+
status: int
|
|
3266
|
+
error: None
|
|
3267
|
+
|
|
3268
|
+
|
|
3269
|
+
GetPetByIdError = GetPetById400Error | GetPetById404Error | GetPetByIdDefaultError
|
|
3270
|
+
|
|
3271
|
+
|
|
3272
|
+
class GetUserByName400Error(BaseModel):
|
|
3273
|
+
"""Error wrapper for GetUserByName status 400."""
|
|
3274
|
+
|
|
3275
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3276
|
+
|
|
3277
|
+
status: Literal[400]
|
|
3278
|
+
error: None
|
|
3279
|
+
|
|
3280
|
+
|
|
3281
|
+
class GetUserByName404Error(BaseModel):
|
|
3282
|
+
"""Error wrapper for GetUserByName status 404."""
|
|
3283
|
+
|
|
3284
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3285
|
+
|
|
3286
|
+
status: Literal[404]
|
|
3287
|
+
error: None
|
|
3288
|
+
|
|
3289
|
+
|
|
3290
|
+
class GetUserByNameDefaultError(BaseModel):
|
|
3291
|
+
"""Error wrapper for GetUserByName status default."""
|
|
3292
|
+
|
|
3293
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3294
|
+
|
|
3295
|
+
status: int
|
|
3296
|
+
error: None
|
|
3297
|
+
|
|
3298
|
+
|
|
3299
|
+
GetUserByNameError = (
|
|
3300
|
+
GetUserByName400Error | GetUserByName404Error | GetUserByNameDefaultError
|
|
3301
|
+
)
|
|
3302
|
+
|
|
3303
|
+
|
|
3304
|
+
class LoginUser400Error(BaseModel):
|
|
3305
|
+
"""Error wrapper for LoginUser status 400."""
|
|
3306
|
+
|
|
3307
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3308
|
+
|
|
3309
|
+
status: Literal[400]
|
|
3310
|
+
error: None
|
|
3311
|
+
|
|
3312
|
+
|
|
3313
|
+
class LoginUserDefaultError(BaseModel):
|
|
3314
|
+
"""Error wrapper for LoginUser status default."""
|
|
3315
|
+
|
|
3316
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3317
|
+
|
|
3318
|
+
status: int
|
|
3319
|
+
error: None
|
|
3320
|
+
|
|
3321
|
+
|
|
3322
|
+
LoginUserError = LoginUser400Error | LoginUserDefaultError
|
|
3323
|
+
|
|
3324
|
+
|
|
3325
|
+
class LogoutUserDefaultError(BaseModel):
|
|
3326
|
+
"""Error wrapper for LogoutUser status default."""
|
|
3327
|
+
|
|
3328
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3329
|
+
|
|
3330
|
+
status: int
|
|
3331
|
+
error: None
|
|
3332
|
+
|
|
3333
|
+
|
|
3334
|
+
LogoutUserError = LogoutUserDefaultError
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
class PlaceOrder400Error(BaseModel):
|
|
3338
|
+
"""Error wrapper for PlaceOrder status 400."""
|
|
3339
|
+
|
|
3340
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3341
|
+
|
|
3342
|
+
status: Literal[400]
|
|
3343
|
+
error: None
|
|
3344
|
+
|
|
3345
|
+
|
|
3346
|
+
class PlaceOrder422Error(BaseModel):
|
|
3347
|
+
"""Error wrapper for PlaceOrder status 422."""
|
|
3348
|
+
|
|
3349
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3350
|
+
|
|
3351
|
+
status: Literal[422]
|
|
3352
|
+
error: None
|
|
3353
|
+
|
|
3354
|
+
|
|
3355
|
+
class PlaceOrderDefaultError(BaseModel):
|
|
3356
|
+
"""Error wrapper for PlaceOrder status default."""
|
|
3357
|
+
|
|
3358
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3359
|
+
|
|
3360
|
+
status: int
|
|
3361
|
+
error: None
|
|
3362
|
+
|
|
3363
|
+
|
|
3364
|
+
PlaceOrderError = PlaceOrder400Error | PlaceOrder422Error | PlaceOrderDefaultError
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
class UpdatePet400Error(BaseModel):
|
|
3368
|
+
"""Error wrapper for UpdatePet status 400."""
|
|
3369
|
+
|
|
3370
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3371
|
+
|
|
3372
|
+
status: Literal[400]
|
|
3373
|
+
error: None
|
|
3374
|
+
|
|
3375
|
+
|
|
3376
|
+
class UpdatePet404Error(BaseModel):
|
|
3377
|
+
"""Error wrapper for UpdatePet status 404."""
|
|
3378
|
+
|
|
3379
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3380
|
+
|
|
3381
|
+
status: Literal[404]
|
|
3382
|
+
error: None
|
|
3383
|
+
|
|
3384
|
+
|
|
3385
|
+
class UpdatePet422Error(BaseModel):
|
|
3386
|
+
"""Error wrapper for UpdatePet status 422."""
|
|
3387
|
+
|
|
3388
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3389
|
+
|
|
3390
|
+
status: Literal[422]
|
|
3391
|
+
error: None
|
|
3392
|
+
|
|
3393
|
+
|
|
3394
|
+
class UpdatePetDefaultError(BaseModel):
|
|
3395
|
+
"""Error wrapper for UpdatePet status default."""
|
|
3396
|
+
|
|
3397
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3398
|
+
|
|
3399
|
+
status: int
|
|
3400
|
+
error: None
|
|
3401
|
+
|
|
3402
|
+
|
|
3403
|
+
UpdatePetError = (
|
|
3404
|
+
UpdatePet400Error | UpdatePet404Error | UpdatePet422Error | UpdatePetDefaultError
|
|
3405
|
+
)
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
class UpdatePetWithForm400Error(BaseModel):
|
|
3409
|
+
"""Error wrapper for UpdatePetWithForm status 400."""
|
|
3410
|
+
|
|
3411
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3412
|
+
|
|
3413
|
+
status: Literal[400]
|
|
3414
|
+
error: None
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
class UpdatePetWithFormDefaultError(BaseModel):
|
|
3418
|
+
"""Error wrapper for UpdatePetWithForm status default."""
|
|
3419
|
+
|
|
3420
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3421
|
+
|
|
3422
|
+
status: int
|
|
3423
|
+
error: None
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
UpdatePetWithFormError = UpdatePetWithForm400Error | UpdatePetWithFormDefaultError
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
class UpdateUser400Error(BaseModel):
|
|
3430
|
+
"""Error wrapper for UpdateUser status 400."""
|
|
3431
|
+
|
|
3432
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3433
|
+
|
|
3434
|
+
status: Literal[400]
|
|
3435
|
+
error: None
|
|
3436
|
+
|
|
3437
|
+
|
|
3438
|
+
class UpdateUser404Error(BaseModel):
|
|
3439
|
+
"""Error wrapper for UpdateUser status 404."""
|
|
3440
|
+
|
|
3441
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3442
|
+
|
|
3443
|
+
status: Literal[404]
|
|
3444
|
+
error: None
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
class UpdateUserDefaultError(BaseModel):
|
|
3448
|
+
"""Error wrapper for UpdateUser status default."""
|
|
3449
|
+
|
|
3450
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3451
|
+
|
|
3452
|
+
status: int
|
|
3453
|
+
error: None
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
UpdateUserError = UpdateUser400Error | UpdateUser404Error | UpdateUserDefaultError
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
class UploadFile400Error(BaseModel):
|
|
3460
|
+
"""Error wrapper for UploadFile status 400."""
|
|
3461
|
+
|
|
3462
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3463
|
+
|
|
3464
|
+
status: Literal[400]
|
|
3465
|
+
error: None
|
|
3466
|
+
|
|
3467
|
+
|
|
3468
|
+
class UploadFile404Error(BaseModel):
|
|
3469
|
+
"""Error wrapper for UploadFile status 404."""
|
|
3470
|
+
|
|
3471
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3472
|
+
|
|
3473
|
+
status: Literal[404]
|
|
3474
|
+
error: None
|
|
3475
|
+
|
|
3476
|
+
|
|
3477
|
+
class UploadFileDefaultError(BaseModel):
|
|
3478
|
+
"""Error wrapper for UploadFile status default."""
|
|
3479
|
+
|
|
3480
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
3481
|
+
|
|
3482
|
+
status: int
|
|
3483
|
+
error: None
|
|
3484
|
+
|
|
3485
|
+
|
|
3486
|
+
UploadFileError = UploadFile400Error | UploadFile404Error | UploadFileDefaultError
|
|
3487
|
+
"
|
|
3488
|
+
`;
|