-
Notifications
You must be signed in to change notification settings - Fork 10.7k
OpenAPI documentation is incorrect when using custom TryParse() binding with Minimal APIs #36412
Copy link
Copy link
Closed
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Metadata
Metadata
Assignees
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Type
Fields
Give feedbackNo fields configured for issues without a type.
Describe the bug
If a type with a static
TryParse()method is used as a parameter for a Minimal APIs action, the OpenAPI description does not work as would be expected.There are two examples of this I have found for
MapGet()andMapPost().MapGetIf a parameter uses a custom type which has a
TryParse()method, it will be reported as an object parameter, rather than the string that is received to be parsed.MapPostIf a parameter uses a custom type which has a
TryParse()method, it will be reported as both an object query string parameter and as the request body. If[FromBody]is used on the parameter, the extra parameter is not shown.To Reproduce
Create an empty ASP.NET Core 6 project with a reference to
Swashbuckle.AspNetCorewith the below code asProgram.cs.Further technical details
.NET SDK version
6.0.100-rc.1.21460.8