Reputation: 1108
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:
Expected document Output:
Upvotes: 2
Views: 2332
Reputation: 481
Swagger Snake Case Configuration in Springboot
I faced the same issue and was able to fix it using ModelResolver from Swagger OAS.
Upvotes: 1
Reputation: 17664
Try using an IDocumentFilter
, you can do all kind of changes to your document output (aka SwaggerDocument
)
Here are some examples on GitHub
Upvotes: 1