Created
December 19, 2016 13:37
-
-
Save corleonis/c0c9e4498dcc15a64fbcc43e7a316149 to your computer and use it in GitHub Desktop.
Swagger Plugin Enum values to lower case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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