RESTEasy using Application/BeanConfig not seeing resources

240 views
Skip to first unread message

hancholo

unread,
Jul 18, 2016, 12:11:56 PM7/18/16
to Swagger
Can't figure this seemingly easy problem out

Using Wildfly 10, have a basic REST CRUD webapp with a /hello endpoint for testing, which works fine.


and got to the point of the 'empty' swagger.json :

{
swagger
: "2.0",
info
: {},
version
: "0.0.3",
title
: "HelloWorld2Api"
host
: "http://localhost:8080",
basePath
: "/HelloWorld2/rest",
schemes
: [] "http"
}

my setup:


in pom.xml:

<dependency>
   
<groupId>io.swagger</groupId>
   
<artifactId>swagger-jaxrs</artifactId>
   
<version>1.5.0</version>
</dependency>

in jboss-web.xml
<context-root>HelloWorld2</context-root>


Here are the annotations on my test resource:
@Path("hello")
@Api(value="hello")
@Produces({"application/json", "application/xml"})
public class HelloREST { ... }


Here's the extended Application:

@ApplicationPath("rest")
public class ApplicationConfig extends Application {


   
/**
     * Custom constructor for Swagger
     */

   
public ApplicationConfig() {
       
BeanConfig beanConfig = new BeanConfig();
        beanConfig
.setTitle("HelloWorld2Api");
        beanConfig
.setVersion("0.0.3");
        beanConfig
.setSchemes(new String[]{"http"});
        beanConfig
.setHost("http://localhost:8080");
        beanConfig
.setBasePath("/HelloWorld2/rest");
        beanConfig
.setScan(true);    
        beanConfig
.setResourcePackage("io.swagger.resources");
     
//  beanConfig.setResourcePackage("helloworld2.rest");
        beanConfig
.setPrettyPrint(true);
   
}


   
@Override
   
public Set<Class<?>> getClasses() {
       
Set<Class<?>> resources = new java.util.HashSet<>();
       
        resources
.add(helloworld2.rest.HelloREST.class);
       
        resources
.add(io.swagger.jaxrs.listing.ApiListingResource.class);
        resources
.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);
       
       
return resources;
   
}


}


If the above commented out line:    
  //  beanConfig.setResourcePackage("helloworld2.rest")

is used instead of
  beanConfig.setResourcePackage("io.swagger.resources");

then the swagger.json returns
Context Path:
/HelloWorld2

Servlet Path:
/
rest

Path Info:
/swagger.json

Query String:
null
Stack Trace
org
.jboss.resteasy.spi.UnhandledException: java.lang.ArrayIndexOutOfBoundsException: 1


I've tried all sorts of permutations of configurations, paths, using xml descriptors and not, but can't find the problem. I would very much prefer to use the non-Spring beanConfig technique.  Where's my mistake?


Ron Ratovsky

unread,
Jul 18, 2016, 6:07:55 PM7/18/16
to swagger-sw...@googlegroups.com

Hi,

 

First thing would be to use the latest version which is 1.5.9.

Second, the output of the swagger.json you share doesn’t make sense as it’s  not even JSON.

Is that the full output you get? Anything else in the logs?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

hancholo

unread,
Jul 19, 2016, 10:18:48 AM7/19/16
to Swagger

 

First thing would be to use the latest version which is 1.5.9.


Good to know.  Someone should update the docs since I can't be the first person to cut and paste the maven dependency.

And that did it!!!!

Thanks so much.

 

Ron Ratovsky

unread,
Jul 19, 2016, 12:00:56 PM7/19/16
to swagger-sw...@googlegroups.com

Maintenance wise, it’d be very difficult to keep the docs updated with the latest version all the time.

However, the docs do say –

"Check the change log to see information about the latest version and the changes from previous versions.”

--

Reply all
Reply to author
Forward
0 new messages