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

PythonGenerator with Pydantic If a property is Optional not required the json expected a key None #1644

Closed
tornabene opened this issue Dec 6, 2023 · 4 comments · Fixed by #1663
Labels
bug Something isn't working good first issue Good for newcomers Python generator Anything related to the Python generator released on @next released

Comments

@tornabene
Copy link

Describe the bug

PythonGenerator with Pydantic

How to Reproduce

If a property is Optional not required the json expected a key None

it is possible change the Class Python pydantic generator and add a default value =None for not required properties
from:
optionalkey: Optional[str] = Field( )
to:
optionalkey: Optional[str] = Field( default= None )

@tornabene tornabene added the bug Something isn't working label Dec 6, 2023
Copy link
Contributor

github-actions bot commented Dec 6, 2023

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@jonaslagoni
Copy link
Member

Thanks for the issue @tornabene 👍

This should be an easy fix, it's rendered as part of the preset located here:

return `${params.property.propertyName}: ${type} = Field(${alias})`;

Happy to review a PR and answer questions to fix this 🙂

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 2.0.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 3.0.0-next.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Python generator Anything related to the Python generator released on @next released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants