Skip to content

don't declare unused variable if model has no properties #1109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

eli-bl
Copy link
Collaborator

@eli-bl eli-bl commented Aug 27, 2024

Fixes #1108.

@eli-bl eli-bl force-pushed the issue-1108-empty-object branch from a43da72 to 3bd2160 Compare August 27, 2024 03:07
@eli-bl eli-bl marked this pull request as ready for review August 27, 2024 03:20
@dbanty dbanty changed the title fix: don't declare unused variable if model has no properties don't declare unused variable if model has no properties Sep 2, 2024
Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another edge-case fix, thanks!!

@dbanty dbanty enabled auto-merge September 2, 2024 19:37
@dbanty dbanty added this pull request to the merge queue Sep 2, 2024
Merged via the queue into openapi-generators:main with commit fc31254 Sep 2, 2024
19 checks passed
@knope-bot knope-bot bot mentioned this pull request Sep 2, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 7, 2024
> [!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 #1109. Thanks @eli-bl!

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generated code fails linting if an object has no properties
2 participants