fix: keep nullable when single allOf type replaces a property

Merged
TH
2d ago
+61-9

Property with allOf of one inline type plus nullable: true from #20373 is replaced in InlineModelResolver by that only item, so nullable is lost: two: {allOf: [{type: string}], nullable: true} gives two: string in typescript-axios and StrictStr in python. Same shape with $ref inside allOf doesnt lose it

Now nullable of property is copied to the item when it has none. Added test in InlineModelResolverTest. Regenerated all samples: only typescript-fetch enum builds change, their nullable-string-enum / nullable-number-enum have same shape and become | null as spec says

Fixes #20373

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    Commit all changed files.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes nullable being lost when InlineModelResolver flattens a property whose allOf contains a single inline type. The property's nullable value is now copied to the replacement item when the item doesn't set its own, matching the behavior already present for $ref-based allOf items. Tests cover both inline-type and $ref allOf items, and regenerated typescript-fetch enum samples now emit | null for nullable enums, matching the spec.