-
-
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 strict-nullable option (#328)
- Loading branch information
Showing
13 changed files
with
344 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# generated by datamodel-codegen: | ||
# filename: nullable.yaml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import AnyUrl, BaseModel, Field | ||
|
||
|
||
class Cursors(BaseModel): | ||
prev: str | ||
next: Optional[str] = 'last' | ||
index: float | ||
|
||
|
||
class TopLevel(BaseModel): | ||
cursors: Cursors | ||
|
||
|
||
class Info(BaseModel): | ||
name: str | ||
|
||
|
||
class User(BaseModel): | ||
info: Info | ||
|
||
|
||
class Api(BaseModel): | ||
apiKey: Optional[str] = Field( | ||
None, description='To be used as a dataset parameter value' | ||
) | ||
apiVersionNumber: Optional[str] = Field( | ||
None, description='To be used as a version parameter value' | ||
) | ||
apiUrl: Optional[AnyUrl] = Field( | ||
None, description="The URL describing the dataset's fields" | ||
) | ||
apiDocumentationUrl: Optional[AnyUrl] = Field( | ||
None, description='A URL to the API console for each API' | ||
) | ||
|
||
|
||
class Apis(BaseModel): | ||
__root__: Optional[List[Api]] = None | ||
|
||
|
||
class EmailItem(BaseModel): | ||
author: str | ||
address: str = Field(..., description='email address') | ||
description: Optional[str] = 'empty' | ||
|
||
|
||
class Email(BaseModel): | ||
__root__: List[EmailItem] | ||
|
||
|
||
class Id(BaseModel): | ||
__root__: int |
58 changes: 58 additions & 0 deletions
58
tests/data/expected/main/main_openapi_nullable_strict_nullable/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,58 @@ | ||
# generated by datamodel-codegen: | ||
# filename: nullable.yaml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import AnyUrl, BaseModel, Field | ||
|
||
|
||
class Cursors(BaseModel): | ||
prev: Optional[str] = Field(...) | ||
next: str = 'last' | ||
index: float | ||
|
||
|
||
class TopLevel(BaseModel): | ||
cursors: Cursors | ||
|
||
|
||
class Info(BaseModel): | ||
name: str | ||
|
||
|
||
class User(BaseModel): | ||
info: Info | ||
|
||
|
||
class Api(BaseModel): | ||
apiKey: str = Field(None, description='To be used as a dataset parameter value') | ||
apiVersionNumber: str = Field( | ||
None, description='To be used as a version parameter value' | ||
) | ||
apiUrl: Optional[AnyUrl] = Field( | ||
None, description="The URL describing the dataset's fields" | ||
) | ||
apiDocumentationUrl: Optional[AnyUrl] = Field( | ||
None, description='A URL to the API console for each API' | ||
) | ||
|
||
|
||
class Apis(BaseModel): | ||
__root__: Optional[List[Api]] = Field(...) | ||
|
||
|
||
class EmailItem(BaseModel): | ||
author: str | ||
address: str = Field(..., description='email address') | ||
description: str = 'empty' | ||
|
||
|
||
class Email(BaseModel): | ||
__root__: List[EmailItem] | ||
|
||
|
||
class Id(BaseModel): | ||
__root__: int |
Oops, something went wrong.