api docs not listing paths when i use @PathVariable annotation in my controller
BoinaRamesh opened this issue ยท 14 comments
I am using spring boot application with below springfox dependencies.
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
@RequestMapping(value = "/{orderNumber}/extend",
method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> extend(
@PathVariable String orderNumber,
HttpServletRequest httpRequest,
@Valid @RequestBody(required = false) ExtendRequest request,
BindingResult bindingResult)
{ }
As i mentioned above if i use @PathVariable for orderNumber then i couldn't see paths in api docs (http://localhost:8130/modifications/v2/api-docs)
After debug and removed the @PathVariable then i can able to see the paths in api-docs.
@dilipkrish Please provide your valuable inputs on this issue?
During server startup noticed below exception: but still server started.
{
"@timestamp": "2018-07-10T15:11:31.170-05:00",
"@version": 1,
"level": "ERROR",
"level_value": 40000,
"logger_name": "springfox.documentation.spring.web.scanners.ApiDescriptionReader",
"message": "Skipping process path[/{orderNumber}/extend], method[pickupExtend] as it has an error.",
"stack_trace": "com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.PathVariable.name()Ljava/lang/String;
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2212)
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:134)
at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:71)
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:101)
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:167)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:874)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.tgt.post.order.purchase.app.PostOrderPurchaseApp.main(PostOrderPurchaseApp.java:37)
Caused by: java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.PathVariable.name()Ljava/lang/String;
at springfox.documentation.spring.web.readers.parameter.ParameterRequiredReader.isRequired(ParameterRequiredReader.java:92)
at springfox.documentation.spring.web.readers.parameter.ParameterRequiredReader.apply(ParameterRequiredReader.java:61)
at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.parameter(DocumentationPluginsManager.java:106)
at springfox.documentation.spring.web.readers.operation.OperationParameterReader.readParameters(OperationParameterReader.java:103)
at springfox.documentation.spring.web.readers.operation.OperationParameterReader.apply(OperationParameterReader.java:75)
at springfox.documentation.spring.web.plugins.DocumentationPluginsManager.operation(DocumentationPluginsManager.java:120)
at springfox.documentation.spring.web.readers.operation.ApiOperationReader.read(ApiOperationReader.java:73)
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)
... 25 common frames omitted
",
"thread_name": "main"
}
You need to be on spring 4.3.3 or over for this.
@dilipkrish I'm using spring 4.3.2 RELEASE and spring-boot 1.4.0 RELEASE
That explains why you're seeing this error
@dilipkrish After upgrading spring version its working. Thank you so much for your help.
You're welcome! FYI this issue is fixed in the latest version 3.0.0 too (not released yet)
@dilipkrish , Is there no other workaround for this issue except upgrading the spring version - a lower version of springfox? Is there a release date planned for 3.0.0 where this issue is fixed?
Thanks.
Update - A random older v2.4.0 doesnt give this issue.
In general only one version is supported @deepti-hinge
@dilipkrish Is there a release date planned for 3.0.0 ?
I'm just returning after a OSS vacation, should be in the next few weeks @ricardo-ropelli
So what is the version of spring and springboot should one use with swagger 2.9.2?
You need to be on spring 4.3.3 or over for this.
I have the same question with spring 4.2.3, but I can't upgrade the spring version to 4.3.3, is there any other ways to fix the problems?
I am using swagger2.9.2
Updated: by using swagger 2.8.0 to fix it
springfox 2.9.2 supports spring 4.x. @baofeidyz Curious what error you're getting with 4.3.3.
@baofeidyz, Did you fix the issue with swagger 2.8.0 version?
@dilipkrish, when latest version 3.0.0 is planned?
As am also facing this issue but we can't upgrade spring version from 4.1.6 to 4.3.3