Closed sherlock1982 closed 5 months ago
Looks like this may be a duplicate of https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1459?
You're halfway there by installing Swashbuckle.AspNetCore.Newtonsoft
.
You also need to add this line in your startup:
services.AddSwaggerGenNewtonsoftSupport();
Check the docs here for more details:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore#systemtextjson-stj-vs-newtonsoft
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
This issue was closed because it has been inactive for 14 days since being marked as stale.
I'm using Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Newtonsoft 5.6.3. Consider the following example:
In this case Newtonsoft.Json will serialize this enum as string. Swashbuckle current behavior: In schema it will be reported as int enum
Swashbuckle expected behavior: In schema to be reported as string enum
As a workaround i can apply
[JsonConverter(typeof(StringEnumConverter))]
to a type itself but this is not correct in all cases. Another workaround will be toDescribeAllEnumsAsStrings()
and this is also not always correct.