fix: Indent of generated code for non-required lists. Thanks @sfowl!#1050
Merged
dbanty merged 3 commits intoopenapi-generators:mainfrom Jun 15, 2024
Merged
fix: Indent of generated code for non-required lists. Thanks @sfowl!#1050dbanty merged 3 commits intoopenapi-generators:mainfrom
dbanty merged 3 commits intoopenapi-generators:mainfrom
Conversation
Contributor
Author
|
I believe this bug was introduced by #926 |
Collaborator
|
Can you provide a minimal OpenAPI schema which triggers this issue? That way we can make sure we're exercising that code path in tests to prevent this regression. |
2b821b1 to
ad3192b
Compare
Contributor
Author
|
I've modified the baseline spec in the end to end tests to cover this case, and regenerated the snapshots with |
dbanty
added a commit
that referenced
this pull request
Jun 15, 2024
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 #633, closes #664, resolves #595.
### Fixes
- Indent of generated code for non-required lists. Thanks @sfowl!
(#1050)
- Parsing requestBody with $ref (#633)
Co-authored-by: GitHub <github-actions@github.com>
micha91
pushed a commit
to micha91/openapi-python-client
that referenced
this pull request
May 13, 2025
…penapi-generators#1050) The `_transform` macro is called at three different places in this file, but one location was not similarly indented as the other two. This caused errors in the ruff post_hook like: ``` error: Failed to parse foo/models/foo_request.py:125:9: Expected an indented block after `if` statement ``` The generated code without the indent fix looks like: ``` if not isinstance(self.foo, Unset): _temp_foo = [] # <-- incorrect indent for foo_item_data in self.foo: foo_item: Union[None, int] foo_item = foo_item_data _temp_foo.append(foo_item) foo = (None, json.dumps(_temp_foo).encode(), 'application/json') ``` --------- Co-authored-by: Dylan Anthony <43723790+dbanty@users.noreply.github.com>
micha91
pushed a commit
to micha91/openapi-python-client
that referenced
this pull request
May 13, 2025
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>
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
Sign up for free
to 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.
The
_transformmacro is called at three different places in this file, but one location was not similarly indented as the other two. This caused errors in the ruff post_hook like:The generated code without the indent fix looks like: