95 Commits

Author SHA1 Message Date
Brandon Sorensen
33d6666882 Added support for passing pathlib.Path as a format to JSON schema (#1879)
* 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>
2024-03-16 19:57:14 +09:00
Yaroslav Halchenko
2d0f900d5a Add codespell configuration, workflow, pre-commit config and fix few typos (#1842)
* Add github action to codespell main on push and PRs

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>

* Add rudimentary codespell config

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>

* Add pre-commit definition for codespell

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>

* skip tests and dotfiles for codespell

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>

* [DATALAD RUNCMD] run codespell throughout fixing typo automagically

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>

* Fix spells

* Fix config

* pre-commit: exclude tests

---------

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2024-02-14 02:24:36 +09:00
Joseph Richardson
edaa234582 Added graphql to --input-file-type options (#1846)
* Added graphql option to readme

* Removed typo

* Add graphql to --input-file-type in docs/index.md

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2024-02-14 02:14:40 +09:00
Denis Artyushin
16043791b0 Fix docs (#1739) 2023-11-27 01:02:28 +09:00
Denis Artyushin
71718421e4 Add code highlight for docs (#1738) 2023-11-25 22:02:03 +09:00
Denis Artyushin
a36ce94f2d Add custom formatters (#1733)
* 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
2023-11-25 00:59:32 +09:00
Denis Artyushin
c0da688945 Add additional imports to cli (#1723)
* 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
2023-11-22 18:28:24 +09:00
Koudai Aono
cb5c66c077 Update badges (#1718) 2023-11-21 22:44:34 +09:00
Denis Artyushin
6e1de9b970 Beta version graphql (#1707)
* 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
2023-11-21 21:57:50 +09:00
Koudai Aono
74deebd43c Change master to main (#1681)
* Change master to main

* Change master to main
2023-11-11 00:03:02 +09:00
Koudai Aono
cbbe26da46 Change --validation option to optional (#1675)
* Change --validation option to optional

* Fix deps

* Fix deps

* Fix coverage
2023-11-10 01:56:20 +09:00
Koudai Aono
4cfd4676d6 Move pysnooper to optional (#1672)
* Move pysnooper to optional

* Add unittest

* Add unittest

* Add unittest

* Add unittest
2023-11-09 15:06:18 +09:00
Koudai Aono
405b50afe7 Remove build status (#1629)
* Remove build status

* Update index.md
2023-10-21 01:51:02 +09:00
Koudai Aono
60256efafc Add msgspec.Struct to README.md (#1598)
* Add msgspec.Struct to README.md

* Update README.md

* Update index.md

* Update index.md
2023-10-05 17:04:54 +09:00
Tom Crasset
da4cbf589e chore: link to contributing guidelines from README.md (#1561)
* chore: add CONTRIBUTING.md

* docs: add a link from README.md
2023-09-22 01:26:23 +09:00
howardj99
2cae951ffd Organize help options (#1540)
* style: add help option groups and alphabetize

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* chore: add return type

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* chore: revert order of arguments for ease of review

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* chore: shorter usage message, add description

* refactor: add `--no-color` flag

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* test: fix unit tests

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* style: use typing.Optional

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* test: add coverage

* style: address CodeQL notice

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* refactor: extract arg definitions into new module

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* refactor: add models for CLI options

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>

* Revert "refactor: add models for CLI options"

This reverts commit 86b4ca7b33.

---------

Signed-off-by: Jonathan Howard <howard.jonathan.21@gmail.com>
2023-09-15 17:19:47 +09:00
Koudai Aono
1f0a26fa3a Fix generate typo (#1470) 2023-08-03 00:58:28 +09:00
Koudai Aono
6fa0ebcdb9 Add output model type description to documents (#1402) 2023-07-04 09:26:43 +09:00
Koudai Aono
f9270683d0 Add --use-unique-items as set (#1400) 2023-07-03 12:14:40 +09:00
Koudai Aono
dfb601bbcb Add pydantic v2 as output model type (#1391)
* Add pydantic_v2 model module

* Change custom_root_type to root_model

* add unittest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix unittest file

* Fix unittest file

* Support ConfigDict

* Fix type

* Add unittest

* Add unittest

* Add unittest

* Fix unittest

* Fix unittest

* change min/max items to min/max length

* change min/max items to min/max length

* use pattern instead of regex

* remove const

* remove uniqueItems

* WIP

* WIP

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix imports

* Remove unused code

* Fix lint

* Update documents

* Refactor model

* Refactor model

* Fix types

* Fix coverage

* Update documents

* Fix coverage

* Add unittest

* Add unittest

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-07-03 10:54:46 +09:00
Koudai Aono
35b892ce75 Support TypedDict as output type (#1309)
* Support TypedDict as output type

* Addd unittest

* Fix lint

* Support functional typeddict

* Add unittest

* Update unittest

* Add comment

* Update documents

* Improve typedDict keys

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix unittest

* Fix unittest

* Fix lint

* Fix unittest

* Fix unittest

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-01 00:24:23 +09:00
Noddy
2db3745127 Update documentation (#1316)
* 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
2023-05-13 11:38:46 +09:00
Koudai Aono
ba09d77c70 Fix max min round issue (#1235)
* Fix max min round issue

* Change type name

* Fix coverage
2023-04-10 02:57:01 +09:00
Koudai Aono
c56b339a22 Add document for custom template dir option (#1233)
* Create custom_template

* Delete custom_template

* Create custom_template.md

* Update custom_template.md

* Update custom_template.md

* Update custom_template.md

* Update mkdocs.yml
2023-04-09 15:43:15 +09:00
Kamyar
4d8f8e17f0 Fix typo: docuemnt -> document (#1179)
* fix typo in README.md

* typo fix in index.md
2023-03-15 23:51:43 +09:00
Kasper Primdal Lauritzen
1bd814f630 Docs: typo (#1153)
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-03-08 00:33:41 +09:00
Koudai Aono
fcb6d89a34 Support dataclasses.dataclass (#1068)
* Support dataclass

* Fix set_base_classes

* Add CLI option

* Fix set_base_class

* Add cli option

* Fix import

* Add datatypes for dataclass
Add testcase

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dataclass.py

* Update test_main.py

* Fix dataclass field

* Fix coverage

* Update README.md

* Update README.md

* Add unittest

* Add unittest

* Fix coverage

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-07 02:21:38 +09:00
Matt Hambro
4dffe86029 OpenAPI - Add support for query parameter model generation (#1083)
* 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>
2023-02-06 23:29:05 +09:00
Koudai Aono
38f177135f Add --field-extra-keys-without-x-prefix (#1066)
* Add --field-extra-keys-without-x-prefix

* Update README.md
2023-01-31 01:15:24 +09:00
Koudai Aono
5a08106ffb Fix cli option name --use_non_positive_negative_number_constrained_types (#1064) 2023-01-31 00:21:11 +09:00
Koudai Aono
0c47a63c0c Update document (#1044) 2023-01-25 00:00:44 +09:00
Koudai Aono
a019450f53 Add --disable-warnings (#1038) 2023-01-21 03:24:11 +09:00
Koudai Aono
913c251df7 add --remove-special-field-name-prefix (#1033)
* add remove_special_field_name_prefix

* Update documents

* Update README.md

* Update documents
2023-01-20 09:28:27 +09:00
Zack Yancey
45a5031029 Add --use-default-kwarg option for better type checker compatibility (#1034)
* 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>
2023-01-20 08:31:21 +09:00
Koudai Aono
34079734bb Update README.md (#1031)
* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update index.md

* Update README.md

* Update README.md

* Update index.md
2023-01-20 02:13:35 +09:00
Koudai Aono
55b73f91e4 add --capitalise-enum-members option (#970)
* add --capitalise-enum-members option

* Add test files
2022-12-29 01:42:31 +09:00
C2D
c7ee6c84d2 Add collapse root model feature (#933)
* 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>
2022-12-29 00:53:24 +09:00
Koudai Aono
775c8484d2 Support --special-field-name-prefix option (#966)
* Support --special-field-name-prefix option

* Fix type

* Update README.md
2022-12-27 23:31:06 +09:00
Fabian Gebhart
da7e56f158 allow to pass extra fields using --allow-extra-fields (#949) 2022-12-23 00:52:57 +09:00
Dominic-Walther
cc5ce6baf5 Implement field descriptions as docstrings (#918)
* 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>
2022-11-18 00:25:22 +09:00
Bulygin Evgeny
4ed233659c added option --use-double-quotes (#818) 2022-08-12 02:40:15 +09:00
Koudai Aono
ce9bed7b45 Support --original-field-name-delimiter option (#776)
* Support --original-field-name-delimiter option

* add validator for the option
2022-05-27 14:20:06 +09:00
Koudai Aono
7c7e35d869 Support subclass enum (#771)
* Support subclass enum

* Add unittest

* Remove unsued import

* Update documents

* Fix condition

* Update unittest

* Update unittest
2022-05-27 09:20:13 +09:00
Koudai Aono
d706b1ec9f Update documents (#708) 2022-02-09 02:14:52 +09:00
Ian Rodney
9427e76f22 poeyry -> poetry (#702) 2022-02-02 19:53:54 +09:00
Jona Klemenc
e2dcb199fc Use Non{Positive,Negative}{Float,Int} in models (#679)
* 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>
2022-01-18 03:36:00 +09:00
Adam Žurek
5f98cef769 documented installation via pip (#620) 2021-11-29 01:20:02 +09:00
Koudai Aono
ff8be21b83 Support --use-annotated (#516)
* Support --use-annotated

* fix format

* Update documents
2021-08-28 00:12:14 +09:00
Koudai Aono
349f4407a0 Support wrap_string_literal (#493)
* Support wrap_string_literal

* Update documents

* Fix black version for test and lint

* ignore mypy error

* ignore mypy error

* ignore mypy error
2021-08-11 10:16:40 +09:00
Koudai Aono
32a158c4c9 Use Poetry (#475)
* Use Poetry

* Update test.yml

* Update test.yml

* Update test.yml

* fix scripts

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Update test.yml

* Create requirements-docs.txt

* Update docs.yml

* Update publish.yml

* Update documents

* Remove setup.cfg

* Remove mypy.ini

* Fix types

* Update test.yml

* Update test.yml

* Fix lint.sh
2021-08-01 01:57:18 +09:00