-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
artsmolin
committed
Dec 18, 2023
1 parent
bbedf9b
commit 71bcc2b
Showing
4 changed files
with
19 additions
and
234 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,2 @@ | ||
# Discriminator | ||
Generate [pydantic classes with discriminators](https://docs.pydantic.dev/latest/api/standard_library_types/#discriminated-unions-aka-tagged-unions) based on [OpenAPI discriminators](https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/). The original OpenAPI specification must have the propertyName and mapping fields. | ||
|
||
### Property safety name | ||
You can explicitly specify the name with which the property will be generated for the data schema. To do this, specify the desired name in the property description in the format `__safety_key__(your_name)`. | ||
|
||
For example, for the original schema with not safety property `event-data` | ||
```yaml | ||
PostObjectData: | ||
title: PostObjectData | ||
type: object | ||
properties: | ||
event-data: | ||
title: Event-Data | ||
type: object | ||
description: __safety_key__(custom_name) | ||
``` | ||
the following class with property `custom_name` will be generated | ||
```python | ||
class PostObjectData(BaseModel): | ||
custom_name: dict = Field(..., alias="event-data", description="__safety_key__(custom_name)") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Property safety name | ||
You can explicitly specify the name with which the property will be generated for the data schema. To do this, specify the desired name in the property description in the format `__safety_key__(your_name)`. | ||
|
||
For example, for the original schema with not safety property `event-data` | ||
```yaml | ||
PostObjectData: | ||
title: PostObjectData | ||
type: object | ||
properties: | ||
event-data: | ||
title: Event-Data | ||
type: object | ||
description: __safety_key__(custom_name) | ||
``` | ||
the following class with property `custom_name` will be generated | ||
```python | ||
class PostObjectData(BaseModel): | ||
custom_name: dict = Field(..., alias="event-data", description="__safety_key__(custom_name)") | ||
``` |