2

I've changed my API response parameters to snake case by adding below line in WebApiConfig.cs

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver
        {
            NamingStrategy = new SnakeCaseNamingStrategy()
        };
    }
}

Currently I'm generating API documentation by using Swagger and I'm looking for same setup in Swagger response? Is there any option in Swagger for this?

Current document Output:

enter image description here

Expected document Output:

enter image description here

Arasu RRK
  • 1,078
  • 16
  • 28
  • Try this link: https://stackoverflow.com/questions/28552567/web-api-2-how-to-return-json-with-camelcased-property-names-on-objects-and-the – Sujith Jul 04 '17 at 06:17

2 Answers2

1

Try using an IDocumentFilter, you can do all kind of changes to your document output (aka SwaggerDocument)

Here are some examples on GitHub

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
Helder Sepulveda
  • 15,500
  • 4
  • 29
  • 56
1

Swagger Snake Case Configuration in Springboot

I faced the same issue and was able to fix it using ModelResolver from Swagger OAS.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sourabh
  • 413
  • 5
  • 17