Swagger UI Web Api documentation Present enums as strings?

后端 未结 20 2052
半阙折子戏
半阙折子戏 2020-11-27 11:31

Is there a way to display all enums as their string value in swagger instead of their int value?

I want to be able to submit POST actions and put enums according to

20条回答
  •  囚心锁ツ
    2020-11-27 11:37

    If the version of the swagger were 5.5.x, then you need to:

    1. install: Install-Package Swashbuckle.AspNetCore.Newtonsoft -Version 5.5.0

    2. services.AddSwaggerGenNewtonsoftSupport();

    Reference: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#systemtextjson-stj-vs-newtonsoft

提交回复
热议问题