Skip to content

Tags: bagerard/openapi-python-client

Tags

v0.21.5

Toggle v0.21.5's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release 0.21.5 (openapi-generators#1115)

> [!IMPORTANT]
> Merging this pull request will create this release

## 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 `maxLength` or
`pattern`.
- Combining a generic numeric type with `int` (resulting in `int`).
- Adding a `format` to a string.
- Combining `any` with 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 `Any` type

### Produce valid code for an object that has no properties at all

Fixed by PR openapi-generators#1109. Thanks @eli-bl!

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>

v0.21.4

Toggle v0.21.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release 0.21.4 (openapi-generators#1106)

> [!IMPORTANT]
> Merging this pull request will create this release

## Fixes

### Allow OpenAPI 3.1-style `exclusiveMinimum` and `exclusiveMaximum`

Fixed by PR openapi-generators#1092. Thanks @mikkelam!

### Add missing `cast` import when using `const`

Fixed by PR openapi-generators#1072. Thanks @dorcohe!

### Correctly resolve references to a type that is itself just a single
allOf reference

PR openapi-generators#1103 fixed issue openapi-generators#1091. Thanks @eli-bl!

### Support `const` booleans and floats

Fixed in PR openapi-generators#1086. Thanks @flxdot!

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>

v0.21.3

Toggle v0.21.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Release 0.21.3 (openapi-generators#1100)

> [!IMPORTANT]
> Merging this pull request will create this release

## Features

- update Ruff to >=0.2,<0.7 (openapi-generators#1097)

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>

v0.21.2

Toggle v0.21.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.21.2 (openapi-generators#1079)

This PR was created by Knope. Merging it will create a new release

### Features

- Update to Ruff 0.5

Co-authored-by: GitHub <github-actions@github.com>

v0.21.1

Toggle v0.21.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.21.1 (openapi-generators#1056)

This PR was created by Knope. Merging it will create a new release

### Features

#### Support request body refs

You can now define and reuse bodies via refs, with a document like this:

```yaml
paths:
  /something:
    post:
      requestBody:
        "$ref": "#/components/requestBodies/SharedBody"
components:
  requestBodies:
    SharedBody:
      content:
        application/json:
          schema:
            type: string
```

Thanks to @kigawas and @supermihi for initial implementations and
@RockyMM for the initial request.

Closes openapi-generators#633, closes openapi-generators#664, resolves openapi-generators#595.

### Fixes

- Indent of generated code for non-required lists. Thanks @sfowl!
(openapi-generators#1050)
- Parsing requestBody with $ref (openapi-generators#633)

Co-authored-by: GitHub <github-actions@github.com>

v0.21.0

Toggle v0.21.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.21.0 (openapi-generators#1053)

This PR was created by Knope. Merging it will create a new release

### 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
openapi-generators#824](openapi-generators#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`.

Co-authored-by: GitHub <github-actions@github.com>

v0.20.0

Toggle v0.20.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.20.0 (openapi-generators#1032)

This PR was created by Knope. Merging it will create a new release

### 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 openapi-generators#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](https://yaml.readthedocs.io/en/latest/pyyaml/#defaulting-to-yaml-12-support)
from YAML 1.1 to 1.2,
though they will not affect most use cases.

PR openapi-generators#1042 fixes openapi-generators#1041. Thanks @rtaycher!

### Features

- allow Ruff 0.4 (openapi-generators#1031)

### Fixes

#### Fix nullable and required properties in multipart bodies

Fixes openapi-generators#926.

> [!WARNING]
> This change is likely to break custom templates. Multipart body
handling has been completely split from JSON bodies.

Co-authored-by: GitHub <github-actions@github.com>

v0.19.1

Toggle v0.19.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.19.1 (openapi-generators#1015)

This PR was created by Knope. Merging it will create a new release

### Features

#### Add config option to override content types

You can now define a `content_type_overrides` field in your
`config.yml`:

```yaml
content_type_overrides:
  application/zip: application/octet-stream
```

This allows `openapi-python-client` to generate code for content types
it doesn't recognize.

PR openapi-generators#1010 closes openapi-generators#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 openapi-generators#1009 closes openapi-generators#909. Thanks @patrick91!

Co-authored-by: GitHub <github-actions@github.com>

v0.19.0

Toggle v0.19.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.19.0 (openapi-generators#990)

This PR was created by Knope. Merging it will create a new release

### 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 openapi-generators#989 implements openapi-generators#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 openapi-generators#986 fixed issue openapi-generators#976. Thanks @harabat!

> [!WARNING]
> This change may break custom templates, see [this
diff](https://github.com/openapi-generators/openapi-python-client/pull/986/files#diff-0de8437b26075d8fe8454cf47d8d95d4835c7f827fa87328e03f690412be803e)
> if you have trouble upgrading.

Co-authored-by: GitHub <github-actions@github.com>

v0.18.0

Toggle v0.18.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
chore: prepare release 0.18.0 (openapi-generators#975)

This PR was created by Knope. Merging it will create a new release

### Breaking Changes

#### For custom templates, changed type of endpoint parameters

**This does not affect projects that are not using
`--custom-template-path`**

The type of these properties on `Endpoint` has been changed from
`Dict[str, Property]` to `List[Property]`:

- `path_parameters`
- `query_parameters`
- `header_parameters`
- `cookie_parameters`

If your templates are very close to the default templates, you can
probably just remove `.values()` anywhere it appears.

The type of `iter_all_parameters()` is also different, you probably want
`list_all_parameters()` instead.

#### Updated generated config for Ruff v0.2

This only affects projects using the `generate` command, not the
`update` command. The `pyproject.toml` file generated which configures
Ruff for linting and formatting has been updated to the 0.2 syntax,
which means it will no longer work with Ruff 0.1.

#### Updated naming strategy for conflicting properties

While fixing openapi-generators#922, some naming strategies were updated. These should
mostly be backwards compatible, but there may be
some small differences in generated code. Make sure to check your diffs
before pushing updates to consumers!

### Features

#### support httpx 0.27 (openapi-generators#974)

### Fixes

#### Allow parameters with names differing only by case

If you have two parameters to an endpoint named `mixedCase` and
`mixed_case`, previously, this was a conflict and the endpoint would not
be generated.
Now, the generator will skip snake-casing the parameters and use the
names as-is. Note that this means if neither of the parameters _was_
snake case, neither _will be_ in the generated code.

Fixes openapi-generators#922 reported by @macmoritz & @benedikt-bartscher.

#### Fix naming conflicts with properties in models with mixed casing

If you had an object with two properties, where the names differed only
by case, conflicting properties would be generated in the model, which
then failed the linting step (when using default config). For example,
this:

```yaml
type: "object"
properties:
  MixedCase:
    type: "string"
  mixedCase:
    type: "string"
```

Would generate a class like this:

```python
class MyModel:
    mixed_case: str
    mixed_case: str
```

Now, neither of the properties will be forced into snake case, and the
generated code will look like this:

```python
class MyModel:
    MixedCase: str
    mixedCase: str
```

Co-authored-by: GitHub <github-actions@github.com>