Skip to content

Conversation

@raymondbutcher
Copy link

Hi. Thanks for the project!

My OpenAPI spec has some fields as both nullable and required, but they are generating models with default values like this:

class Person(BaseModel):
    first_name: Annotated[str | None, Field(alias='firstName')] = None
    last_name: Annotated[str | None, Field(alias='lastName')] = None

Those default values make the fields optional, so it's not working as expected.

This fix also highlighted what looks to be a bug in an existing test that is checking for an incorrect result:

@ilovelinux
Copy link
Contributor

This PR closes the following issues:

Please link this PR with the issue as described here. Thanks!

gaborbernat and others added 2 commits November 3, 2025 06:06
@gaborbernat gaborbernat enabled auto-merge (squash) November 3, 2025 14:07
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 3, 2025

CodSpeed Performance Report

Merging #2520 will not alter performance

Comparing raymondbutcher:required-nullable-annotated (4c52967) with main (9d83669)

Summary

✅ 32 untouched

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

Successfully merging this pull request may close these issues.

3 participants