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

Strip default None from model fields when converting from yaml swagger to pydantic model #1816

Open
bill2605 opened this issue Jan 23, 2024 · 0 comments

Comments

@bill2605
Copy link

bill2605 commented Jan 23, 2024

Would anyone know of a way to remove the enforced default:None when converting an OpenApi 3.0.1 yaml document to Pydantic models for later usage?
As of now I see that every model has the following (unless an default value is explicitly stated in the yaml):

self: Optional[str] = Field(
        None,
        description='blah blah'
        )

My issue is that when comes time to validate a JSON response, some fields which should be part of the model against which the response is validated are ignored without error. However, I've noticed that when the None default field value is removed, then errors are captured (missing or invalid field).

Maybe I'm missing something here. I thought the --strip-default-none would remove None but it is not.
Any ideas would be appreciated.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant