Uh oh!
There was an error while loading. Please reload this page.
fix(api): omit nullable references from the schemas that require them - #41
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #38. Found by generating a client from the published document and parsing a real
/v1/diagnosticsresponse through it:The second one is ours.
#38added a transformer that drops nullable properties fromrequired, because the serializer omits them rather than writing null. It read nullability off the generated schema — which works forstring?("type": ["null","string"]) but not for a nullable reference:That form carries no type of its own, so the check missed it and both properties stayed
requiredwhile 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
The document diff is exactly two entries —
DiagnosticView.positionandGetDiagnosticsResponse.lastRefresh.(The datetime failure is not a defect here: the API emits
+00:00, whichformat: date-timepermits. The consumer's generated schema was too strict and is fixed on that side.)Verification
dotnet build0 warnings,dotnet format --verify-no-changesclean, 364/364 tests pass. The regenerated document is committed, so CI's drift check covers it.