Describe the bug
After updating from v3.7.0 to v3.9.0, the nullable property disappears when writing an OpenAPI 3.0 document.
Repro steps
usingMicrosoft.OpenApi;varmetaSchema=newOpenApiSchema{Type=JsonSchemaType.Object,AdditionalProperties=newOpenApiSchema{Type=JsonSchemaType.Null}};varbaseSchema=newOpenApiSchema{Type=JsonSchemaType.Object,Id="base",Properties=newDictionary<string,IOpenApiSchema>{["id"]=newOpenApiSchema{Type=JsonSchemaType.String}}};varderivedSchema=newOpenApiSchema{Type=JsonSchemaType.Null,AllOf=newList<IOpenApiSchema>{newOpenApiSchemaReference(baseSchema.Id)},Properties=newDictionary<string,IOpenApiSchema>{["kind"]=newOpenApiSchema{Type=JsonSchemaType.String}}};vardoc=newOpenApiDocument();doc.Components??=newOpenApiComponents();doc.Components.Schemas??=newDictionary<string,IOpenApiSchema>();doc.Components.Schemas.Add("meta",metaSchema);doc.Components.Schemas.Add("base",baseSchema);doc.Components.Schemas.Add("derived",derivedSchema);varresult=awaitdoc.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);Console.WriteLine(result);Using v3.7.0, this prints:
{
"openapi": "3.0.4",
"info": { },
"paths": { },
"components": {
"schemas": {
"meta": {
"type": "object",
"additionalProperties": {
"nullable": true
}
},
"base": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"derived": {
"allOf": [
{
"$ref": "#/components/schemas/base"
}
],
"properties": {
"kind": {
"type": "string"
}
},
"nullable": true
}
}
}
}Using v3.9.0, this prints:
{
"openapi": "3.0.4",
"info": { },
"paths": { },
"components": {
"schemas": {
"meta": {
"type": "object",
"additionalProperties": {
"enum": [
null
]
}
},
"base": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"derived": {
"allOf": [
{
"$ref": "#/components/schemas/base"
}
],
"properties": {
"kind": {
"type": "string"
}
}
}
}
}
}Screenshots/Code Snippets
View of the diff:

Originally reported at: domaindrivendev/Swashbuckle.AspNetCore#4065
Describe the bug
After updating from v3.7.0 to v3.9.0, the
nullableproperty disappears when writing an OpenAPI 3.0 document.Repro steps
Using v3.7.0, this prints:
{ "openapi": "3.0.4", "info": { }, "paths": { }, "components": { "schemas": { "meta": { "type": "object", "additionalProperties": { "nullable": true } }, "base": { "type": "object", "properties": { "id": { "type": "string" } } }, "derived": { "allOf": [ { "$ref": "#/components/schemas/base" } ], "properties": { "kind": { "type": "string" } }, "nullable": true } } } }Using v3.9.0, this prints:
{ "openapi": "3.0.4", "info": { }, "paths": { }, "components": { "schemas": { "meta": { "type": "object", "additionalProperties": { "enum": [ null ] } }, "base": { "type": "object", "properties": { "id": { "type": "string" } } }, "derived": { "allOf": [ { "$ref": "#/components/schemas/base" } ], "properties": { "kind": { "type": "string" } } } } } }Screenshots/Code Snippets
View of the diff:
Originally reported at: domaindrivendev/Swashbuckle.AspNetCore#4065