Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork259
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:mainChoose a base branch frome2b-dev:handle-query-array-explode
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for OpenAPI array parameters, especially regarding the
explodeandstyleattributes, 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 the
explodeattribute through the parsing logic, and updating generated code and tests to handle non-exploded array parameters.References: