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
When enabled, the generator will output a Pydantic `__root__` class that will contain utilities to visit the union. For example, for the following union type:
99
-
100
-
```
101
-
types:
102
-
Shape:
103
-
union:
104
-
circle: Circle
105
-
triangle: Triangle
106
-
```
107
-
you will get a generated `Shape` class that has a factory and visitor:
When enabled, the python generator will not run Black formatting in the generated code. Black is slow so this can potentially speed up code generation quite a bit.
<Warning>This changes your declared python dependency, which is not meant to be done often if at all. This is a last resort if any dependencies force you to change your version requirements.</Warning>
- `literals`: Use Python Literal types, e.g. `MyEnum = Literal["foo", "bar"]`
186
+
- `forward_compatible_python_enums`: Use Python Enum classes, with a `MyEnum._UNKNOWN` member for forward compatibility. `MyEnum._UNKNOWN.value` contains the raw unrecognized value.
187
+
- `python_enums`: Your vanilla Python enum class, with the members defined within your API.
When enabled, the generator will output a Pydantic `__root__` class that will contain utilities to visit the union. For example, for the following union type:
200
+
201
+
```
202
+
types:
203
+
Shape:
204
+
union:
205
+
circle: Circle
206
+
triangle: Triangle
207
+
```
208
+
you will get a generated `Shape` class that has a factory and visitor:
When enabled, disables Pydantic validation for API responses. This ensures that Pydantic does not immediately fail if the model being returned from an API does not exactly match the Pydantic model.
244
+
245
+
This is meant to add flexibility should your SDK fall behind your API, but should be used sparingly, as the type-hinting for users will still reflect the Pydantic model exactly.
Control union naming strategy. If you are dealing with discriminated union members that already have the discriminant property on them (and they're only used in one union), you should prefer the global API config within your `generators.yml`:
0 commit comments