Don't require AttributeProvider for JsonPropertyInfo-based modifications#56712
Merged
captainsafia merged 2 commits intomainfrom Jul 10, 2024
Merged
Don't require AttributeProvider for JsonPropertyInfo-based modifications#56712captainsafia merged 2 commits intomainfrom
captainsafia merged 2 commits intomainfrom
Conversation
JamesNK
approved these changes
Jul 10, 2024
Member
JamesNK
left a comment
There was a problem hiding this comment.
Consider adding a test.
But, assuming gRPC JSON transcoding relies on this, its tests will probably cover it.
3 tasks
Contributor
Author
This is the assumption that I was operating on. After a good night's rest though, I was able to figure out a way to simulate this scenario in tests here. |
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 free
to 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.
This PR fixes a bug reported by @JamesNK in #56067.
Our OpenAPI implementation currently applies some transformations to the JSON schema produced by System.Text.Json in order to correctly produce
$refs for nested types. The application of this fix was guarded behind a check that validated if theJsonPropertyInfoassociated with the given schema had anAttributeProviderthat we could query, although theAttributeProviderwas not strictly needed for this check.It turns out that for the case of types generated from protobuf-definitions, there's no implementation of
IAtributeProviderresolved by System.Text.Json, so the fix was never applied for types used in a gRPC context.To resolve this issue, we split up the check in
TransformSchemaNodeto only check forAttributeProviderwhen we strictly need it.Below are the before/after for OpenAPI documents generated from the gRPC JsonTranscoding Sandbox app. Note the
HelloReplyschema.Before
After