Skip to content
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

feat: Allow any Mapping in generated from_dict functions #1211

Merged
merged 3 commits into from
Mar 15, 2025

Conversation

edgarrmondragon
Copy link
Contributor

Closes #1203

@edgarrmondragon edgarrmondragon marked this pull request as ready for review March 3, 2025 01:47
@edgarrmondragon edgarrmondragon changed the title fix: Expect a generic Mapping in generated from_dict fix!: Expect a generic Mapping in generated from_dict Mar 3, 2025
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.

LGTM and I don't think it'll even be a breaking change since a dict is a Mapping. Just one leftover import can be removed

edgarrmondragon and others added 2 commits March 15, 2025 11:45
Co-authored-by: Dylan Anthony <43723790+dbanty@users.noreply.github.com>
@dbanty dbanty changed the title fix!: Expect a generic Mapping in generated from_dict feat: Allow any Mapping in generated from_dict functions Mar 15, 2025
@dbanty dbanty added this pull request to the merge queue Mar 15, 2025
Merged via the queue into openapi-generators:main with commit b8fbea9 Mar 15, 2025
22 checks passed
@knope-bot knope-bot bot mentioned this pull request Mar 15, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 15, 2025
> [!IMPORTANT]
> Merging this pull request will create this release

## Features

- allow Ruff to 0.10 (#1220)
- allow Ruff 0.11 (#1222)
- Allow any `Mapping` in generated `from_dict` functions (#1211)

## Fixes

### Always parse `$ref` as a reference

If additional attributes were included with a `$ref` (for example
`title` or `description`), the property could be
interpreted as a new type instead of a reference, usually resulting in
`Any` in the generated code.
Now, any sibling properties to `$ref` will properly be ignored, as per
the OpenAPI specification.

Thanks @nkrishnaswami!

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
@edgarrmondragon
Copy link
Contributor Author

Thanks @dbanty !

@edgarrmondragon edgarrmondragon deleted the from_dict_immutable branch March 15, 2025 20:13
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.

Read-only src_dict dictionary in from_dict methods should be typed as Mapping[str, Any]
2 participants