-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pyproject.toml detection when
[tool.black]
section is omitted (#…
…2242) * Use custom pyproject.toml resolution instead of black's When loading its configuration, datamodel-codegen now searches for pyproject.toml files with [tool.datamodel-codegen] sections independently, rather than relying on black's project root detection (which fails if a [tool.black] section is not present). * Add tests for pyproject.toml configuration handling * Switch contextlib.chdir to datamodel_code_generator.chdir in test * Ignore old black version --------- Co-authored-by: Koudai Aono <[email protected]>
- Loading branch information
Showing
3 changed files
with
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# generated by datamodel-codegen: | ||
# filename: api.yaml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import AnyUrl, BaseModel, Field, StrictStr | ||
|
||
|
||
class Pet(BaseModel): | ||
id: int | ||
name: StrictStr | ||
tag: Optional[StrictStr] = None | ||
|
||
|
||
class Pets(BaseModel): | ||
__root__: List[Pet] | ||
|
||
|
||
class User(BaseModel): | ||
id: int | ||
name: StrictStr | ||
tag: Optional[StrictStr] = None | ||
|
||
|
||
class Users(BaseModel): | ||
__root__: List[User] | ||
|
||
|
||
class Id(BaseModel): | ||
__root__: StrictStr | ||
|
||
|
||
class Rules(BaseModel): | ||
__root__: List[StrictStr] | ||
|
||
|
||
class Error(BaseModel): | ||
code: int | ||
message: StrictStr | ||
|
||
|
||
class Api(BaseModel): | ||
apiKey: Optional[StrictStr] = Field( | ||
None, description='To be used as a dataset parameter value' | ||
) | ||
apiVersionNumber: Optional[StrictStr] = 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__: List[Api] | ||
|
||
|
||
class Event(BaseModel): | ||
name: Optional[StrictStr] = None | ||
|
||
|
||
class Result(BaseModel): | ||
event: Optional[Event] = 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