Issue with swagger springmvc 0.5.2

282 views
Skip to first unread message

pragnya p

unread,
Apr 25, 2015, 4:12:37 AM4/25/15
to swagger-sw...@googlegroups.com
Hi ,

I started exploring swagger spring mvc last week . To start with I found documentations on swagger springmvc 0.5.2 integration (http://www.3pillarglobal.com/insights/restful-api-documentation-using-swagger-and-spring-mvc) quite easy to follow, so I went ahead with it.
I was successful in exposing my services in swagger ui   but I am struggling  a bit with my model classes.
The swagger ui shows undefined type for object type parameters. @APiModel annotations is not very useful.

my dependency:
com.mangofactory:swagger-springmvc:0.5.2

my applicationContext.xml:
<bean id="documentationConfig" class="com.mangofactory.swagger.configuration.DocumentationConfig"/>
I am including my swagger.properties here

My services are all annotated with spring and swagger annotations.

I am struggling with methods taking object type parameters:
@ApiModel(type = TestModel.class)
public TestModel viewModel(@ApiParam(name="testModel")@RequestBody testModel)

Swagger ui shows undefined type for testModel param. Please let me know what am I missing or I should follow a different approach.
Any pointers will be helpful.

Thanks,
Pragnya


  

Ron Ratovsky

unread,
Apr 26, 2015, 5:55:58 AM4/26/15
to swagger-sw...@googlegroups.com
If this is a new version, please use the latest version of swagger-springmvc, which was renamed to springfox.

You can find more information on it here - https://github.com/springfox/springfox.

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

pragnya p

unread,
Apr 26, 2015, 6:04:00 AM4/26/15
to swagger-sw...@googlegroups.com

I want to expose my restful services via swagger ui so that I can interact better with those services. Do you have any documentation that is easy to follow..
Thanks..

You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/GON9-hgPecY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.

Ron Ratovsky

unread,
Apr 26, 2015, 6:08:25 AM4/26/15
to swagger-sw...@googlegroups.com
If your web service is built using spring-mvc, then springfox is probably your best bet. You'd have to check the documentation they provide in their repository.

pragnya p

unread,
Apr 26, 2015, 6:13:30 AM4/26/15
to swagger-sw...@googlegroups.com

I have my spring application on top of which I wanted to have this swagger ui..so initially I thought swagger spring mvc along with swagger ui is the thing that I require.. Even I was successful in integrating the features on top of my servlet. The problem is with model schema ..
See there are many ways people have implemented it ..so am a bit confused . OK will try exploring springfox..
Thanks a ton for your quick turnaround

pragnya p

unread,
Apr 26, 2015, 11:10:58 AM4/26/15
to swagger-sw...@googlegroups.com

my dependency:
compile  'io.springfox:springfox-swagger2:2.0.0'
In applicationContext.xml I added the bean 
<context:component-scan base-package="path.to.mypackage" />
<mvc:annotation-driven/>
<bean class="springfox.documentation.swagger.configuration.SwaggerCommonConfiguration" />
Am getting below error in my tomcat log:
==============================================================
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiModelBuilder' defined in URL [jar:file:/codemill/pandapra/tomcat/apache-tomcat-7.0.57/webapps/ROOT/WEB-INF/lib/springfox-swagger-common-2.0.0.jar!/springfox/documentation/swagger/schema/ApiModelBuilder.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.fasterxml.classmate.TypeResolver]: : No qualifying bean of type [com.fasterxml.classmate.TypeResolver] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.fasterxml.classmate.TypeResolver] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:747)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1115)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.fasterxml.classmate.TypeResolver] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1118)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:967)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:862)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:811)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:739)
        ... 28 more
========================================================
Any trivial thing that I am missing??

Ron Ratovsky

unread,
Apr 26, 2015, 11:56:32 AM4/26/15
to swagger-sw...@googlegroups.com
No idea. Springfox is a community contribution and I don't have any specific knowledge of it. Its authors monitor this group too, but you can also open an issue directly on their repository.
Reply all
Reply to author
Forward
0 new messages