-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AsParameter] attribute generates a string query parameter when it should generate a decimal #2733
Comments
I tested this using DotSwashbuckle and .NET 8 and it seems to work. |
More information would be good if you can. |
To make sure it's not any external or domain dependency I've created sample project that shows the issue https://github.com/Liandrel/Swashbuckle-AsParameters-sample .NET 8 minimal api with no additional nugget packages except of pattern ones |
Thanks for the repro. |
It seems the ApiExplorer provides the type for the enum as string... using metadata driven approach works tho... // Works
endpoints.MapGet("/asparameter/openapi/enum", ([FromQuery] ConditionState? ConditionStateFromQuery,
[AsParameters] RequestModel model) =>
{
return $"{ConditionStateFromQuery}, {model.ConditionStateAsParameters}";
}).WithOpenApi();
// Does not work
endpoints.MapGet("/asparameter/openapi/enum2", ([FromQuery] ConditionState? ConditionStateFromQuery,
[AsParameters] RequestModel model) =>
{
return $"{ConditionStateFromQuery}, {model.ConditionStateAsParameters}";
}); |
…Type or apiParameter.Type. Fixes an issue where AsParameter Enums get incorrectly generated as strings domaindrivendev#2733
Issue
The
[AsParameters]
attribute is not generating the correct type ofdecimal
when using Swashbuckle to generate a WebApi. It generates astring
.When a decimal type is used on the object that is annotated with the
[AsParameters]
attribute the type generated is always astring
rather than a decimal.Reproduction
I have attached a zip file with a net7.0 solution with a basic replication of the problem. It contains a net7 minimal web API and you need to run it to see the type generated on the
/swagger
URL page is a string, not a decimal as expected.TestWebApp.zip
Expected Behaviour
Generate a decimal when the client runs the build step.
The text was updated successfully, but these errors were encountered: