You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cli-reference/quick-reference.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ datamodel-codegen [OPTIONS]
29
29
|[`--allof-merge-mode`](typing-customization.md#allof-merge-mode)| Merge constraints from root model references in allOf schemas. |
30
30
|[`--disable-future-imports`](typing-customization.md#disable-future-imports)| Prevent automatic addition of __future__ imports in generated code. |
31
31
|[`--enum-field-as-literal`](typing-customization.md#enum-field-as-literal)| Convert all enum fields to Literal types instead of Enum classes. |
32
+
|[`--ignore-enum-constraints`](typing-customization.md#ignore-enum-constraints)| Ignore enum constraints and use base string type instead of Enum classes. |
1. :material-arrow-left: `--ignore-enum-constraints` - the option documented here
1211
+
1212
+
??? example "Examples"
1213
+
1214
+
**Input Schema:**
1215
+
1216
+
```graphql
1217
+
"Employee shift status"
1218
+
enum EmployeeShiftStatus {
1219
+
"not on shift"
1220
+
NOT_ON_SHIFT
1221
+
"on shift"
1222
+
ON_SHIFT
1223
+
}
1224
+
1225
+
enum Color {
1226
+
RED
1227
+
GREEN
1228
+
BLUE
1229
+
}
1230
+
1231
+
enum EnumWithOneField {
1232
+
FIELD
1233
+
}
1234
+
```
1235
+
1236
+
**Output:**
1237
+
1238
+
=== "With Option"
1239
+
1240
+
```python
1241
+
# generated by datamodel-codegen:
1242
+
# filename: enums.graphql
1243
+
# timestamp: 2019-07-26T00:00:00+00:00
1244
+
1245
+
from __future__ import annotations
1246
+
1247
+
from pydantic import BaseModel
1248
+
from typing_extensions import TypeAlias
1249
+
1250
+
Boolean: TypeAlias = bool
1251
+
"""
1252
+
The `Boolean` scalar type represents `true` or `false`.
1253
+
"""
1254
+
1255
+
1256
+
String: TypeAlias = str
1257
+
"""
1258
+
The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
1259
+
"""
1260
+
1261
+
1262
+
class Color(BaseModel):
1263
+
__root__: str
1264
+
1265
+
1266
+
class EmployeeShiftStatus(BaseModel):
1267
+
"""
1268
+
Employee shift status
1269
+
"""
1270
+
1271
+
__root__: str
1272
+
1273
+
1274
+
class EnumWithOneField(BaseModel):
1275
+
__root__: str
1276
+
```
1277
+
1278
+
=== "Without Option"
1279
+
1280
+
```python
1281
+
# generated by datamodel-codegen:
1282
+
# filename: enums.graphql
1283
+
# timestamp: 2019-07-26T00:00:00+00:00
1284
+
1285
+
from __future__ import annotations
1286
+
1287
+
from enum import Enum
1288
+
1289
+
from typing_extensions import TypeAlias
1290
+
1291
+
Boolean: TypeAlias = bool
1292
+
"""
1293
+
The `Boolean` scalar type represents `true` or `false`.
1294
+
"""
1295
+
1296
+
1297
+
String: TypeAlias = str
1298
+
"""
1299
+
The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
0 commit comments