-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
/// <summary>
/// Transforms schemas with oneOf nullable pattern to allOf + nullable pattern.
/// Converts:
/// { "oneOf": [ { "type": "null" }, { "$ref": "..." } ] }
/// To:
/// { "allOf": [ { "$ref": "..." } ], "nullable": true }
/// </summary>
public sealed class OneOfToAllOfNullableTransformer : IOpenApiSchemaTransformer
{
public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext context, CancellationToken cancellationToken)
{
if (schema is OpenApiSchema openApiSchema)
{
TransformSchema(openApiSchema);
}
return Task.CompletedTask;
}
private void TransformSchema(OpenApiSchema schema)
{
// How to do here ?
// Filter oneOf
if (schema.OneOf != null && schema.OneOf.Count == 2)
{
// The breakpoint cannot be hit here.
}
}
}Describe the solution you'd like
The breakpoint can be hit, and I can configure oneOf and allOf.
// Filter oneOf
if (schema.OneOf != null && schema.OneOf.Count == 2)
{
// The breakpoint cannot be hit here.
}Additional context
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi