Swagger 2.8.0 unable to generate api-docs - java

I am unable to get a valid json in my spring boot application, when i call the swagger /v2/api-docs endpoint.
Chrome error message:
This page contains the following errors: error on line 1 at
column 1330: xmlParseEntityRef: no name Below is a rendering of the
page up to the first error.
With the developer tools i see that the swagger.json is wrapped in xml tags,
also the content type is set to application/xhtml+xml.
The response look like this:
<Json>{"swagger":"2.0",..............</Json>
I am using Spring Boot 2.0.0.RELEASE, Spring 5.0.4.RELEASE and
for XML mapping the jackson-dataformat-xml dependency version 2.9.4.
Is there a way that i can send application/json as content type or configure the jackson dependency, that spring loads it not as the first in classpath?
Or is there any other way to fix it?
For Jackson we only used the import, no seperate configuration.
Swagger Configuration:
#SpringBootApplication (exclude = {SecurityAutoConfiguration.class})
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
#ConditionalOnWebApplication
#EnableSwagger2
public static class SwaggerConfig {
#Bean
public Docket springfoxDocket() {
StringVendorExtension vendorExtension = new StringVendorExtension("x-wso2-security", Wso2Config.serialize());
List<VendorExtension> vendorExtensions = new ArrayList<>();
vendorExtensions.add(vendorExtension);
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com"))
.build()
.protocols(protocolSet())
.apiInfo(apiInfo())
.extensions(vendorExtensions)
.directModelSubstitute(LocalDateTime.class, Date.class)
.useDefaultResponseMessages(false).enableUrlTemplating(false)
;
}
private ApiInfo apiInfo() {
return new ApiInfo(
"Event",
"Creates, deletes, reads events",
"2.0",
"",
null,
null, null, Collections.emptyList());
}
private Set<String> protocolSet() {
Set<String> protocolsSet = new HashSet<>();
protocolsSet.add("http");
protocolsSet.add("https");
return protocolsSet;
}
}
}

Since you have jackson-dataformat-xml dependency spring boot will default the content type to application/xml.
If you want application\jsonas content type then configure restTemplate to do so.
Please follow the question Swagger 2 accept xml instead of json

Related

Swagger UI from Springfox 3.0 not showing the POST methods in UI

I am using Springfox 3.0 with a simple REST controller. In Swagger UI, only GET methods are showing up, but not POST methods.
I am also struggling to get my context path in Swagger UI. Actually the context path is appending after the endpoint not before. So I placed everything in tomcat root folder without context.
<servlet-mapping>
<servlet-name>SwaggerRest</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
#Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.host("localhost:8080")
.select()
.apis(RequestHandlerSelectors.basePackage("test.maventest")).paths(PathSelectors.ant("/**"))
.build();
-------------
#Component
// make sure it runs after the default plugin springfox.documentation.swagger2.web.WebMvcBasePathAndHostnameTransformationFilter
#Order(Ordered.HIGHEST_PRECEDENCE + 1000)
public class CustomMvcPathHostFilter implements WebMvcSwaggerTransformationFilter {
#Override
public Swagger transform(SwaggerTransformationContext<HttpServletRequest> context) {
Swagger swagger = context.getSpecification();
context.request().ifPresent(servletRequest -> {
UriComponents uriComponents = HostNameProvider.componentsFrom(servletRequest, swagger.getBasePath());
swagger.host(uriComponents.getHost() + (uriComponents.getPort() > 0 ? ":" + uriComponents.getPort() : ""));
// set Swagger base path
String basePath = StringUtils.isEmpty(uriComponents.getPath()) ? "/" : uriComponents.getPath();
swagger.basePath(basePath);
System.out.println("baseoath "+basePath);
// rewrite paths to remove the leading base path from each endpoint
final Map<String, Path> newPaths = swagger.getPaths().entrySet().stream().collect(Collectors.toMap(
entry -> entry.getKey().replaceAll("^" + basePath, ""), Map.Entry::getValue));
swagger.setPaths(newPaths);
});
return swagger;
}
//Not showing in swagger ui
#PostMapping("/saveInfo")
public ResponseEntity <?> saveinFo(#RequestBody Student student) throws Exception {
System.out.println("Saving studinfo Response at ==>444444444" );
return new ResponseEntity <List<Student>> (studservice.save(student),HttpStatus.OK);
}
Try using the springdoc instead of springfox. It worked for me.
org.springdoc:springdoc-openapi-ui:1.5.13

In springboot application how to set default header if not present

I have written a method with get request mapping it gives list of users. As jakson binding dependency is there is gives response in JSON. I've also dependency for XML which is Jackson Dataformat XML.So, if Accept is application/json it returns the response in JSON and if it is in application/xml it returns in XML.But by default it gives JSON response. SO, I wanted to add Accept header if not present and make it's default value as application/xml.
#GetMapping(path="/getAll")
public List<User> getUsers(#RequestHeader(value= "Accept" ,required=false, defaultValue="application/xml") String Accept)
{
return service.findAll();
}
But in above case, the header is not setting.
In order to do so, you need to modify your controller method to return ResponseEntity<List<User>> as following:
#GetMapping(path="/getAll")
public ResponseEntity<List<User>> getUsers(#RequestHeader(value= "Accept" ,required=false, defaultValue="application/xml") String Accept) {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setLocation(location);
responseHeaders.set("Accept", "Value");
return new ResponseEntity<List<User>>(service.findAll(), responseHeaders, HttpStatus.CREATED);
}
If you just want to respond XML from your spring boot application, use the following custom webMvcConfiguration. Setting a default Accept header just to respond XML does not seem like a good idea.
#Configuration
public class WebMvcConfiguration {
#Bean
public WebMvcConfigurer myWebMvcConfigurer() {
return new WebMvcConfigurerAdapter() {
#Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_XML);
}
};
}
}
if you are already using a custom WebMvcConfigurerAdapter, just override the configureContentNegotiation(...) method as above.

No operations defined in spec! while specifying multiple paths in swagger ui

I want to display two REST API endpoints in Swagger ui: /cart and /post.
When I specify either /cart or /post works fine but with both showing me error as
No operations defined in spec!
in swagger-ui
#Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/cart"))
.paths(PathSelectors.ant("/post"))
.build();
}
Another option is to use .paths(PathSelectors.any()) instead of .paths(PathSelectors.ant("/cart")) and .paths(PathSelectors.ant("/post"))
With Spring boot 2.6.x you also need:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
It because you use AND condition
public ApiSelectorBuilder paths(Predicate<String> selector) {
pathSelector = pathSelector.and(selector);
return this;
}
you can combine conditions by using OR clause
.paths(PathSelectors.ant("/cart").or(PathSelectors.ant("/post")))
Please add package xxxx as root package so It can scan swagger config in all class
public String getApplicationBasePath() {
return swaggerPath;
}
}).select().apis(RequestHandlerSelectors.basePackage("xxxx")).build()
.securitySchemes(Arrays.asList(securitySchema()))
.securityContexts(Collections.singletonList(securityContext())).apiInfo(metaData());

How to add Swagger related static files to Spring Boot + Jersey app?

I am trying to add Swagger support to my REST API but I am confused how to add Swagger related static content (HTML, JS) files to my Spring Boot application.
I use the following dependencies:
spring-boot-starter-parent:2.0.1.RELEASE
spring-boot-starter-jersey:2.0.1.RELEASE
swagger-jersey2-jaxrs:1.5.18
This is my swagger configuration:
#Configuration
public class SwaggerConfig {
#Bean
public BeanConfig swaggerConfiguration() {
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("a.b.c");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);
return beanConfig;
}
}
And the jersey configuration:
#Component
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(ImageResource.class);
register(io.swagger.jaxrs.listing.ApiListingResource.class);
register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
}
}
This part works like a charm, when I open http://localhost:8090/swagger.json then I can see the expected Swagger JSON content.
But I do not know, how to add the Swagger related static HTML content to my application. I can see that this content is in the springfox-swagger-ui.jar and I can add it to my project as a maven dependency, but how I can unpack the content from this jar?
And what is the proper way to overwrite the default swagger.json URL with my URL in the static Swagger file in order to Swagger show my REST API immediately when I open swagger-ui.html.
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>${swagger-ui.version}</version>
</dependency>
Please, do not include springfox-swagger-ui.jar, it's meant to work with Spring's RestController.
You must have solved it now but it might help others so here's the complete procedure as I was also looking for a tutorial.
I am using Swagger V2 with Spring Boot 2 and it's straightforward 3 step process.
Step 1: Add required dependencies in pom.xml file. The second dependency is optional use it only if you need Swagger UI.
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
Step 2: Add configuration class
#Configuration
#EnableSwagger2
public class SwaggerConfig {
public static final Contact DEFAULT_CONTACT = new Contact("Usama Amjad", "https://stackoverflow.com/users/4704510/usamaamjad", "hello#email.com");
public static final ApiInfo DEFAULT_API_INFO = new ApiInfo("Article API", "Article API documentation sample", "1.0", "urn:tos",
DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<VendorExtension>());
#Bean
public Docket api() {
Set<String> producesAndConsumes = new HashSet<>();
producesAndConsumes.add("application/json");
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(DEFAULT_API_INFO)
.produces(producesAndConsumes)
.consumes(producesAndConsumes);
}
}
Step 3: Setup complete and now you need to document APIs in controllers
#ApiOperation(value = "Returns a list Articles for a given Author", response = Article.class, responseContainer = "List")
#ApiResponses(value = { #ApiResponse(code = 200, message = "Success"),
#ApiResponse(code = 404, message = "The resource you were trying to reach is not found") })
#GetMapping(path = "/articles/users/{userId}")
public List<Article> getArticlesByUser() {
// Do your code
}
Usage:
Swagger UI: You can access it via http://localhost:8080/swagger-ui.html
Postman: You can also access your Documentation JSON from http://localhost:8080/v2/api-docs and just copy paste it in Postman to use with it.

Unable to link Swagger-ui to my swagger Spring mvc project

I'm currently creating an API Rest using Eclipse, Spring Framework MVC, and I just added to my project swagger. I can access the json result of swagger but I need to add swagger ui.
Here are all my files creating for swagger-springmvc:
WebAppInitializer.java
public class WebAppInitializer implements WebApplicationInitializer {
private AnnotationConfigWebApplicationContext ctx = null;
#Override
public void onStartup(final ServletContext sc) throws ServletException {
System.setProperty("spring.profiles.active", "web");
// Create the 'root' Spring application context
ctx = new AnnotationConfigWebApplicationContext();
ctx.register(SpringBaseWebConfiguration.class,
SpringSwaggerConfiguration.class);
// Manages the lifecycle
sc.addListener(new ContextLoaderListener(ctx));
sc.addListener(new ContextCleanupListener());
// Spring WebMVC
ServletRegistration.Dynamic springWebMvc = sc.addServlet("ws",
new DispatcherServlet(ctx));
springWebMvc.setLoadOnStartup(1);
springWebMvc.addMapping("/ws/*");
springWebMvc.setAsyncSupported(true);
}
#PreDestroy
protected final void cleanup() {
if (ctx != null) {
ctx.close();
}
}
}
SpringSwaggerConfiguration.java
public class SpringSwaggerConfiguration {
public static final List<String> DEFAULT_INCLUDE_PATTERNS = Arrays
.asList(new String[]{"/com/sa/rnd/dark/resources/.*"});
public static final String SWAGGER_GROUP = "ApiDark";
public static final String RELATIVE_GROUP = "ApiDark";
#Autowired
private SpringSwaggerConfig springSwaggerConfig;
/**
* Adds the jackson scala module to the MappingJackson2HttpMessageConverter
* registered with spring Swagger core models are scala so we need to be
* able to convert to JSON Also registers some custom serializers needed to
* transform swagger models to swagger-ui required json format
*/
#Bean
public JacksonScalaSupport jacksonScalaSupport() {
final JacksonScalaSupport jacksonScalaSupport = new JacksonScalaSupport();
// Set to false to disable
jacksonScalaSupport.setRegisterScalaModule(true);
return jacksonScalaSupport;
}
/**
* Global swagger settings
*/
#Bean
public SwaggerGlobalSettings swaggerGlobalSettings() {
final SwaggerGlobalSettings swaggerGlobalSettings = new SwaggerGlobalSettings();
swaggerGlobalSettings.setGlobalResponseMessages(springSwaggerConfig
.defaultResponseMessages());
swaggerGlobalSettings.setIgnorableParameterTypes(springSwaggerConfig
.defaultIgnorableParameterTypes());
return swaggerGlobalSettings;
}
/**
* API Info as it appears on the swagger-ui page
*/
private ApiInfo apiInfo() {
return new ApiInfo(
"Swagger Spring MVC for Dark Api",
"Sample application demonstrating how to use swagger-springmvc in a no-XML environment.",
"http://en.wikipedia.org/wiki/Terms_of_service",
"michael#laccetti.com", "Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0.html");
}
/**
* Configure a SwaggerApiResourceListing for each swagger instance within
* your app. e.g. 1. private 2. external apis Required to be a spring bean
* as spring will call the postConstruct method to bootstrap swagger
* scanning.
*
* #return
*/
#Bean
public SwaggerApiResourceListing swaggerApiResourceListing() {
// The group name is important and should match the group set on
// ApiListingReferenceScanner
// Note that swaggerCache() is by DefaultSwaggerController to serve the
// swagger json
final SwaggerApiResourceListing swaggerApiResourceListing = new SwaggerApiResourceListing(
springSwaggerConfig.swaggerCache(), SWAGGER_GROUP);
// Set the required swagger settings
swaggerApiResourceListing
.setSwaggerGlobalSettings(swaggerGlobalSettings());
// Supply the API Info as it should appear on swagger-ui web page
swaggerApiResourceListing.setApiInfo(apiInfo());
// Use the default path provider
swaggerApiResourceListing.setSwaggerPathProvider(springSwaggerConfig
.defaultSwaggerPathProvider());
// Global authorization - see the swagger documentation
swaggerApiResourceListing.setAuthorizationTypes(authorizationTypes());
// Sets up an auth context - i.e. which controller request paths to
// apply global auth to
swaggerApiResourceListing
.setAuthorizationContext(authorizationContext());
// Every SwaggerApiResourceListing needs an ApiListingReferenceScanner
// to scan the spring request mappings
swaggerApiResourceListing
.setApiListingReferenceScanner(apiListingReferenceScanner());
return swaggerApiResourceListing;
}
#Bean
/**
* The ApiListingReferenceScanner does most of the work.
* Scans the appropriate spring RequestMappingHandlerMappings
* Applies the correct absolute paths to the generated swagger resources
*/
public ApiListingReferenceScanner apiListingReferenceScanner() {
ApiListingReferenceScanner apiListingReferenceScanner = new ApiListingReferenceScanner();
// Picks up all of the registered spring RequestMappingHandlerMappings
// for
// scanning
apiListingReferenceScanner
.setRequestMappingHandlerMapping(springSwaggerConfig
.swaggerRequestMappingHandlerMappings());
// Excludes any controllers with the supplied annotations
apiListingReferenceScanner.setExcludeAnnotations(springSwaggerConfig
.defaultExcludeAnnotations());
//
apiListingReferenceScanner
.setResourceGroupingStrategy(springSwaggerConfig
.defaultResourceGroupingStrategy());
// Path provider used to generate the appropriate uri's
apiListingReferenceScanner
.setSwaggerPathProvider(relativeSwaggerPathProvider());
// Must match the swagger group set on the SwaggerApiResourceListing
apiListingReferenceScanner.setSwaggerGroup(SWAGGER_GROUP);
// Only include paths that match the supplied regular expressions
apiListingReferenceScanner.setIncludePatterns(DEFAULT_INCLUDE_PATTERNS);
return apiListingReferenceScanner;
}
private List<AuthorizationType> authorizationTypes() {
final List<AuthorizationType> authorizationTypes = new ArrayList<>();
authorizationTypes.add(new BasicAuth());
return authorizationTypes;
}
#Bean
public AuthorizationContext authorizationContext() {
final List<Authorization> authorizations = newArrayList();
AuthorizationScope authorizationScope = new AuthorizationScope(
"global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[]{authorizationScope};
authorizations.add(new Authorization("basic", authorizationScopes));
AuthorizationContext authorizationContext = new AuthorizationContext.AuthorizationContextBuilder(
authorizations).withIncludePatterns(DEFAULT_INCLUDE_PATTERNS)
.build();
return authorizationContext;
}
// Relative path example
#Bean
public SwaggerApiResourceListing relativeSwaggerApiResourceListing() {
SwaggerApiResourceListing swaggerApiResourceListing = new SwaggerApiResourceListing(
springSwaggerConfig.swaggerCache(), RELATIVE_GROUP);
swaggerApiResourceListing
.setSwaggerGlobalSettings(swaggerGlobalSettings());
swaggerApiResourceListing
.setSwaggerPathProvider(relativeSwaggerPathProvider());
swaggerApiResourceListing
.setApiListingReferenceScanner(relativeApiListingReferenceScanner());
return swaggerApiResourceListing;
}
#Bean
public ApiListingReferenceScanner relativeApiListingReferenceScanner() {
ApiListingReferenceScanner apiListingReferenceScanner =
new ApiListingReferenceScanner();
apiListingReferenceScanner
.setRequestMappingHandlerMapping(springSwaggerConfig
.swaggerRequestMappingHandlerMappings());
apiListingReferenceScanner.setExcludeAnnotations(springSwaggerConfig
.defaultExcludeAnnotations());
apiListingReferenceScanner
.setResourceGroupingStrategy(springSwaggerConfig
.defaultResourceGroupingStrategy());
apiListingReferenceScanner
.setSwaggerPathProvider(relativeSwaggerPathProvider());
apiListingReferenceScanner.setSwaggerGroup(RELATIVE_GROUP);
apiListingReferenceScanner.setIncludePatterns(DEFAULT_INCLUDE_PATTERNS);
return apiListingReferenceScanner;
}
#Bean
public SwaggerPathProvider relativeSwaggerPathProvider() {
return new ApiRelativeSwaggerPathProvider();
}
private class ApiRelativeSwaggerPathProvider extends
DefaultSwaggerPathProvider {
#Override
public String getAppBasePath() {
return "/ApiDark/ws";
}
}
}
SpringBaseWebConfiguration.java :
#Configuration
#ComponentScan(basePackages = {"com.sa.rnd.dark.resources",
"com.mangofactory.swagger.configuration",
"com.mangofactory.swagger.controllers"})
#EnableWebMvc
public class SpringBaseWebConfiguration extends WebMvcConfigurerAdapter {
private List<HttpMessageConverter<?>> messageConverters;
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("/");
}
#Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/api-docs").setViewName("redirect:index.html");
}
/**
* The message converters for the content types we support.
*
* #return the message converters; returns the same list on subsequent calls
*/
private List<HttpMessageConverter<?>> getMessageConverters() {
if (messageConverters == null) {
messageConverters = new ArrayList<>();
final MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
final ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
mappingJacksonHttpMessageConverter.setObjectMapper(mapper);
messageConverters.add(mappingJacksonHttpMessageConverter);
}
return messageConverters;
}
#Override
public void configureMessageConverters(
List<HttpMessageConverter<?>> converters) {
converters.addAll(getMessageConverters());
}
#Bean
public static PropertyPlaceholderConfigurer swaggerProperties() {
final PropertyPlaceholderConfigurer swaggerProperties = new PropertyPlaceholderConfigurer();
swaggerProperties.setLocation(new ClassPathResource(
"swagger.properties"));
return swaggerProperties;
}
}
Here are my 3 files to add swagger to my project, atm I just decide to check just 1 method which is :
#Api(description = "CRUD services for containers working with WebDark",
value = "CRUD Services Containers")
#RestController
#RequestMapping(value = "/container", produces = MediaType.APPLICATION_JSON_VALUE)
public class ContainersResources {
/**
* Find all children of a container.
*
* #param containerId
* ID of the parent container
* #return ApiResponse
*/
#ApiOperation(response = ApiResponse.class,
value = "Find all children containers of one container",
notes = "Find all children containers of one container")
#RequestMapping(method = RequestMethod.GET, value = "/{containerId}")
#ResponseStatus(HttpStatus.OK)
public #ResponseBody ApiResponse<List<ContainerModel>> getContainerChildren(
#ApiParam(required = true, value = "The id of the container parent",
name = "containerId")#PathVariable("containerId") final String containerId) {
ApiResponse<List<ContainerModel>> result = new ApiResponse<>();
result.setMessage("getContainerChildren method of new Api Dark");
result.setSuccess(true);
result.setTotal(9000);
return result;
}
}
My results : I can access the following url http://localhost:8080/ApiDark/ws/api-docs but I get the json value like :
{"apiVersion":"1","swaggerVersion":"1.2","authorizations":{"basicAuth":{"type":"basicAuth"}},"info":{"title":"Swagger Spring MVC for Dark Api","description":"Sample application demonstrating how to use swagger-springmvc in a no-XML environment.","termsOfServiceUrl":"http://en.wikipedia.org/wiki/Terms_of_service","contact":"michael#laccetti.com","license":"Apache 2.0","licenseUrl":"http://www.apache.org/licenses/LICENSE-2.0.html"}}
That's why I decided to add swagger-ui. I add the content of dist folder (taken from swagger-ui) to my src/main/webapp folder. And modify the content of index.html to point to my url :
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "http://localhost:8080/ApiDark/ws/api-docs.json",
dom_id: "swagger-ui-container",
But I can't access to swagger-ui interface, I just have the json result... Need help to make it work please !
This issue seems old but just to share, with the recent version of swagger-springmvc and springmvc-ui, it has become very easy and less complicated to integrate swagger & swagger-ui with your web service to see in production REST api documentation.
#EnableSwagger annotation is added that enables swagger-springmvc out of the box. The generated swagger json Resource Listing can be accessed at /api-docs.
You may refer to following link for the steps on integrating swagger-springmvc and swagger-ui with your spring mvc project.
https://github.com/martypitt/swagger-springmvc
What do you mean by 'I can't access to swagger-ui interface'?
In my case, my browser did not load the index.html (I think it throw 404), which I had in a subfolder together with all the dist files: webapp/doc/index.html. I had to exclude the subfolder from the servlet mapping in web.xml as I shortly described here:
Java swagger with JaxRS throwing errors
My web.xml snippet looks like this finally:
<servlet-mapping>
<servlet-name>My application servlet-name</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/doc/*</url-pattern>
</servlet-mapping>
(why this works see here:http://blog.ericdaugherty.com/2010/02/excluding-content-from-url-pattern-in.html)
Hope that helps!

Categories

Resources