-
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/pip/ruff-0.4.8
- Loading branch information
Showing
20 changed files
with
370 additions
and
39 deletions.
There are no files selected for viewing
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
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
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
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
37 changes: 37 additions & 0 deletions
37
tests/data/expected/main/discriminator_with_external_reference/output.py
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,37 @@ | ||
# generated by datamodel-codegen: | ||
# filename: schema.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Optional, Union | ||
|
||
from pydantic import BaseModel, Field | ||
from typing_extensions import Literal | ||
|
||
|
||
class Type1(BaseModel): | ||
type_: Literal['a'] = Field('a', title='Type ') | ||
|
||
|
||
class Type2(BaseModel): | ||
type_: Literal['b'] = Field('b', title='Type ') | ||
ref_type: Optional[Type1] = Field(None, description='A referenced type.') | ||
|
||
|
||
class Type4(BaseModel): | ||
type_: Literal['d'] = Field('d', title='Type ') | ||
|
||
|
||
class Type5(BaseModel): | ||
type_: Literal['e'] = Field('e', title='Type ') | ||
|
||
|
||
class Type3(BaseModel): | ||
type_: Literal['c'] = Field('c', title='Type ') | ||
|
||
|
||
class Response(BaseModel): | ||
inner: Union[Type1, Type2, Type3, Type4, Type5] = Field( | ||
..., discriminator='type_', title='Inner' | ||
) |
3 changes: 3 additions & 0 deletions
3
tests/data/expected/main/discriminator_with_external_references_folder/__init__.py
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,3 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_with_external_reference | ||
# timestamp: 2019-07-26T00:00:00+00:00 |
3 changes: 3 additions & 0 deletions
3
...data/expected/main/discriminator_with_external_references_folder/inner_folder/__init__.py
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,3 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_with_external_reference | ||
# timestamp: 2019-07-26T00:00:00+00:00 |
3 changes: 3 additions & 0 deletions
3
.../discriminator_with_external_references_folder/inner_folder/artificial_folder/__init__.py
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,3 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_with_external_reference | ||
# timestamp: 2019-07-26T00:00:00+00:00 |
12 changes: 12 additions & 0 deletions
12
...in/discriminator_with_external_references_folder/inner_folder/artificial_folder/type_1.py
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,12 @@ | ||
# generated by datamodel-codegen: | ||
# filename: inner_folder/artificial_folder/type-1.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, Field | ||
from typing_extensions import Literal | ||
|
||
|
||
class Type1(BaseModel): | ||
type_: Literal['a'] = Field(..., const=True, title='Type ') |
25 changes: 25 additions & 0 deletions
25
...s/data/expected/main/discriminator_with_external_references_folder/inner_folder/schema.py
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,25 @@ | ||
# generated by datamodel-codegen: | ||
# filename: inner_folder/schema.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Union | ||
|
||
from pydantic import BaseModel, Field | ||
from typing_extensions import Literal | ||
|
||
from .. import type_4 | ||
from ..subfolder import type_5 | ||
from . import type_2 | ||
from .artificial_folder import type_1 | ||
|
||
|
||
class Type3(BaseModel): | ||
type_: Literal['c'] = Field(..., const=True, title='Type ') | ||
|
||
|
||
class Response(BaseModel): | ||
inner: Union[type_1.Type1, type_2.Type2, Type3, type_4.Type4, type_5.Type5] = Field( | ||
..., discriminator='type_', title='Inner' | ||
) |
16 changes: 16 additions & 0 deletions
16
...s/data/expected/main/discriminator_with_external_references_folder/inner_folder/type_2.py
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,16 @@ | ||
# generated by datamodel-codegen: | ||
# filename: inner_folder/type-2.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from .artificial_folder import type_1 | ||
|
||
|
||
class Type2(BaseModel): | ||
type_: Literal['b'] = Field(..., const=True, title='Type ') | ||
ref_type: Optional[type_1.Type1] = Field(None, description='A referenced type.') |
3 changes: 3 additions & 0 deletions
3
tests/data/expected/main/discriminator_with_external_references_folder/subfolder/__init__.py
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,3 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_with_external_reference | ||
# timestamp: 2019-07-26T00:00:00+00:00 |
11 changes: 11 additions & 0 deletions
11
tests/data/expected/main/discriminator_with_external_references_folder/subfolder/type_5.py
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,11 @@ | ||
# generated by datamodel-codegen: | ||
# filename: subfolder/type-5.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Type5(BaseModel): | ||
type_: Literal['e'] = Field(..., const=True, title='Type ') |
11 changes: 11 additions & 0 deletions
11
tests/data/expected/main/discriminator_with_external_references_folder/type_4.py
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,11 @@ | ||
# generated by datamodel-codegen: | ||
# filename: type-4.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Type4(BaseModel): | ||
type_: Literal['d'] = Field(..., const=True, title='Type ') |
11 changes: 11 additions & 0 deletions
11
...onschema/discriminator_with_external_reference/inner_folder/artificial_folder/type-1.json
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,11 @@ | ||
{ | ||
"properties": { | ||
"type_": { | ||
"const": "a", | ||
"default": "a", | ||
"title": "Type " | ||
} | ||
}, | ||
"title": "Type1", | ||
"type": "object" | ||
} |
Oops, something went wrong.