-
-
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 customTypePath * Fix unittest
- Loading branch information
Showing
7 changed files
with
127 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
tests/data/expected/main/main_jsonschema_custom_type_path/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,36 @@ | ||
# generated by datamodel-codegen: | ||
# filename: custom_type_path.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from custom import MultipleLineString, SpecialString, TitleString | ||
from custom.collection.array import Friends | ||
from custom.special import UpperString | ||
from custom.special.numbers import Age | ||
|
||
|
||
class Person(BaseModel): | ||
class Config: | ||
arbitrary_types_allowed = True | ||
|
||
firstName: Optional[TitleString] = Field( | ||
None, description="The person's first name." | ||
) | ||
lastName: Optional[UpperString] = Field(None, description="The person's last name.") | ||
age: Optional[Age] = Field( | ||
None, description='Age in years which must be equal to or greater than zero.' | ||
) | ||
friends: Optional[Friends] = None | ||
comment: Optional[MultipleLineString] = None | ||
|
||
|
||
class RootedCustomType(BaseModel): | ||
class Config: | ||
arbitrary_types_allowed = True | ||
|
||
__root__: SpecialString |
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 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Person", | ||
"type": "object", | ||
"properties": { | ||
"firstName": { | ||
"type": "string", | ||
"description": "The person's first name.", | ||
"customTypePath": "custom.TitleString" | ||
}, | ||
"lastName": { | ||
"type": "string", | ||
"description": "The person's last name.", | ||
"customTypePath": "custom.special.UpperString" | ||
}, | ||
"age": { | ||
"description": "Age in years which must be equal to or greater than zero.", | ||
"type": "integer", | ||
"minimum": 0, | ||
"customTypePath": "custom.special.numbers.Age" | ||
}, | ||
"friends": { | ||
"type": "array", | ||
"customTypePath": "custom.collection.array.Friends" | ||
}, | ||
"comment": { | ||
"type": "null", | ||
"customTypePath": "custom.MultipleLineString" | ||
} | ||
}, | ||
"definitions": { | ||
"RootedCustomType": { | ||
"type": "string", | ||
"customTypePath": "custom.SpecialString" | ||
} | ||
} | ||
} |
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