495 Commits

Author SHA1 Message Date
Laurence de Jong
3dac0646e7 Make discriminators work with multiple keys pointing to the same schema (#1885)
* Make discriminators work with multiple keys pointing to the same schema

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

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

---------

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 20:28:07 +09:00
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
pre-commit-ci[bot]
862a98cb7e [pre-commit.ci] pre-commit autoupdate (#1883)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2)

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-16 14:42:22 +09:00
Nicolas Wicht
e1c795e09a Fix overriden required (#1868)
* reorder required to resolve it's imports

* add tests

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

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

---------

Co-authored-by: fft001 <nicolas.wicht@cognex.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-07 03:04:08 +09:00
Koudai Aono
a4a3a42987 Fix black module error when 19.10b0 is installed (#1855)
* Fix black module error

* Add unittest pattern

* skip unsupported unittest

* skip unsupported unittest
2024-02-14 03:06:56 +09:00
Eric VanDever
ab4a39c139 fix: constraints with a Falsy value should still return a truthful has_constraints (#1844) 2024-02-14 02:32:00 +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
jamesbezuk
f9c1f74b00 Fix object instance comparison. Add test. (#1849)
* Fix object instance comparison. Add test.

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

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

---------

Co-authored-by: James Bezuk <james.bezuk@cognex.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-02-14 01:43:22 +09:00
Etienne Wodey
690cb1281d format: support black >=24 (#1829)
* format: support black >=24

Fixes #1821

* format: refine string_processing detection for black >= 24

* Add test pattern

* Ignore unsupported tests

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2024-02-02 03:07:27 +09:00
Alexander Shadchin
1320fcbf0a Fix #1787 (#1791) 2024-02-02 01:50:30 +09:00
gluap
480779ec5e Stop modifying behavior of yaml on load (#1826)
* Stop modifying behavior of yaml on load

Only modify a copy of ``SafeLoader`` to ensure that we don't change the behaviour of ``pyyaml`` for everyone.

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

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

* Update util.py

Try to address the CodeQL warning.

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

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

* Non-functional commit to trigger the github worklow checks hoping that the codecov isue is resolved.

---------

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-01-31 02:52:17 +09:00
William Jamieson
50a6da1039 Enable ability to use custom JsonSchemaObject in JsonSchemaParser (#1783)
* Move explicit call to `JsonSchemaObject` for parsing to calling a class variable instead.

* Add contrived test

* ignore unittest for pydantic v1

* Fix format

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-12-23 02:26:26 +09:00
Koudai Aono
726b39071e Fix un-imported literal when generate discriminator (#1765)
* Fix un-imported literal when generate discriminator

* Fix target python version
2023-12-21 03:01:02 +09:00
Mike Davidson
3e7d81c819 Improve json_schema_extra to pydanticv2 Field with readOnly/writeOnly (#1778)
* Add json schema extra for pydantic v2 Field with readOnly/writeOnly

* Run formatter

* Fix field

* dump raw extra keys

* remove unused field

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-12-21 02:48:59 +09:00
Koudai Aono
05761b69a2 Support json_schema_extra (#1782)
* Support json_schema_extra

* Fix unittest
2023-12-21 01:41:55 +09:00
Miles Mason Winther
ef15441112 Use const as default (#1767)
* Reproduce bug with unit test

* Use const as default
2023-12-09 13:34:13 +09:00
Koudai Aono
b2b57e728c Fix original_name validation (#1755) 2023-12-04 22:58:21 +09:00
C2D
a46fe94e36 Fix default for annotated field in pydantic v2 (#1498)
* Fix default for annotated field in pydantic v2

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

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

* Move v2 logic to v2 model

---------

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>
2023-11-25 16:04:29 +09:00
mesfahanisimscale
5ccc44145f Support discriminators in array items (#1458)
* setup usecase

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

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

* Support discriminator in array

* Support discriminator in array

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-11-25 04:18:45 +09:00
Gustavo J. A. M. Carneiro
a31148da35 with pydantic v2, use pydantic.AwareDatetime instead of datetime (#1735)
* with pydantic v2, use pydantic.AwareDatetime instead of datetime

Openapi spec says that type string with format "date-time" must have a timezone.
Therefore, we need pydantic.AwareDatetime here.

* Add unittest

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-11-25 02:13:05 +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
ef1f97e017 Close #1719 (#1730)
* Update Scalar.jinja2

* Update Scalar.jinja2 2

* Add test

generation datamodel from github graphql api https://docs.github.com/en/graphql/overview/public-schema

* Fix test test_main_graphql_github_api

* Remove test test_main_graphql_github_api
2023-11-22 23:35:04 +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
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
8b3064bc96 Fix --use-default of allOf (#1708)
* Fix --use-default of allOf

* Add unittest
2023-11-21 02:59:42 +09:00
Koudai Aono
c63b87e5f6 Enable --set-default-enum-member for dataclasses (#1706)
* Enable --set-default-enum-member for dataclasses

* Fix unittest
2023-11-20 02:03:19 +09:00
Koudai Aono
55f8b67f81 Change example to examples in pydantic_v2 (#1705)
* Change example to examples in pydantic_v2

* Change example to examples in pydantic_v2

* Fix unittest
2023-11-20 01:51:07 +09:00
Koudai Aono
0201d3f3c3 Improve one of any of models creation (#1682)
* Improve oneOf anyOf models creation

* fix unit test

* fix unit test

* Remove comments

* Improve combined schemas

* Add test patterns
2023-11-18 03:37:04 +09:00
Koudai Aono
8fa2fade14 Improve collapse_root_models for list (#1700)
* Improve collapse_root_models for list

* Improve Field imports

* Improve Field imports
2023-11-18 00:31:55 +09:00
Koudai Aono
0ffcfd1845 Fix join_url bug when httpx 2.4.0 or later (#1699) 2023-11-16 20:00:28 +09:00
sbussard-vareto
02ebbe19f3 Fix error when JsonSchemaObject is bool with Pydantic v2 (#1691)
* Skips failure

I don't know what the ramifications of this change are, but I know this change seems to skip the error when data classes from json schema

* Add unittest

* Fix unittest

---------

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
2023-11-15 02:55:53 +09:00
Pierre Marsais
4aada4bbef Resolve ref before adding references for allOf items (#1678) 2023-11-10 10:15:05 +09:00
Koudai Aono
8ca47052e8 Remove black in lint.sh and format.sh (#1676) 2023-11-10 03:57:47 +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
7d53b9892e use tomllib in 3.11 or later (#1674)
* use tomllib in 3.11 or later

* Fix types
2023-11-10 00:23:58 +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
Jérôme Boulmier
b7e5d3d2f6 Fix UnionIntFloat json schema generation. (#1669) 2023-11-09 09:59:53 +09:00
Koudai Aono
979444cdd4 Improve discriminator (#1666)
* Improve discriminator

* Improve discriminator

* Fix unittest

* Add unittest

* Fix coverage
2023-11-09 01:16:57 +09:00
Koudai Aono
bb9a20478b add pytest-xdist (#1667)
* add pytest-xdist

* add pytest-xdist

* Fix coverage
2023-11-09 00:33:48 +09:00
Koudai Aono
63cfb53028 Remove constraint on anyurl (#1665) 2023-11-08 02:49:55 +09:00
Koudai Aono
ff63a9806a Fix exponent in minimum (#1664)
* Fix numerical field with an exponent in the minimum

* Add unittest
2023-11-08 01:26:12 +09:00
Koudai Aono
4a244c4e85 Improve model naming (#1663)
* Improve model naming

* Improve model naming
2023-11-07 23:39:40 +09:00
Koudai Aono
2a3d27df82 Move nullable logic to openapi parser (#1655)
* - Move nullable logic to openapi parser
- Add unittest

* Add comments
2023-11-05 02:30:22 +09:00
Tobias Fausten
a4dd6f36eb fix generation of nullable array items (#1648) 2023-11-05 02:07:06 +09:00
Leon Haffmans
775a1c59ad Fix --remove-special-field-name-prefix + fields (e.g. enum members) starting with numbers (#1654)
* Prepend fields with leading numbers with `special_field_name_prefix`

* 📄Change documentation of `--remove-special-field-name-prefix`

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

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

* Missing underscore

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-11-05 00:24:34 +09:00
Koudai Aono
e93a28ee3b Support python 3.12 (#1612)
* Support python 3.12

* Fix deps

* Fix deps

* Fix deps

* Fix deps
2023-10-25 01:00:53 +09:00
Koudai Aono
5fb8b3998c Fix list default in dataclass (#1632)
* Fix list default in dataclass

* Add unittest

* Add unittest
2023-10-23 01:40:02 +09:00
Koudai Aono
39c46f995f Support $defs for Draft 2019-09 (#1630)
* Support $defs

* Add unittest

* Add unittest

* Add unittest
2023-10-22 23:12:34 +09:00
Koudai Aono
339f6c6ab6 Fix msgspec root import (#1611) 2023-10-08 09:35:02 +09:00
Koudai Aono
85f1955cc9 Fix missing constr import issue (#1609)
* Fix missing constr import issue
Add duplicate field constraints test case

* Remove unused imports

* Fix adding imports

* get original field to get imports

* Fix types

* ignore coverage

* Remove unused imports
2023-10-08 01:23:58 +09:00