-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support subclass enum * Add unittest * Remove unsued import * Update documents * Fix condition * Update unittest * Update unittest
- Loading branch information
Showing
12 changed files
with
230 additions
and
12 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
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
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
53 changes: 53 additions & 0 deletions
53
tests/data/expected/main/main_jsonschema_subclass_enum/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,53 @@ | ||
# generated by datamodel-codegen: | ||
# filename: subclass_enum.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class IntEnum(int, Enum): | ||
integer_1 = 1 | ||
integer_2 = 2 | ||
integer_3 = 3 | ||
|
||
|
||
class FloatEnum(float, Enum): | ||
number_1_1 = 1.1 | ||
number_2_1 = 2.1 | ||
number_3_1 = 3.1 | ||
|
||
|
||
class StrEnum(str, Enum): | ||
field_1 = '1' | ||
field_2 = '2' | ||
field_3 = '3' | ||
|
||
|
||
class NonTypedEnum(Enum): | ||
field_1 = '1' | ||
field_2 = '2' | ||
field_3 = '3' | ||
|
||
|
||
class BooleanEnum(Enum): | ||
boolean_True = True | ||
boolean_False = False | ||
|
||
|
||
class UnknownEnum(Enum): | ||
a = 'a' | ||
b = 'b' | ||
|
||
|
||
class Model(BaseModel): | ||
IntEnum: Optional[IntEnum] = None | ||
FloatEnum: Optional[FloatEnum] = None | ||
StrEnum: Optional[StrEnum] = None | ||
NonTypedEnum: Optional[NonTypedEnum] = None | ||
BooleanEnum: Optional[BooleanEnum] = None | ||
UnknownEnum: Optional[UnknownEnum] = None |
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,51 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"IntEnum": { | ||
"type": "integer", | ||
"enum": [ | ||
1, | ||
2, | ||
3 | ||
] | ||
}, | ||
"FloatEnum": { | ||
"type": "number", | ||
"enum": [ | ||
1.1, | ||
2.1, | ||
3.1 | ||
] | ||
}, | ||
"StrEnum": { | ||
"type": "string", | ||
"enum": [ | ||
"1", | ||
"2", | ||
"3" | ||
] | ||
}, | ||
"NonTypedEnum": { | ||
"enum": [ | ||
"1", | ||
"2", | ||
"3" | ||
] | ||
}, | ||
"BooleanEnum": { | ||
"type": "boolean", | ||
"enum": [ | ||
true, | ||
false | ||
] | ||
}, | ||
"UnknownEnum": { | ||
"type": "unknown", | ||
"enum": [ | ||
"a", | ||
"b" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.