Releases: openapi-generators/openapi-python-client
0.21.6 (2024-10-20)
Features
- update Ruff to >=0.2,<0.8 (#1137)
- Add UUID string format. Thanks @estyrke! (#1140)
- Support OpenAPI 3.1 prefixItems property for arrays. Thanks @estyrke! (#1141)
Add literal_enums config setting
Instead of the default Enum classes for enums, you can now generate Literal sets wherever enum appears in the OpenAPI spec by setting literal_enums: true in your config file.
literal_enums: trueThanks to @emosenkis for PR #1114 closes #587, #725, #1076, and probably many more.
Thanks also to @eli-bl, @expobrain, @theorm, @chrisguillory, and anyone else who helped getting to this design!
Fixes
- Typo in docstring (#1128)
Use literal value instead of HTTPStatus enum when checking response statuses
Python 3.13 renamed some of the HTTPStatus enum members, which means clients generated with Python 3.13 may not work
with older versions of Python. This change stops using the HTTPStatus enum directly when checking response statuses.
Statuses will still be checked for validity at generation time, and transformed into HTTPStatus after being checked
at runtime.
This may cause some linters to complain.
0.21.5 (2024-09-07)
Features
Improved property-merging behavior with allOf
When using allOf to extend a base object type, openapi-python-client is now able to handle some kinds of modifications to an existing property that would have previously caused an error:
- Overriding attributes that do not affect validation, such as
description. - Combining properties that this generator ignores, like
maxLengthorpattern. - Combining a generic numeric type with
int(resulting inint). - Adding a
formatto a string. - Combining
anywith a specific type (resulting in that specific type). - Adding or overriding a
default
Note
pattern and max_length are no longer fields on StringProperty, which may impact custom templates.
This also fixes a bug where properties of inline objects (as opposed to references) were not using the
merge logic, but were simply overwriting previous definitions of the same property.
Fixes
- Allow default values for properties of
Anytype
Produce valid code for an object that has no properties at all
0.21.4 (2024-08-25)
Fixes
Correctly resolve references to a type that is itself just a single allOf reference
PR #1103 fixed issue #1091. Thanks @eli-bl!
Allow OpenAPI 3.1-style exclusiveMinimum and exclusiveMaximum
Fixed by PR #1092. Thanks @mikkelam!
Add missing cast import when using const
Fixed by PR #1072. Thanks @dorcohe!
Support const booleans and floats
0.21.3 (2024-08-18)
Features
- update Ruff to >=0.2,<0.7 (#1097)
0.21.2 (2024-07-20)
Features
- Update to Ruff 0.5
0.21.1 (2024-06-15)
Features
Support request body refs
You can now define and reuse bodies via refs, with a document like this:
paths:
/something:
post:
requestBody:
"$ref": "#/components/requestBodies/SharedBody"
components:
requestBodies:
SharedBody:
content:
application/json:
schema:
type: stringThanks to @kigawas and @supermihi for initial implementations and @RockyMM for the initial request.
Closes #633, closes #664, resolves #595.
Fixes
0.21.0 (2024-06-08)
Breaking Changes
Removed the update command
The update command is no more, you can (mostly) replace its usage with some new flags on the generate command.
If you had a package named my-api-client in the current working directory, the update command previously would update the my_api_client module within it. You can now almost perfectly replicate this behavior using openapi-python-client generate --meta=none --output-path=my-api-client/my_api_client --overwrite.
The only difference is that my-api-client would have run post_hooks in the my-api-client directory,
but generate will run post_hooks in the output-path directory.
Alternatively, you can now also run openapi-python-client generate --meta=<your-meta-type> --overwrite to regenerate
the entire client, if you don't care about keeping any changes you've made to the generated client.
Please comment on discussion #824
(or a new discussion, as appropriate) to aid in designing future features that fill any gaps this leaves for you.
Features
Added an --output-path option to generate
Rather than changing directories before running generate you can now specify an output directory with --output-path.
Note that the project name will not be appended to the --output-path, whatever path you specify is where the
generated code will be placed.
Added an --overwrite flag to generate
You can now tell openapi-python-client to overwrite an existing directory, rather than deleting it yourself before
running generate.
0.20.0 (2024-05-18)
Breaking Changes
const values in responses are now validated at runtime
Prior to this version, const values returned from servers were assumed to always be correct. Now, if a server returns
an unexpected value, the client will raise a ValueError. This should enable better usage with oneOf.
PR #1024. Thanks @peter-greenatlas!
Switch YAML parsing to 1.2
This change switches the YAML parsing library to ruamel.yaml which follows the YAML 1.2 specification.
There are breaking changes from YAML 1.1 to 1.2,
though they will not affect most use cases.
PR #1042 fixes #1041. Thanks @rtaycher!
Features
- allow Ruff 0.4 (#1031)
Fixes
Fix nullable and required properties in multipart bodies
Fixes #926.
Warning
This change is likely to break custom templates. Multipart body handling has been completely split from JSON bodies.
0.19.1 (2024-03-27)
Features
Add config option to override content types
You can now define a content_type_overrides field in your config.yml:
content_type_overrides:
application/zip: application/octet-streamThis allows openapi-python-client to generate code for content types it doesn't recognize.
PR #1010 closes #810. Thanks @gaarutyunov!
Fixes
Add aliases to Client for pyright
This should resolve incompatibilities between the generated Client class and the pyright type checker.
PR #1009 closes #909. Thanks @patrick91!
0.19.0 (2024-03-06)
Breaking Changes
Update PDM metadata syntax
Metadata generated for PDM will now use the new distribution = true syntax instead of package-type = "library".
New packages generated with --meta pdm will require PDM 2.12.0 or later to build.
Features
Add response content to UnexpectedStatus exception
The error message for UnexpectedStatus exceptions will now include the UTF-8 decoded (ignoring errors) body of the response.
PR #989 implements #840. Thanks @harabat!
Fixes
Allow hyphens in path parameters
Before now, path parameters which were invalid Python identifiers were not allowed, and would fail generation with an
"Incorrect path templating" error. In particular, this meant that path parameters with hyphens were not allowed.
This has now been fixed!
PR #986 fixed issue #976. Thanks @harabat!
Warning
This change may break custom templates, see this diff
if you have trouble upgrading.