forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest_body.py
More file actions
70 lines (64 loc) · 2.72 KB
/
request_body.py
File metadata and controls
70 lines (64 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from typing import Optional
from pydantic import BaseModel, ConfigDict
from .media_type import MediaType
class RequestBody(BaseModel):
"""Describes a single request body.
References:
- https://swagger.io/docs/specification/describing-request-body/
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#requestBodyObject
"""
description: Optional[str] = None
content: dict[str, MediaType]
required: bool = False
model_config = ConfigDict(
# `MediaType` is not build yet, will rebuild in `__init__.py`:
defer_build=True,
extra="allow",
json_schema_extra={
"examples": [
{
"description": "user to add to the system",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/User"},
"examples": {
"user": {
"summary": "User Example",
"externalValue": "http://foo.bar/examples/user-example.json",
}
},
},
"application/xml": {
"schema": {"$ref": "#/components/schemas/User"},
"examples": {
"user": {
"summary": "User example in XML",
"externalValue": "http://foo.bar/examples/user-example.xml",
}
},
},
"text/plain": {
"examples": {
"user": {
"summary": "User example in Plain text",
"externalValue": "http://foo.bar/examples/user-example.txt",
}
}
},
"*/*": {
"examples": {
"user": {
"summary": "User example in other format",
"externalValue": "http://foo.bar/examples/user-example.whatever",
}
}
},
},
},
{
"description": "user to add to the system",
"content": {"text/plain": {"schema": {"type": "array", "items": {"type": "string"}}}},
},
]
},
)