Integrating with Swagger Ui

315 views
Skip to first unread message

Guru Yeshwanth

unread,
Sep 21, 2015, 5:01:44 PM9/21/15
to Swagger
Hello,

I am trying to integrate Swagger Ui with the current swagger implementation.

I managed to get swagger up and running using the swagger annotations and now I get the Json output as given below

{"apiVersion":"1.0.2","swaggerVersion":"1.2","apis":[{"path":"/Print service"},{"path":"/user","description":"User REST for Integration Testing"}]}

Now to integrate this with the swagger UI I did the following 


Copied this contents of this dist folder in the below URL

https://github.com/swagger-api/swagger-ui

and pasted it into webapp/WEB_INF folder of my directory

changed the url in the index.xml to point to my project

http://localhost:8080/tester/api-docs

now if I go and get access the URL i should be getting the Ui right?

Please let me know if I am missing anything


Regards,
Guru

Ron Ratovsky

unread,
Sep 22, 2015, 10:18:24 AM9/22/15
to Swagger
If you're getting that output, you're using an old version of swagger-core and should upgrade.

If you just copied the contents of the dist directory, the URL should be the context root of your application.

--
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.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------

Guru Yeshwanth

unread,
Sep 22, 2015, 2:17:54 PM9/22/15
to Swagger
Hello Ron,

Like you said I have tried to upgrade the version of Swagger core but when I changed it to 1.5.0 I get the following errors

package com.wordnik.swagger.annotations does not exist
package com.wordnik.swagger.annotations does not exist 
cannot find symbol package com.wordnik.swagger.jaxrs.config does not exist

 cannot find symbol Bean config

Just to let you know I took out the bean config from my Spring.Xml since it was not working earlier and I have created a separate bootstrap to load swagger config now that I am using 1.5.0 do you think I can revert back to loading all config in the XML?

Please let me know

Ron Ratovsky

unread,
Sep 22, 2015, 2:28:04 PM9/22/15
to Swagger
Try following https://github.com/swagger-api/swagger-core/wiki/1.3--1.5-Migration. Keep in mind the namespace changed from com.wordnik.swagger to io.swagger.

--
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.

Guru Yeshwanth

unread,
Sep 22, 2015, 5:43:32 PM9/22/15
to Swagger
Ron,

I did the migration from 1.3 to 1.5.0 and I tried to access my app using the URL

http://localhost:8080/tester/sw/swagger.json

but all I get is a blank page please check and let me know if I have my applicationContext and Bootstrap right

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>


<bean id="accountService" class="com.guru.learning.apachepoc.service.BenifitService" init-method="init"/>
<bean id="jsonProvider"
class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>

<jaxrs:server id="accountrs" address="/rservice">
<jaxrs:serviceBeans>
<ref bean="accountService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean='jsonProvider' />
</jaxrs:providers>
</jaxrs:server>

<bean id="swaggerResourceJSON" class="io.swagger.jaxrs.listing.ApiListingResource" />
<bean id="swaggerSerializers" class="io.swagger.jaxrs.listing.SwaggerSerializers" />

<!--<bean id="swaggerResourceJSON" class="com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON" />-->
<!--<bean id="swaggerResourceWriter" class="com.wordnik.swagger.jaxrs.listing.ResourceListingProvider" />-->
<!--<bean id="swaggerApiWriter" class="com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider" />-->
<jaxrs:server id="swagger" address="/sw">
<jaxrs:serviceBeans>
<ref bean="accountService" />
<ref bean="swaggerResourceJSON"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="swaggerSerializers"/>
<ref bean='jsonProvider' />
<!--<ref bean="swaggerResourceWriter" />-->
<!--<ref bean="swaggerApiWriter" />-->
</jaxrs:providers>
</jaxrs:server>


</beans>



package com.guru.learning.apachepoc.config;

import io.swagger.jaxrs.config.BeanConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
* Created by gnamathe on 7/30/2015.
*/
public class Bootstrap extends HttpServlet {
Logger log = LoggerFactory.getLogger(Bootstrap.class);

public void init(ServletConfig config) throws ServletException {
super.init(config);

BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setBasePath("http://localhost:8080/tester/");
beanConfig.setResourcePackage("com.guru.learning.apachepoc.service");
        beanConfig.setScan(true);
}
}

am I missing anything here?

On Monday, September 21, 2015 at 2:01:44 PM UTC-7, Guru Yeshwanth wrote:

Ron Ratovsky

unread,
Sep 23, 2015, 8:23:34 AM9/23/15
to Swagger

--
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.
Reply all
Reply to author
Forward
0 new messages