-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
Before v10, I was configuring nullability as follows:
builder.Services.AddSwaggerGen(o =>
{
options.SupportNonNullableReferenceTypes();
options.UseAllOfToExtendReferenceSchemas();
options.UseAllOfForInheritance();
}This produced correct nullability annotations for enums as well as reference types (including other object schemas) using nullable: true.
v10 seems to have changed both how nullability is annotated, as well as how references work. The above setup now produces the nonsensical combination of type: "null" with allOf: [...], causing type definition source generators to go haywire (e.g. the typescript one produces an intersection of null and the referenced object type definition, which collapses into never).
I tried to fix this with a schema filter, however I came to the conclusion that this is not possible to model with the new way references are represented (as the Type property is passed through to the reference target, which is obviously not nullable in this context).
The Microsoft.AspNetCore.OpenApi generator does not have this issue, though it comes with a myriad of other problems for our codebase, so I'd love for this to get addressed / to get any leads for a possible workaround.
Thank you for this awesome project, and should I have missed anything obvious, apologies in advance.