* Added support for passing pathlib.Path as a format to JSON schema
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added unit test
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
* Support custom formatters for CodeFormatter
* Add custom formatters argument
* Add graphql to docs/supported-data-types.md
* Add test
custom formatter for custom-scalar-types.graphql;
* Run poetry run scripts/format.sh
* Add simple doc
* Add new argument `additional-imports`
* Add new argument `additional-imports` to docs
* Add test:
graphql schema with custom imports (using additional-imports argument)
* Fix test test_main_graphql_additional_imports:
to tests for isort 4 and isort 5
* REsolve conflict
* Add scalar data type and template for this
* Add union data type and template for this
* Updater union template
* Add typing.TypeAlias to default imports
* Add graphql parser
* Add first test
* Formatted code style
* Fix for test_main_simple_star_wars
* Use poetry run ./scripts/format.sh
* Fix `typename__` field for graphql object
Set default literal value for `typename__` field
* Add graphql docs
* Add test:
Check all GraphQL field types;
* Add test:
Check custom scalar py type;
* Add test:
Check graphql field aliases;
* Run poetry run ./scripts/format.sh
* Update graphql docs:
Add section `Custom scalar types`;
* poetry run ./scripts/format.sh
* Make small grammatical and phrasing changes, update external like to JSON schema docs, remove unused schema keywords, unify JSON Schema language
* Title case some headers, modify some phrasing, remove duplicate custom template docs, clean up using_as_module with phrasing and removal of redundant ending.
* Add crosslinks between documents for clarity, rephrase sectinos, unify representation of "JSON Schema", remove specifictation of temporary directory use
* Reword "File" to "Data" to include python dicts, update working on project mentions
* Update language from "repositories" to "projects" to include links that are not repos
* Small phrasing update
* Update phrasing of supported data page for clairty
* Unify representation of "JSON", remove redundant information from index
* Synchronize changes between readme and index page
* Standardize formatting, fix heading levels
* Add test for query parameters
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* undo whitespace change
* savepoint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Testing commit
* Modified OpenAPI spec file due to issue #1084
* Create models from query data types
* use get_object_field
* add resolve_object
* Improve parse logic for parameters
* Improve test coverage
* Improve test coverage
* Update README.md
* Fix condition
---------
Co-authored-by: Matt Hambro <matt.hambro@hulu.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Petru Vicol <vicolp1@gmail.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
* Add --use-default-kwarg option for better type checker compatibility
Python 3.11 introduced the `@dataclass_transform` decorator, and older
verisions of python can access the same from the `typing_extensions`
package. This decorator lets type checkers infer the right `__init__`
function for "dataclass-like" classes. It relies on some conventional
keyword arguments to determine whether a given field is a required
argument for `__init__`. Essentially, if the `default=` kwarg is
present, then the field is not required.
Pydantic allows for the `default` argument to be positional, but this
doesn't give the right hints to the type checker. If we set `default` as
a kwarg for fields that do have defaults, then the signature of
`__init__` is inferred correctly.
Example generated code:
```python
# Without --use-default-kwarg: type checkers will assume `b` and `c` are
# required arguments to `__init__`
class Model(BaseModel):
a: str = Field(..., description='Required field')
b: Optional[str] = Field(None, description='Optional field')
c: str = Field("default", description='Another optional field')
# With --use-default-kwarg: type checkers will correctly assume `b` and
# `c` are optional arguments to `__init__`
class Model(BaseModel):
a: str = Field(..., description='Required field')
b: Optional[str] = Field(default=None, description='Optional field')
c: str = Field(default="default", description='Another optional field')
```
* Update README/docs with output of `datamodel-codegen -h`
Co-authored-by: Zack Yancey <mail@zackyancey.com>
* Add collapse root model feature
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove unused root type model
* Update unittest
* ignore coverage
* copy field arguments
* Update documents
Co-authored-by: ferris <ferris@devdroplets.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
* Use schema description to populate field docstring (#857)
* Use schema description to populate field docstring
* Let black do its thing
* Add/improve documentation
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
* Use `Non{Positive,Negative}{Float,Int}` in models
Expands the usage of `{Positive,Negative}{Float,Int}` to also support
`Non{Positive,Negative}{Float,Int}` in code generation.
* Add cli argument to use new constrained types
* fix tests
* revert change on most test files
* - Change CLI option name
- Refactor DataTypes
* Update README.md
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>