Don't require AttributeProvider for JsonPropertyInfo-based modifications #56712
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
$ref
s for nested types. The application of this fix was guarded behind a check that validated if theJsonPropertyInfo
associated with the given schema had anAttributeProvider
that we could query, although theAttributeProvider
was not strictly needed for this check.It turns out that for the case of types generated from protobuf-definitions, there's no implementation of
IAtributeProvider
resolved 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
TransformSchemaNode
to only check forAttributeProvider
when we strictly need it.Below are the before/after for OpenAPI documents generated from the gRPC JsonTranscoding Sandbox app. Note the
HelloReply
schema.Before
After