Skip to content

Instantly share code, notes, and snippets.

@corleonis
Created December 19, 2016 13:37
Show Gist options
  • Save corleonis/c0c9e4498dcc15a64fbcc43e7a316149 to your computer and use it in GitHub Desktop.
Save corleonis/c0c9e4498dcc15a64fbcc43e7a316149 to your computer and use it in GitHub Desktop.
Swagger Plugin Enum values to lower case
<!--
and specified it as swaggerApiReader on the apiSource config in the pom:
now if the enum implements toString, it will be serialized using its toString method
-->
<apiSource>
...
<swaggerApiReader>com.your.package.SwaggerCustomJaxrsReader</swaggerApiReader>
...
</apiSource>
/**
* Hi,
* we had the same problem and we worked around it by creating a custom swaggerApiReader :
**/
import com.github.kongchen.swagger.docgen.reader.JaxrsReader;
public class SwaggerCustomReader extends JaxrsReader {
public SwaggerCustomReader(Swagger swagger, Log log) {
super(swagger, log);
Json.mapper().configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment