Skip to content

[OpenAPI] AdditionalProperties missing in the ProblemDetails schema (.net 10 preview 4) #62099

@aw-if

Description

@aw-if

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I created a web api in .net 10 preview 4 with AddOpenApi (version OpenApi3_0), and added ProblemDetails to the weather forecast controller. The generated ProblemDetails schema looks like this:

"ProblemDetails": {
"type": "object",
"properties": {
"type": {
"type": "string",
"nullable": true
},
"title": {
"type": "string",
"nullable": true
},
"status": {
"pattern": "^-?(?:0|[1-9]\d*)$",
"format": "int32"
},
"detail": {
"type": "string",
"nullable": true
},
"instance": {
"type": "string",
"nullable": true
}
}
},

Shouldn't it also have additionalProperties to mark that it could contain more properties than the ones defined in the schema, like the ValidationProblemDetails schema has on the errors node?
"ValidationProblemDetails": {
"type": "object",
"properties": {
"type": {
"type": "string",
"nullable": true,
},
"title": {
"type": "string",
"nullable": true,
},
"status": {
"pattern": "^-?(?:0|[1-9]\d*)$",
"format": "int32"
},
"detail": {
"type": "string",
"nullable": true,
},
"instance": {
"type": "string",
"nullable": true,
},
"errors": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}

Expected Behavior

No response

Steps To Reproduce

New ASP.NET Core Web API with .NET 10.

In Program.cs:
builder.Services.AddOpenApi(c => { c.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi3_0; });

In the WeatherForecastController, add the following attributes to the Get method:
[ProducesResponseType<ProblemDetails>(StatusCodes.Status500InternalServerError, MediaTypeNames.Application.ProblemJson)] [ProducesResponseType<ValidationProblemDetails>(StatusCodes.Status500InternalServerError, MediaTypeNames.Application.ProblemJson)]

Exceptions (if any)

No response

.NET Version

10.0.100-preview.4.25258.110

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions