Skip to content

Instantly share code, notes, and snippets.

@CSchulz
Created May 11, 2016
Embed
What would you like to do?
SwaggerServlet with jaxb module
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