gvdm gvdm - 1 year ago 104
reST (reStructuredText) Question

Swagger not generating the REST documentation

I'm trying to let Swagger autogenerate che documentation of my REST APIs but I only get a partial result.

I'm using Resteasy. I added the Maven Swagger dependency


Then I configured my Application object

package com.myapp.init;

import java.util.HashSet;
import java.util.Set;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
import io.swagger.jaxrs.listing.SwaggerSerializers;

public class WebappInit extends Application {

public WebappInit() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setSchemes(new String[]{"http"});


public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<Class<?>>();

// here I add my REST WSs

return s;


Then I run the web application (on a Wildfly 9 server) and go to the URL
. That's what I get

swagger: "2.0",
info: {
version: "1.0.0"
host: "",
basePath: "/devops/rest/",
schemes: [

It seems that Swagger cannot build the REST documentation, even though my REST endpoints are reachable and are added to the Swagger list of resources.

What can be the problem?

Thank you


Update: I checked that in the Swagger init method
my REST classes are correctly discovered.

Answer Source

You need to add an @Api annotation to your resource classes.

For example:

package my.sample;
import io.swagger.annotations.Api;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.core.Response;

@Path ("/mypath")
public class MyResource
    public Response myEndpoint()
        return Response.ok ();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download