Closed captainsafia closed 2 months ago
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
Are you expecting users to code the recursion into subschemas themselves or will that be done by the framework? I'm hoping it is the latter, and that the new context fields are needed to implement that.
It's the later. The implementation referenced in the proposal is referring to the framework.
To support this, the implementation will apply transformers on child schemas. As part of this work, we need to expose additional APIs on OpenApiSchemaTransformerContext in order to be able to analyze
API Review Notes:
TypeInfo
and PropertyInfo
instead of JsonTypeInfo
and JsonPropertyInfo
?
JsonTypeInfo
be null in valid scenarios?
TypeInfo
to JsonTypeInfo
and PropertyInfo
to JsonPropertyInfo
?
Type
property now that it's redundant?
JsonTypeInfo
be required?
OpenApiSchemaTransformerContext
(and other contexts) so it can only be constructed internally?
API Approved!
// Assembly: Microsoft.AspNetCore.OpenApi;
namespace Microsoft.AspNetCore.OpenApi;
public sealed class OpenApiSchemaTransformerContext
{
- public required Type Type { get; init; }
+ public required JsonTypeInfo JsonTypeInfo { get; init; }
+ public JsonPropertyInfo? JsonPropertyInfo { get; init; }
}
Background and Motivation
OpenAPI schema transformers currently only run on schemas that are generated at the top-level for parameters and responses. For example, in the following case:
The transformer will only apply the modification on the schema generated for the
id
route parameter and not theid
property withinTodo
. To resolve this issue, schemas need to be applied recursively into properties and child schemas (like those inanyOf
andallOf
). To support this, the implementation will apply transformers on child schemas. As part of this work, we need to expose additional APIs onOpenApiSchemaTransformerContext
in order to be able to analyzeProposed API
Usage Examples
Alternative Designs
TypeInfo
andPropertyInfo
instead ofJsonTypeInfo
andJsonPropertyInfo
?Risks
anyOf
of a parent type.