datamodel-code-generator 0.11.12__py3-none-any.whl → 0.45.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- datamodel_code_generator/__init__.py +654 -185
- datamodel_code_generator/__main__.py +872 -388
- datamodel_code_generator/arguments.py +798 -0
- datamodel_code_generator/cli_options.py +295 -0
- datamodel_code_generator/format.py +292 -54
- datamodel_code_generator/http.py +85 -10
- datamodel_code_generator/imports.py +152 -43
- datamodel_code_generator/model/__init__.py +138 -1
- datamodel_code_generator/model/base.py +531 -120
- datamodel_code_generator/model/dataclass.py +211 -0
- datamodel_code_generator/model/enum.py +133 -12
- datamodel_code_generator/model/imports.py +22 -0
- datamodel_code_generator/model/msgspec.py +462 -0
- datamodel_code_generator/model/pydantic/__init__.py +30 -25
- datamodel_code_generator/model/pydantic/base_model.py +304 -100
- datamodel_code_generator/model/pydantic/custom_root_type.py +11 -2
- datamodel_code_generator/model/pydantic/dataclass.py +15 -4
- datamodel_code_generator/model/pydantic/imports.py +40 -27
- datamodel_code_generator/model/pydantic/types.py +188 -96
- datamodel_code_generator/model/pydantic_v2/__init__.py +51 -0
- datamodel_code_generator/model/pydantic_v2/base_model.py +268 -0
- datamodel_code_generator/model/pydantic_v2/imports.py +15 -0
- datamodel_code_generator/model/pydantic_v2/root_model.py +35 -0
- datamodel_code_generator/model/pydantic_v2/types.py +143 -0
- datamodel_code_generator/model/scalar.py +124 -0
- datamodel_code_generator/model/template/Enum.jinja2 +15 -2
- datamodel_code_generator/model/template/ScalarTypeAliasAnnotation.jinja2 +6 -0
- datamodel_code_generator/model/template/ScalarTypeAliasType.jinja2 +6 -0
- datamodel_code_generator/model/template/ScalarTypeStatement.jinja2 +6 -0
- datamodel_code_generator/model/template/TypeAliasAnnotation.jinja2 +20 -0
- datamodel_code_generator/model/template/TypeAliasType.jinja2 +20 -0
- datamodel_code_generator/model/template/TypeStatement.jinja2 +20 -0
- datamodel_code_generator/model/template/TypedDict.jinja2 +5 -0
- datamodel_code_generator/model/template/TypedDictClass.jinja2 +25 -0
- datamodel_code_generator/model/template/TypedDictFunction.jinja2 +24 -0
- datamodel_code_generator/model/template/UnionTypeAliasAnnotation.jinja2 +10 -0
- datamodel_code_generator/model/template/UnionTypeAliasType.jinja2 +10 -0
- datamodel_code_generator/model/template/UnionTypeStatement.jinja2 +10 -0
- datamodel_code_generator/model/template/dataclass.jinja2 +50 -0
- datamodel_code_generator/model/template/msgspec.jinja2 +55 -0
- datamodel_code_generator/model/template/pydantic/BaseModel.jinja2 +17 -4
- datamodel_code_generator/model/template/pydantic/BaseModel_root.jinja2 +12 -4
- datamodel_code_generator/model/template/pydantic/Config.jinja2 +1 -1
- datamodel_code_generator/model/template/pydantic/dataclass.jinja2 +15 -2
- datamodel_code_generator/model/template/pydantic_v2/BaseModel.jinja2 +57 -0
- datamodel_code_generator/model/template/pydantic_v2/ConfigDict.jinja2 +5 -0
- datamodel_code_generator/model/template/pydantic_v2/RootModel.jinja2 +48 -0
- datamodel_code_generator/model/type_alias.py +70 -0
- datamodel_code_generator/model/typed_dict.py +161 -0
- datamodel_code_generator/model/types.py +106 -0
- datamodel_code_generator/model/union.py +105 -0
- datamodel_code_generator/parser/__init__.py +30 -12
- datamodel_code_generator/parser/_graph.py +67 -0
- datamodel_code_generator/parser/_scc.py +171 -0
- datamodel_code_generator/parser/base.py +2426 -380
- datamodel_code_generator/parser/graphql.py +652 -0
- datamodel_code_generator/parser/jsonschema.py +2518 -647
- datamodel_code_generator/parser/openapi.py +631 -222
- datamodel_code_generator/py.typed +0 -0
- datamodel_code_generator/pydantic_patch.py +28 -0
- datamodel_code_generator/reference.py +672 -290
- datamodel_code_generator/types.py +521 -145
- datamodel_code_generator/util.py +155 -0
- datamodel_code_generator/watch.py +65 -0
- datamodel_code_generator-0.45.0.dist-info/METADATA +301 -0
- datamodel_code_generator-0.45.0.dist-info/RECORD +69 -0
- {datamodel_code_generator-0.11.12.dist-info → datamodel_code_generator-0.45.0.dist-info}/WHEEL +1 -1
- datamodel_code_generator-0.45.0.dist-info/entry_points.txt +2 -0
- datamodel_code_generator/version.py +0 -1
- datamodel_code_generator-0.11.12.dist-info/METADATA +0 -440
- datamodel_code_generator-0.11.12.dist-info/RECORD +0 -31
- datamodel_code_generator-0.11.12.dist-info/entry_points.txt +0 -3
- {datamodel_code_generator-0.11.12.dist-info → datamodel_code_generator-0.45.0.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: datamodel-code-generator
|
|
3
|
-
Version: 0.11.12
|
|
4
|
-
Summary: Datamodel Code Generator
|
|
5
|
-
Home-page: https://github.com/koxudaxi/datamodel-code-generator
|
|
6
|
-
License: MIT
|
|
7
|
-
Author: Koudai Aono
|
|
8
|
-
Author-email: koxudaxi@gmail.com
|
|
9
|
-
Requires-Python: >=3.6.1,<4.0.0
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
-
Provides-Extra: http
|
|
20
|
-
Requires-Dist: PySnooper (>=0.4.1,<1.0.0)
|
|
21
|
-
Requires-Dist: argcomplete (>=1.10,<2.0)
|
|
22
|
-
Requires-Dist: black (>=19.10b0)
|
|
23
|
-
Requires-Dist: genson (>=1.2.1,<2.0)
|
|
24
|
-
Requires-Dist: httpx; extra == "http"
|
|
25
|
-
Requires-Dist: inflect (>=4.1.0,<6.0)
|
|
26
|
-
Requires-Dist: isort (>=4.3.21,<6.0)
|
|
27
|
-
Requires-Dist: jinja2 (>=2.10.1,<4.0)
|
|
28
|
-
Requires-Dist: openapi-spec-validator (>=0.2.8,<0.4)
|
|
29
|
-
Requires-Dist: prance (>=0.18.2,<1.0)
|
|
30
|
-
Requires-Dist: pydantic[email] (>=1.5.1,<2.0)
|
|
31
|
-
Requires-Dist: regex (!=2021.8.27)
|
|
32
|
-
Requires-Dist: toml (>=0.10.0,<1.0.0)
|
|
33
|
-
Project-URL: Repository, https://github.com/koxudaxi/datamodel-code-generator
|
|
34
|
-
Description-Content-Type: text/markdown
|
|
35
|
-
|
|
36
|
-
# datamodel-code-generator
|
|
37
|
-
|
|
38
|
-
This code generator creates pydantic model from an openapi file and others.
|
|
39
|
-
|
|
40
|
-
[](https://github.com/koxudaxi/datamodel-code-generator/actions?query=workflow%3ATest)
|
|
41
|
-
[](https://pypi.python.org/pypi/datamodel-code-generator)
|
|
42
|
-
[](https://pepy.tech/project/datamodel-code-generator)
|
|
43
|
-
[](https://pypi.python.org/pypi/datamodel-code-generator)
|
|
44
|
-
[](https://codecov.io/gh/koxudaxi/datamodel-code-generator)
|
|
45
|
-

|
|
46
|
-
[](https://github.com/psf/black)
|
|
47
|
-
[](https://lgtm.com/projects/g/koxudaxi/datamodel-code-generator/alerts/)
|
|
48
|
-
[](https://lgtm.com/projects/g/koxudaxi/datamodel-code-generator/context:python)
|
|
49
|
-
|
|
50
|
-
## Help
|
|
51
|
-
See [documentation](https://koxudaxi.github.io/datamodel-code-generator) for more details.
|
|
52
|
-
|
|
53
|
-
## Supported source types
|
|
54
|
-
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types))
|
|
55
|
-
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html)/[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html))
|
|
56
|
-
- JSON/YAML/CSV Data (it will be converted to JSON Schema)
|
|
57
|
-
- Python dictionary (it will be converted to JSON Schema)
|
|
58
|
-
|
|
59
|
-
## Implemented list
|
|
60
|
-
### OpenAPI 3 and JsonSchema
|
|
61
|
-
#### DataType
|
|
62
|
-
- string (include patter/minLength/maxLenght)
|
|
63
|
-
- number (include maximum/exclusiveMaximum/minimum/exclusiveMinimum/multipleOf/le/ge)
|
|
64
|
-
- integer (include maximum/exclusiveMaximum/minimum/exclusiveMinimum/multipleOf/le/ge)
|
|
65
|
-
- boolean
|
|
66
|
-
- array
|
|
67
|
-
- object
|
|
68
|
-
|
|
69
|
-
##### String Format
|
|
70
|
-
- date
|
|
71
|
-
- datetime
|
|
72
|
-
- time
|
|
73
|
-
- password
|
|
74
|
-
- email
|
|
75
|
-
- idn-email
|
|
76
|
-
- uuid (uuid1/uuid2/uuid3/uuid4/uuid5)
|
|
77
|
-
- ipv4
|
|
78
|
-
- ipv6
|
|
79
|
-
- hostname
|
|
80
|
-
- decimal
|
|
81
|
-
|
|
82
|
-
#### Other schema
|
|
83
|
-
- enum (as enum.Enum or typing.Literal)
|
|
84
|
-
- allOf (as Multiple inheritance)
|
|
85
|
-
- anyOf (as typing.Union)
|
|
86
|
-
- oneOf (as typing.Union)
|
|
87
|
-
- $ref ([http extra](#http-extra-option) is required when resolving $ref for remote files.)
|
|
88
|
-
- $id (for [JSONSchema](https://json-schema.org/understanding-json-schema/structuring.html#the-id-property))
|
|
89
|
-
|
|
90
|
-
## Installation
|
|
91
|
-
|
|
92
|
-
To install `datamodel-code-generator`:
|
|
93
|
-
```bash
|
|
94
|
-
$ pip install datamodel-code-generator
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### `http` extra option
|
|
98
|
-
If you want to resolve `$ref` for remote files then you should specify `http` extra option.
|
|
99
|
-
```bash
|
|
100
|
-
$ pip install datamodel-code-generator[http]
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Usage
|
|
104
|
-
|
|
105
|
-
The `datamodel-codegen` command:
|
|
106
|
-
```bash
|
|
107
|
-
usage: datamodel-codegen [-h] [--input INPUT] [--url URL]
|
|
108
|
-
[--http-headers HTTP_HEADER [HTTP_HEADER ...]]
|
|
109
|
-
[--input-file-type {auto,openapi,jsonschema,json,yaml,dict,csv}]
|
|
110
|
-
[--openapi-scopes {schemas,paths} [{schemas,paths} ...]]
|
|
111
|
-
[--output OUTPUT] [--base-class BASE_CLASS]
|
|
112
|
-
[--field-constraints] [--use-annotated]
|
|
113
|
-
[--field-extra-keys FIELD_EXTRA_KEYS [FIELD_EXTRA_KEYS ...]]
|
|
114
|
-
[--field-include-all-keys] [--snake-case-field]
|
|
115
|
-
[--strip-default-none]
|
|
116
|
-
[--disable-appending-item-suffix]
|
|
117
|
-
[--allow-population-by-field-name]
|
|
118
|
-
[--enable-faux-immutability] [--use-default]
|
|
119
|
-
[--force-optional] [--strict-nullable]
|
|
120
|
-
[--strict-types {str,bytes,int,float,bool} [{str,bytes,int,float,bool} ...]]
|
|
121
|
-
[--disable-timestamp] [--use-standard-collections]
|
|
122
|
-
[--use-generic-container-types]
|
|
123
|
-
[--use-schema-description] [--reuse-model]
|
|
124
|
-
[--enum-field-as-literal {all,one}]
|
|
125
|
-
[--set-default-enum-member]
|
|
126
|
-
[--empty-enum-field-name EMPTY_ENUM_FIELD_NAME]
|
|
127
|
-
[--class-name CLASS_NAME] [--use-title-as-name]
|
|
128
|
-
[--custom-template-dir CUSTOM_TEMPLATE_DIR]
|
|
129
|
-
[--extra-template-data EXTRA_TEMPLATE_DATA]
|
|
130
|
-
[--aliases ALIASES]
|
|
131
|
-
[--target-python-version {3.6,3.7,3.8,3.9}]
|
|
132
|
-
[--wrap-string-literal] [--validation]
|
|
133
|
-
[--encoding ENCODING] [--debug] [--version]
|
|
134
|
-
|
|
135
|
-
optional arguments:
|
|
136
|
-
-h, --help show this help message and exit
|
|
137
|
-
--input INPUT Input file/directory (default: stdin)
|
|
138
|
-
--url URL Input file URL. `--input` is ignore when `--url` is
|
|
139
|
-
used
|
|
140
|
-
--http-headers HTTP_HEADER [HTTP_HEADER ...]
|
|
141
|
-
Set headers in HTTP requests to the remote host.
|
|
142
|
-
(example: "Authorization: Basic dXNlcjpwYXNz")
|
|
143
|
-
--input-file-type {auto,openapi,jsonschema,json,yaml,dict,csv}
|
|
144
|
-
Input file type (default: auto)
|
|
145
|
-
--openapi-scopes {schemas,paths} [{schemas,paths} ...]
|
|
146
|
-
Scopes of OpenAPI model generation (default: schemas)
|
|
147
|
-
--output OUTPUT Output file (default: stdout)
|
|
148
|
-
--base-class BASE_CLASS
|
|
149
|
-
Base Class (default: pydantic.BaseModel)
|
|
150
|
-
--field-constraints Use field constraints and not con* annotations
|
|
151
|
-
--use-annotated Use typing.Annotated for Field(). Also, `--field-
|
|
152
|
-
constraints` option will be enabled.
|
|
153
|
-
--field-extra-keys FIELD_EXTRA_KEYS [FIELD_EXTRA_KEYS ...]
|
|
154
|
-
Add extra keys to field parameters
|
|
155
|
-
--field-include-all-keys
|
|
156
|
-
Add all keys to field parameters
|
|
157
|
-
--snake-case-field Change camel-case field name to snake-case
|
|
158
|
-
--strip-default-none Strip default None on fields
|
|
159
|
-
--disable-appending-item-suffix
|
|
160
|
-
Disable appending `Item` suffix to model name in an
|
|
161
|
-
array
|
|
162
|
-
--allow-population-by-field-name
|
|
163
|
-
Allow population by field name
|
|
164
|
-
--enable-faux-immutability
|
|
165
|
-
Enable faux immutability
|
|
166
|
-
--use-default Use default value even if a field is required
|
|
167
|
-
--force-optional Force optional for required fields
|
|
168
|
-
--strict-nullable Treat default field as a non-nullable field (Only
|
|
169
|
-
OpenAPI)
|
|
170
|
-
--strict-types {str,bytes,int,float,bool} [{str,bytes,int,float,bool} ...]
|
|
171
|
-
Use strict types
|
|
172
|
-
--disable-timestamp Disable timestamp on file headers
|
|
173
|
-
--use-standard-collections
|
|
174
|
-
Use standard collections for type hinting (list, dict)
|
|
175
|
-
--use-generic-container-types
|
|
176
|
-
Use generic container types for type hinting
|
|
177
|
-
(typing.Sequence, typing.Mapping). If `--use-standard-
|
|
178
|
-
collections` option is set, then import from
|
|
179
|
-
collections.abc instead of typing
|
|
180
|
-
--use-schema-description
|
|
181
|
-
Use schema description to populate class docstring
|
|
182
|
-
--reuse-model Re-use models on the field when a module has the model
|
|
183
|
-
with the same content
|
|
184
|
-
--enum-field-as-literal {all,one}
|
|
185
|
-
Parse enum field as literal. all: all enum field type
|
|
186
|
-
are Literal. one: field type is Literal when an enum
|
|
187
|
-
has only one possible value
|
|
188
|
-
--set-default-enum-member
|
|
189
|
-
Set enum members as default values for enum field
|
|
190
|
-
--empty-enum-field-name EMPTY_ENUM_FIELD_NAME
|
|
191
|
-
Set field name when enum value is empty (default: `_`)
|
|
192
|
-
--class-name CLASS_NAME
|
|
193
|
-
Set class name of root model
|
|
194
|
-
--use-title-as-name use titles as class names of models
|
|
195
|
-
--custom-template-dir CUSTOM_TEMPLATE_DIR
|
|
196
|
-
Custom template directory
|
|
197
|
-
--extra-template-data EXTRA_TEMPLATE_DATA
|
|
198
|
-
Extra template data
|
|
199
|
-
--aliases ALIASES Alias mapping file
|
|
200
|
-
--target-python-version {3.6,3.7,3.8,3.9}
|
|
201
|
-
target python version (default: 3.7)
|
|
202
|
-
--wrap-string-literal
|
|
203
|
-
Wrap string literal by using black `experimental-
|
|
204
|
-
string-processing` option (require black 20.8b0 or
|
|
205
|
-
later)
|
|
206
|
-
--validation Enable validation (Only OpenAPI)
|
|
207
|
-
--encoding ENCODING The encoding of input and output (default: UTF-8)
|
|
208
|
-
--debug show debug message
|
|
209
|
-
--version show version
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## Example
|
|
213
|
-
### OpenAPI
|
|
214
|
-
```sh
|
|
215
|
-
# Generate models from a local file.
|
|
216
|
-
$ datamodel-codegen --input api.yaml --output model.py
|
|
217
|
-
# or directly from a URL.
|
|
218
|
-
$ datamodel-codegen --url https://<INPUT FILE URL> --output model.py
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
<details>
|
|
222
|
-
<summary>api.yaml</summary>
|
|
223
|
-
|
|
224
|
-
```yaml
|
|
225
|
-
openapi: "3.0.0"
|
|
226
|
-
info:
|
|
227
|
-
version: 1.0.0
|
|
228
|
-
title: Swagger Petstore
|
|
229
|
-
license:
|
|
230
|
-
name: MIT
|
|
231
|
-
servers:
|
|
232
|
-
- url: http://petstore.swagger.io/v1
|
|
233
|
-
paths:
|
|
234
|
-
/pets:
|
|
235
|
-
get:
|
|
236
|
-
summary: List all pets
|
|
237
|
-
operationId: listPets
|
|
238
|
-
tags:
|
|
239
|
-
- pets
|
|
240
|
-
parameters:
|
|
241
|
-
- name: limit
|
|
242
|
-
in: query
|
|
243
|
-
description: How many items to return at one time (max 100)
|
|
244
|
-
required: false
|
|
245
|
-
schema:
|
|
246
|
-
type: integer
|
|
247
|
-
format: int32
|
|
248
|
-
responses:
|
|
249
|
-
'200':
|
|
250
|
-
description: A paged array of pets
|
|
251
|
-
headers:
|
|
252
|
-
x-next:
|
|
253
|
-
description: A link to the next page of responses
|
|
254
|
-
schema:
|
|
255
|
-
type: string
|
|
256
|
-
content:
|
|
257
|
-
application/json:
|
|
258
|
-
schema:
|
|
259
|
-
$ref: "#/components/schemas/Pets"
|
|
260
|
-
default:
|
|
261
|
-
description: unexpected error
|
|
262
|
-
content:
|
|
263
|
-
application/json:
|
|
264
|
-
schema:
|
|
265
|
-
$ref: "#/components/schemas/Error"
|
|
266
|
-
x-amazon-apigateway-integration:
|
|
267
|
-
uri:
|
|
268
|
-
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PythonVersionFunction.Arn}/invocations
|
|
269
|
-
passthroughBehavior: when_no_templates
|
|
270
|
-
httpMethod: POST
|
|
271
|
-
type: aws_proxy
|
|
272
|
-
post:
|
|
273
|
-
summary: Create a pet
|
|
274
|
-
operationId: createPets
|
|
275
|
-
tags:
|
|
276
|
-
- pets
|
|
277
|
-
responses:
|
|
278
|
-
'201':
|
|
279
|
-
description: Null response
|
|
280
|
-
default:
|
|
281
|
-
description: unexpected error
|
|
282
|
-
content:
|
|
283
|
-
application/json:
|
|
284
|
-
schema:
|
|
285
|
-
$ref: "#/components/schemas/Error"
|
|
286
|
-
x-amazon-apigateway-integration:
|
|
287
|
-
uri:
|
|
288
|
-
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PythonVersionFunction.Arn}/invocations
|
|
289
|
-
passthroughBehavior: when_no_templates
|
|
290
|
-
httpMethod: POST
|
|
291
|
-
type: aws_proxy
|
|
292
|
-
/pets/{petId}:
|
|
293
|
-
get:
|
|
294
|
-
summary: Info for a specific pet
|
|
295
|
-
operationId: showPetById
|
|
296
|
-
tags:
|
|
297
|
-
- pets
|
|
298
|
-
parameters:
|
|
299
|
-
- name: petId
|
|
300
|
-
in: path
|
|
301
|
-
required: true
|
|
302
|
-
description: The id of the pet to retrieve
|
|
303
|
-
schema:
|
|
304
|
-
type: string
|
|
305
|
-
responses:
|
|
306
|
-
'200':
|
|
307
|
-
description: Expected response to a valid request
|
|
308
|
-
content:
|
|
309
|
-
application/json:
|
|
310
|
-
schema:
|
|
311
|
-
$ref: "#/components/schemas/Pets"
|
|
312
|
-
default:
|
|
313
|
-
description: unexpected error
|
|
314
|
-
content:
|
|
315
|
-
application/json:
|
|
316
|
-
schema:
|
|
317
|
-
$ref: "#/components/schemas/Error"
|
|
318
|
-
x-amazon-apigateway-integration:
|
|
319
|
-
uri:
|
|
320
|
-
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PythonVersionFunction.Arn}/invocations
|
|
321
|
-
passthroughBehavior: when_no_templates
|
|
322
|
-
httpMethod: POST
|
|
323
|
-
type: aws_proxy
|
|
324
|
-
components:
|
|
325
|
-
schemas:
|
|
326
|
-
Pet:
|
|
327
|
-
required:
|
|
328
|
-
- id
|
|
329
|
-
- name
|
|
330
|
-
properties:
|
|
331
|
-
id:
|
|
332
|
-
type: integer
|
|
333
|
-
format: int64
|
|
334
|
-
name:
|
|
335
|
-
type: string
|
|
336
|
-
tag:
|
|
337
|
-
type: string
|
|
338
|
-
Pets:
|
|
339
|
-
type: array
|
|
340
|
-
items:
|
|
341
|
-
$ref: "#/components/schemas/Pet"
|
|
342
|
-
Error:
|
|
343
|
-
required:
|
|
344
|
-
- code
|
|
345
|
-
- message
|
|
346
|
-
properties:
|
|
347
|
-
code:
|
|
348
|
-
type: integer
|
|
349
|
-
format: int32
|
|
350
|
-
message:
|
|
351
|
-
type: string
|
|
352
|
-
apis:
|
|
353
|
-
type: array
|
|
354
|
-
items:
|
|
355
|
-
type: object
|
|
356
|
-
properties:
|
|
357
|
-
apiKey:
|
|
358
|
-
type: string
|
|
359
|
-
description: To be used as a dataset parameter value
|
|
360
|
-
apiVersionNumber:
|
|
361
|
-
type: string
|
|
362
|
-
description: To be used as a version parameter value
|
|
363
|
-
apiUrl:
|
|
364
|
-
type: string
|
|
365
|
-
format: uri
|
|
366
|
-
description: "The URL describing the dataset's fields"
|
|
367
|
-
apiDocumentationUrl:
|
|
368
|
-
type: string
|
|
369
|
-
format: uri
|
|
370
|
-
description: A URL to the API console for each API
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
</details>
|
|
374
|
-
|
|
375
|
-
`model.py`:
|
|
376
|
-
```python
|
|
377
|
-
# generated by datamodel-codegen:
|
|
378
|
-
# filename: api.yaml
|
|
379
|
-
# timestamp: 2020-06-02T05:28:24+00:00
|
|
380
|
-
|
|
381
|
-
from __future__ import annotations
|
|
382
|
-
|
|
383
|
-
from typing import List, Optional
|
|
384
|
-
|
|
385
|
-
from pydantic import AnyUrl, BaseModel, Field
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
class Pet(BaseModel):
|
|
389
|
-
id: int
|
|
390
|
-
name: str
|
|
391
|
-
tag: Optional[str] = None
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
class Pets(BaseModel):
|
|
395
|
-
__root__: List[Pet]
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
class Error(BaseModel):
|
|
399
|
-
code: int
|
|
400
|
-
message: str
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
class Api(BaseModel):
|
|
404
|
-
apiKey: Optional[str] = Field(
|
|
405
|
-
None, description='To be used as a dataset parameter value'
|
|
406
|
-
)
|
|
407
|
-
apiVersionNumber: Optional[str] = Field(
|
|
408
|
-
None, description='To be used as a version parameter value'
|
|
409
|
-
)
|
|
410
|
-
apiUrl: Optional[AnyUrl] = Field(
|
|
411
|
-
None, description="The URL describing the dataset's fields"
|
|
412
|
-
)
|
|
413
|
-
apiDocumentationUrl: Optional[AnyUrl] = Field(
|
|
414
|
-
None, description='A URL to the API console for each API'
|
|
415
|
-
)
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
class Apis(BaseModel):
|
|
419
|
-
__root__: List[Api]
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
## Related projects
|
|
423
|
-
### fastapi-code-generator
|
|
424
|
-
This code generator creates [FastAPI](https://github.com/tiangolo/fastapi) app from an openapi file.
|
|
425
|
-
|
|
426
|
-
[https://github.com/koxudaxi/fastapi-code-generator](https://github.com/koxudaxi/fastapi-code-generator)
|
|
427
|
-
|
|
428
|
-
### pydantic-pycharm-plugin
|
|
429
|
-
[A JetBrains PyCharm plugin](https://plugins.jetbrains.com/plugin/12861-pydantic) for [`pydantic`](https://github.com/samuelcolvin/pydantic).
|
|
430
|
-
|
|
431
|
-
[https://github.com/koxudaxi/pydantic-pycharm-plugin](https://github.com/koxudaxi/pydantic-pycharm-plugin)
|
|
432
|
-
|
|
433
|
-
## PyPi
|
|
434
|
-
|
|
435
|
-
[https://pypi.org/project/datamodel-code-generator](https://pypi.org/project/datamodel-code-generator)
|
|
436
|
-
|
|
437
|
-
## License
|
|
438
|
-
|
|
439
|
-
datamodel-code-generator is released under the MIT License. http://www.opensource.org/licenses/mit-license
|
|
440
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
datamodel_code_generator/__init__.py,sha256=4VxuYOb1TuiI1GY_CLvfxlj2lbZUyvLg1-XyHJ7kEu8,13107
|
|
2
|
-
datamodel_code_generator/__main__.py,sha256=OLv9FggomDaKcVc4X-nEZYP_SPsyYogDY1SK6_B9k_Q,16555
|
|
3
|
-
datamodel_code_generator/format.py,sha256=QrbAsct-LaLLPwjINvPxikQ2V-3Po9P0ar1avZuuoFU,3430
|
|
4
|
-
datamodel_code_generator/http.py,sha256=Ew-ZyT4q1dl0j93jltuyyBBiNLOfHZgEkuyDvyoT57s,449
|
|
5
|
-
datamodel_code_generator/imports.py,sha256=IL6Rai7AxmC5tRyFerS004nWb8adDCUEaedBAhTpSs8,3115
|
|
6
|
-
datamodel_code_generator/model/__init__.py,sha256=UtIV3s9aDgB4mCwx6aMFM0-SFhHiGhqG12ATGUyWNh4,131
|
|
7
|
-
datamodel_code_generator/model/base.py,sha256=rSaFA-1v_nRFJe5tmLmkXaKp-sF8OX_aviZBDW6t79I,8509
|
|
8
|
-
datamodel_code_generator/model/enum.py,sha256=MvG4KoSIBilhvmDCJXZp3bY1PA0CSbxJo2wmFsRnlPw,1329
|
|
9
|
-
datamodel_code_generator/model/pydantic/__init__.py,sha256=qh9NIkaz-oLgpOit0RrICW7VhMc3DOJr42c73n6Wr9c,1253
|
|
10
|
-
datamodel_code_generator/model/pydantic/base_model.py,sha256=g2zqkfsMTRxcLcqOYt5hfQkJglUk6dZxxNhS3Y-1A1o,5904
|
|
11
|
-
datamodel_code_generator/model/pydantic/custom_root_type.py,sha256=C-KsVN2-iGeMnFakzKmKlp3Xbspx-afCFSeQLC1CpRc,263
|
|
12
|
-
datamodel_code_generator/model/pydantic/dataclass.py,sha256=gFLXubeIEVJi3whQ1R6FBpFTnU5-MxRd-HOg6rJNZuM,388
|
|
13
|
-
datamodel_code_generator/model/pydantic/imports.py,sha256=gmAXrSNUBu6rOuVNArjvXZWzTgazJG8M3ZqsJ79K2fI,1743
|
|
14
|
-
datamodel_code_generator/model/pydantic/types.py,sha256=ow9Ecl4FrwojCv12BbWQs70b-KAxdveCGf1Poxstb-A,10181
|
|
15
|
-
datamodel_code_generator/model/template/Enum.jinja2,sha256=Ruvb2koTN0h0CYm9jVyz15Yh112_ZpJGBqz-Y2bIU1k,253
|
|
16
|
-
datamodel_code_generator/model/template/pydantic/BaseModel.jinja2,sha256=h4acuFltM-dcGLDYnPEgqRTVcEITh4AGWozX0dzVbU4,896
|
|
17
|
-
datamodel_code_generator/model/template/pydantic/BaseModel_root.jinja2,sha256=uJISgApzvNwpj3jb1P6w6HAhi4XRXQDXFLdy9sWeCaY,812
|
|
18
|
-
datamodel_code_generator/model/template/pydantic/Config.jinja2,sha256=mAviPpJKD1xWIkgoUhUZrgianKBOJUoussHKZBZcCo8,134
|
|
19
|
-
datamodel_code_generator/model/template/pydantic/dataclass.jinja2,sha256=rLD1LRweoD-wsmWATDobczyJgV5TQgP0rom7v_powyQ,515
|
|
20
|
-
datamodel_code_generator/parser/__init__.py,sha256=xAioJOwPBX8UeiJHc4wgWEFuzcif9-wZ5fNJAXJDz_I,757
|
|
21
|
-
datamodel_code_generator/parser/base.py,sha256=KB4iuYUUvyIx6qjhYJ4Fln6zk8kA4jbBBeNYpo1WhPc,25248
|
|
22
|
-
datamodel_code_generator/parser/jsonschema.py,sha256=R9ZpbEwyU52SFzh6zjK6DgDEHcy5bmihZq6WkVigv94,48628
|
|
23
|
-
datamodel_code_generator/parser/openapi.py,sha256=LhifmedAmzCYU8mV_4q4XSt4g5ZXFZ6JL12Q0flw1JI,16729
|
|
24
|
-
datamodel_code_generator/reference.py,sha256=O0qheAShqtiJG2ffSsC8Pvw-TFI4trs6Fqttc5mgTRQ,19471
|
|
25
|
-
datamodel_code_generator/types.py,sha256=HzngoTx3Vz3fX2LU12laXM7BdCINRYmlSLZPyYC60iY,10896
|
|
26
|
-
datamodel_code_generator/version.py,sha256=jhVVRxQ_BbjSRS69veQNi71kOHBNQ-BCDE1ENfUnj2g,25
|
|
27
|
-
datamodel_code_generator-0.11.12.dist-info/entry_points.txt,sha256=bykbUWqOCiKfxJPGe8jpNqTqD1NG7uyRmozdnwzu7rk,76
|
|
28
|
-
datamodel_code_generator-0.11.12.dist-info/LICENSE,sha256=K54Lwc6_jduycsy8oFFjQEeSSuEiqvVIjCGIXOMnuTQ,1068
|
|
29
|
-
datamodel_code_generator-0.11.12.dist-info/WHEEL,sha256=N0LZrBtofpkS5mJXgVHTCEy52Sam4D6PHQWC8HnMeTs,83
|
|
30
|
-
datamodel_code_generator-0.11.12.dist-info/METADATA,sha256=r8FF9rK3zEUbghfaONwBPpaHQQE_kJodFt1p29d6mzA,16552
|
|
31
|
-
datamodel_code_generator-0.11.12.dist-info/RECORD,,
|
|
File without changes
|