forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse.py
61 lines (55 loc) · 2.4 KB
/
response.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from typing import Optional
from pydantic import BaseModel, ConfigDict
from .header import Header
from .link import Link
from .media_type import MediaType
from .reference import ReferenceOr
class Response(BaseModel):
"""
Describes a single response from an API Operation, including design-time,
static `links` to operations based on the response.
References:
- https://swagger.io/docs/specification/describing-responses/
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responseObject
"""
description: str
headers: Optional[dict[str, ReferenceOr[Header]]] = None
content: Optional[dict[str, MediaType]] = None
links: Optional[dict[str, ReferenceOr[Link]]] = None
model_config = ConfigDict(
# `MediaType` is not build yet, will rebuild in `__init__.py`:
defer_build=True,
extra="allow",
json_schema_extra={
"examples": [
{
"description": "A complex object array response",
"content": {
"application/json": {
"schema": {"type": "array", "items": {"$ref": "#/components/schemas/VeryComplexType"}}
}
},
},
{"description": "A simple string response", "content": {"text/plain": {"schema": {"type": "string"}}}},
{
"description": "A simple string response",
"content": {"text/plain": {"schema": {"type": "string", "example": "whoa!"}}},
"headers": {
"X-Rate-Limit-Limit": {
"description": "The number of allowed requests in the current period",
"schema": {"type": "integer"},
},
"X-Rate-Limit-Remaining": {
"description": "The number of remaining requests in the current period",
"schema": {"type": "integer"},
},
"X-Rate-Limit-Reset": {
"description": "The number of seconds left in the current period",
"schema": {"type": "integer"},
},
},
},
{"description": "object created"},
]
},
)