Enum is showing as string in query parameter in swagger doc

Smith
Smith
Moderator
754 Points
157 Posts

I'm using Swashbuckle 

"Swashbuckle.AspNetCore" Version="6.5.0"

In Action:

[HttpGet]
public IHttpActionResult GetListByPriority (Priority priority)
{
   //
}

public enum Priority
{
    Low,
    Medium,
    High
}

Getting string field instead of option/dropdown for enum:

 

Views: 71
Total Answered: 1
Total Marked As Answer: 1
Posted On: 20-Jan-2023 04:08

Share:   fb twitter linkedin
Answers
beginer
beginer
314 Points
87 Posts
         

Found something here:

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1329 

If you are using SerializeAsV2 then this issue can be arise. Try to remove this setting:

app.UseSwagger(o => o.SerializeAsV2 = true);

 

Posted On: 22-Jan-2023 07:14
thanks
 - Smith  23-Jan-2023 04:20
 Log In to Chat