-
-
Notifications
You must be signed in to change notification settings - Fork 228
fix: Indent of generated code for non-required lists. Thanks @sfowl! #1050
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
Conversation
I believe this bug was introduced by #926 |
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
I've modified the baseline spec in the end to end tests to cover this case, and regenerated the snapshots with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks so much!
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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
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:The generated code without the indent fix looks like: