Skip to content

fix(api): omit nullable references from the schemas that require them - #41

Merged
DutchyD merged 1 commit into
developmentfrom
fix/openapi-nullable-refs
Aug 10, 2026
Merged

fix(api): omit nullable references from the schemas that require them#41
DutchyD merged 1 commit into
developmentfrom
fix/openapi-nullable-refs

Conversation

@DutchyD

Copy link
Copy Markdown
Contributor

Follows #38. Found by generating a client from the published document and parsing a real /v1/diagnostics response through it:

lastRefresh.attemptedAt -> Invalid ISO datetime
diagnostics.0.position -> expected object, received undefined

The second one is ours. #38 added a transformer that drops nullable properties from required, because the serializer omits them rather than writing null. It read nullability off the generated schema — which works for string? ("type": ["null","string"]) but not for a nullable reference:

"lastRefresh": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/RefreshView" } ] }

That form carries no type of its own, so the check missed it and both properties stayed required while the API omits them. Any consumer validating against the document rejected a perfectly valid response.

Nullability now comes from the property via NullabilityInfoContext, which is the same thing the serializer consults, so the schema cannot disagree with what is written regardless of how the schema spells the type.

Result

nullable properties still required: NONE
enum properties: 12
schemas: 21

The document diff is exactly two entries — DiagnosticView.position and GetDiagnosticsResponse.lastRefresh.

(The datetime failure is not a defect here: the API emits +00:00, which format: date-time permits. The consumer's generated schema was too strict and is fixed on that side.)

Verification

dotnet build 0 warnings, dotnet format --verify-no-changes clean, 364/364 tests pass. The regenerated document is committed, so CI's drift check covers it.

A nullable reference is described as a oneOf over null and the reference,
which carries no type of its own, so reading nullability off the schema
missed it and left lastRefresh and position required while the serializer
omits both. Nullability now comes from the property, which is what the
serializer reads too.
@DutchyD
DutchyD merged commit 87ec334 into developmentAug 10, 2026
5 checks passed
@DutchyD
DutchyD deleted the fix/openapi-nullable-refs branch August 10, 2026 11:00
Sign up for freeto 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.

1 participant

@DutchyD