-
-
Save CSchulz/d3ee383c5b134231c39c144e537d9901 to your computer and use it in GitHub Desktop.
SwaggerServlet with jaxb module
This file contains 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
package de.openknowledge.shop.api; | |
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; | |
import io.swagger.jaxrs.config.BeanConfig; | |
import io.swagger.util.Json; | |
import io.swagger.util.Yaml; | |
import javax.servlet.ServletConfig; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
public class SwaggerServlet extends HttpServlet { | |
@Override | |
public void init(ServletConfig config) throws ServletException { | |
super.init(config); | |
Json.mapper().registerModule(new JaxbAnnotationModule()); | |
Yaml.mapper().registerModule(new JaxbAnnotationModule()); | |
BeanConfig beanConfig = new BeanConfig(); | |
beanConfig.setVersion("1.0.0"); | |
beanConfig.setBasePath("/api"); | |
beanConfig.setResourcePackage("de.openknowledge.shop"); | |
beanConfig.setScan(true); | |
beanConfig.setPrettyPrint(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment