Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: handlestyle andexplode properties for parameters#1296

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jakubno wants to merge3 commits intoopenapi-generators:main
base:main
Choose a base branch
Loading
frome2b-dev:handle-query-array-explode

Conversation

@jakubno
Copy link

Description

Adds support for OpenAPI array parameters, especially regarding theexplode andstyle attributes, and enhances validation and code generation for parameters in the generated client.

The most significant changes include updating the OpenAPI schema models for parameters, propagating theexplode attribute through the parsing logic, and updating generated code and tests to handle non-exploded array parameters.

References:

ValentaTomas reacted with thumbs up emoji
richardlarocque added a commit to getoutreach/openapi-python-client that referenced this pull requestSep 17, 2025
Updates the data models to capture `style` and `explode` parameters.There was a PR outstanding that went in this direction [1].  We mightwant to rebase on top of that one day, when it's merged.  For now wesettle for some more targeted changes.Updates "ModelProperty" and related templates with a `to_deep_dict()`serialization option.  This option differs from the regular `to_dict()`in that nested dicts are flattened.  It also adds a `[]` suffix for keysthat point at arrays.  Finally, it takes a "prefix" argument that is thebase name of this object.The end result of all this is that we can have a deepObject query paramnamed `filter` that results in some `FooFilter` model param.  We caninitialize it as```pythonFooFilter.from_dict({'owner': { 'id': [12, 34] }})```then invoke its `to_deep_dict()` method to get```python{ 'filter[owner][id][]': [12, 34] }```which, when passed in to `httpx`, will result in a query param like```?filter[owner][id][]=12&filter[owner][id][]=34```which is exactly the format that APIv2 expects.  This is not acoincidence.  We're doing this specifically to support APIv2.Unfortunately, I don't see a straightforward way to polish and upstreamthis change.  The serialization conventions above are "Rails-style" [2],one of many possible interpretations of how an OpenAPI deepObject shouldact.  The spec doesn't actually specify very much here.So, while this is technically not *against* the spec, this is probablynot the interpretation that a Python generator would go with by default.(Maybe one day it could be configurable?  Or just wait and see ifOpenAPI delivers on its promise to fix all this?)I feel like "fork" is the best option for us for now.Since I don't expect this to be upstreamed, I haven't put much effortinto updating test suites.  I expect that would only make later rebasesmore difficult, without actually testing what we want most, which is"do the generated libraries work with our API?"[1]openapi-generators#1296[2]OAI/OpenAPI-Specification#1706 (comment)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@jakubno

[8]ページ先頭

©2009-2025 Movatter.jp