Apiresponse differences in Swagger 1 and Swagger 2

Source: Internet
Author: User

Write code at random in 1,

In 2, you will be prompted

Com.google.common.util.concurrent.UncheckedExecutionException:java.lang.IllegalArgumentException:No Matching constant for [1]
At Com.google.common.cache.localcache$segment.get (localcache.java:2214)
At Com.google.common.cache.LocalCache.get (localcache.java:4053)
At Com.google.common.cache.LocalCache.getOrLoad (localcache.java:4057)
At Com.google.common.cache.localcache$localloadingcache.get (localcache.java:4986)
At com.google.common.cache.localcache$localloadingcache.getunchecked (localcache.java:4992)
At Springfox.documentation.spring.web.scanners.CachingOperationReader.read (cachingoperationreader.java:57)
At Springfox.documentation.spring.web.scanners.ApiDescriptionReader.read (apidescriptionreader.java:70)
At Springfox.documentation.spring.web.scanners.ApiListingScanner.scan (apilistingscanner.java:89)
At Springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan (apidocumentationscanner.java:69)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation ( documentationpluginsbootstrapper.java:105)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent ( documentationpluginsbootstrapper.java:91)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent ( DOCUMENTATIONPLUGINSBOOTSTRAPPER.JAVA:53)
At Org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener ( simpleapplicationeventmulticaster.java:151)
At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:128)
At Org.springframework.context.support.AbstractApplicationContext.publishEvent (Abstractapplicationcontext.java : 331)
At Org.springframework.context.support.AbstractApplicationContext.finishRefresh (Abstractapplicationcontext.java : 773)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:483)
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.eclipse.jetty.server.handler.ContextHandler.callContextInitialized (contexthandler.java:782)
At Org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized (servletcontexthandler.java:424)
At Org.eclipse.jetty.server.handler.ContextHandler.startContext (contexthandler.java:774)
At Org.eclipse.jetty.servlet.ServletContextHandler.startContext (servletcontexthandler.java:249)
At Org.eclipse.jetty.webapp.WebAppContext.startContext (webappcontext.java:1242)
At Org.eclipse.jetty.server.handler.ContextHandler.doStart (contexthandler.java:717)
At Org.eclipse.jetty.webapp.WebAppContext.doStart (webappcontext.java:494)
At Org.mortbay.jetty.plugin.JettyWebAppContext.doStart (jettywebappcontext.java:298)
At Org.eclipse.jetty.util.component.AbstractLifeCycle.start (abstractlifecycle.java:64)
At ORG.MORTBAY.JETTY.PLUGIN.JETTYRUNMOJO.RESTARTWEBAPP (jettyrunmojo.java:435)
At Org.mortbay.jetty.plugin.jettyrunmojo$1.fileschanged (jettyrunmojo.java:394)
At Org.eclipse.jetty.util.Scanner.reportBulkChanges (scanner.java:691)
At Org.eclipse.jetty.util.Scanner.reportDifferences (scanner.java:551)
At Org.eclipse.jetty.util.Scanner.scan (scanner.java:403)
At Org.eclipse.jetty.util.scanner$1.run (scanner.java:353)
At Java.util.TimerThread.mainLoop (timer.java:555)
At Java.util.TimerThread.run (timer.java:505)
caused by:java.lang.IllegalArgumentException:No matching constant for [1]
At Org.springframework.http.httpstatus$series.valueof (httpstatus.java:524)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.isSuccessful ( swaggerresponsemessagereader.java:148)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.read ( swaggerresponsemessagereader.java:105)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.apply ( swaggerresponsemessagereader.java:74)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsManager.operation ( documentationpluginsmanager.java:113)
At Springfox.documentation.spring.web.readers.operation.ApiOperationReader.read (apioperationreader.java:80)
At Springfox.documentation.spring.web.scanners.cachingoperationreader$1.load (cachingoperationreader.java:50)
At Springfox.documentation.spring.web.scanners.cachingoperationreader$1.load (cachingoperationreader.java:48)
At Com.google.common.cache.localcache$loadingvaluereference.loadfuture (localcache.java:3628)
At Com.google.common.cache.localcache$segment.loadsync (localcache.java:2336)
At Com.google.common.cache.localcache$segment.lockedgetorload (localcache.java:2295)
At Com.google.common.cache.localcache$segment.get (localcache.java:2208)
... More
[WARNING] Failed startup of the context O.m.j.p.jettywebappcontext{/,[file:/e:/homegit/zhangbaowei/home-news/autonews-webapi/src /main/webapp/, jar:file:/d:/javatools/maven/my_local_repository/io/springfox/springfox-swagger-ui/2.4.0/ springfox-swagger-ui-2.4.0.jar!/meta-inf/resources/]},file:/e:/homegit/zhangbaowei/home-news/autonews-webapi/ src/main/webapp/
Com.google.common.util.concurrent.UncheckedExecutionException:java.lang.IllegalArgumentException:No Matching constant for [1]
At Com.google.common.cache.localcache$segment.get (localcache.java:2214)
At Com.google.common.cache.LocalCache.get (localcache.java:4053)
At Com.google.common.cache.LocalCache.getOrLoad (localcache.java:4057)
At Com.google.common.cache.localcache$localloadingcache.get (localcache.java:4986)
At com.google.common.cache.localcache$localloadingcache.getunchecked (localcache.java:4992)
At Springfox.documentation.spring.web.scanners.CachingOperationReader.read (cachingoperationreader.java:57)
At Springfox.documentation.spring.web.scanners.ApiDescriptionReader.read (apidescriptionreader.java:70)
At Springfox.documentation.spring.web.scanners.ApiListingScanner.scan (apilistingscanner.java:89)
At Springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan (apidocumentationscanner.java:69)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation ( documentationpluginsbootstrapper.java:105)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent ( documentationpluginsbootstrapper.java:91)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent ( DOCUMENTATIONPLUGINSBOOTSTRAPPER.JAVA:53)
At Org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener ( simpleapplicationeventmulticaster.java:151)
At Org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent ( simpleapplicationeventmulticaster.java:128)
At Org.springframework.context.support.AbstractApplicationContext.publishEvent (Abstractapplicationcontext.java : 331)
At Org.springframework.context.support.AbstractApplicationContext.finishRefresh (Abstractapplicationcontext.java : 773)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:483)
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.eclipse.jetty.server.handler.ContextHandler.callContextInitialized (contexthandler.java:782)
At Org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized (servletcontexthandler.java:424)
At Org.eclipse.jetty.server.handler.ContextHandler.startContext (contexthandler.java:774)
At Org.eclipse.jetty.servlet.ServletContextHandler.startContext (servletcontexthandler.java:249)
At Org.eclipse.jetty.webapp.WebAppContext.startContext (webappcontext.java:1242)
At Org.eclipse.jetty.server.handler.ContextHandler.doStart (contexthandler.java:717)
At Org.eclipse.jetty.webapp.WebAppContext.doStart (webappcontext.java:494)
At Org.mortbay.jetty.plugin.JettyWebAppContext.doStart (jettywebappcontext.java:298)
At Org.eclipse.jetty.util.component.AbstractLifeCycle.start (abstractlifecycle.java:64)
At ORG.MORTBAY.JETTY.PLUGIN.JETTYRUNMOJO.RESTARTWEBAPP (jettyrunmojo.java:435)
At Org.mortbay.jetty.plugin.jettyrunmojo$1.fileschanged (jettyrunmojo.java:394)
At Org.eclipse.jetty.util.Scanner.reportBulkChanges (scanner.java:691)
At Org.eclipse.jetty.util.Scanner.reportDifferences (scanner.java:551)
At Org.eclipse.jetty.util.Scanner.scan (scanner.java:403)
At Org.eclipse.jetty.util.scanner$1.run (scanner.java:353)
At Java.util.TimerThread.mainLoop (timer.java:555)
At Java.util.TimerThread.run (timer.java:505)
caused by:java.lang.IllegalArgumentException:No matching constant for [1]
At Org.springframework.http.httpstatus$series.valueof (httpstatus.java:524)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.isSuccessful ( swaggerresponsemessagereader.java:148)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.read ( swaggerresponsemessagereader.java:105)
At Springfox.documentation.swagger.readers.operation.SwaggerResponseMessageReader.apply ( swaggerresponsemessagereader.java:74)
At Springfox.documentation.spring.web.plugins.DocumentationPluginsManager.operation ( documentationpluginsmanager.java:113)
At Springfox.documentation.spring.web.readers.operation.ApiOperationReader.read (apioperationreader.java:80)
At Springfox.documentation.spring.web.scanners.cachingoperationreader$1.load (cachingoperationreader.java:50)
At Springfox.documentation.spring.web.scanners.cachingoperationreader$1.load (cachingoperationreader.java:48)
At Com.google.common.cache.localcache$loadingvaluereference.loadfuture (localcache.java:3628)
At Com.google.common.cache.localcache$segment.loadsync (localcache.java:2336)
At Com.google.common.cache.localcache$segment.lockedgetorload (localcache.java:2295)
At Com.google.common.cache.localcache$segment.get (localcache.java:2208)
... More

Originally, the Code in 2 is hooked up with httpstatus, so you can only write Httpstaus related code

  @ApiResponses (value = {
             @ApiResponse (code = $, message = "Success"),  //correct
@ApiResponse (Code = 302, message = "Send again later"),//correct
@ApiResponse (code = 2, message = "exceeds limit"),//This is wrong.
})

Apiresponse differences in Swagger 1 and Swagger 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.