Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service description has no api's as the path regular expression does not match any of the service #1125

Closed
irfandawood opened this issue Jan 6, 2016 · 9 comments
Labels
Milestone

Comments

@irfandawood
Copy link

I am trying to set up Swagger 2 using Springfox in my Spring mvc based application. I am not using Spring Boot.

When I use .paths(PathSelectors.regex("/rest/.*")), I can see the following json when I hit http://localhost:8080/myservice/rest/v2/api-docs. Apparently its only picking up .apiInfo() but nothing from my actual RestController.

"swagger":"2.0","info":{"description":"This is a description of your API.","version":"API TOS","title":"My Project's REST API","termsOfService":"me@wherever.com","contact":{"name":"API License"},"license":{"name":"API License URL"}},"host":"localhost:8080","basePath":"/myservice"}

Any idea?

@dilipkrish
Copy link
Member

Can you try removing the paths(...) and see if you see the services you expect to see. If you do see them then I think there is a problem with your regex. Also try replacing the regex with .*/rest/.* and see if that makes a difference

@dilipkrish dilipkrish added this to the 2.4.0 milestone Jan 6, 2016
@dilipkrish dilipkrish changed the title Swagger only showing information from apiInfo() Service description has no api's as the path regular expression does not match any of the service Jan 6, 2016
@irfandawood
Copy link
Author

Dear dilipkrish,
Thanks for your reply.
If I remove paths(...) then I get the following error
Multiple entries with same key: links=springfox.documentation.schema.ModelProperty@274f9f and links=springfox.documentation.schema.ModelProperty@dc8e60

paths("./rest/.") also didn't make any difference. I mean no error but no api either.

@dilipkrish
Copy link
Member

Could you share the stacktrace.

@irfandawood
Copy link
Author

Yes sure!

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Multiple entries with same key: links=springfox.documentation.schema.ModelProperty@132b13 and links=springfox.documentation.schema.ModelProperty@712d0f at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2203) at com.google.common.cache.LocalCache.get(LocalCache.java:3937) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824) at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830) at springfox.documentation.schema.CachingModelProvider.modelFor(CachingModelProvider.java:56) at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:67) at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:88) at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:69) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:101) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:87) at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.onApplicationEvent(DocumentationPluginsBootstrapper.java:50) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:333) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:776) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798) at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444) at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294) at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341) at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:296) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497) at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.maven.plugin.JettyRunMojo.restartWebApp(JettyRunMojo.java:541) at org.eclipse.jetty.maven.plugin.JettyRunMojo$1.filesChanged(JettyRunMojo.java:494) at org.eclipse.jetty.util.Scanner.reportBulkChanges(Scanner.java:685) at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:539) at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391) at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:329) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: java.lang.IllegalArgumentException: Multiple entries with same key: links=springfox.documentation.schema.ModelProperty@132b13 and links=springfox.documentation.schema.ModelProperty@712d0f at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:150) at com.google.common.collect.RegularImmutableMap.checkNoConflictInBucket(RegularImmutableMap.java:104) at com.google.common.collect.RegularImmutableMap.<init>(RegularImmutableMap.java:70) at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:254) at com.google.common.collect.Maps.uniqueIndex(Maps.java:1166) at com.google.common.collect.Maps.uniqueIndex(Maps.java:1140) at springfox.documentation.schema.DefaultModelProvider.modelFor(DefaultModelProvider.java:85) at springfox.documentation.schema.CachingModelProvider$1.load(CachingModelProvider.java:49) at springfox.documentation.schema.CachingModelProvider$1.load(CachingModelProvider.java:47) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197) ... 37 more

@irfandawood
Copy link
Author

Related to:
#997

It works if I use something like this

@RequestMapping(value = "/{id}", method = RequestMethod.GET)

public MyObjectVO getMyObjectById(@PathVariable("id") String id) {
        MyObjectVO myObjectVO =  myService.getMyObjectById(id);
               return myObjectVO;
//      Resource<MyObjectVO> resource = myObjectResourceAssembler.toResource(myObjectVO);
//      return new ResponseEntity<Resource<MyObjectVO>>(resource, HttpStatus.OK);
    }

MyObjectVO extends ResourceSupport class.

@dilipkrish
Copy link
Member

@irfandawood before your change what did the signature look like? and what does your MyObjectVO look like? Im asking so that we can fix this bug

@irfandawood
Copy link
Author

@RequestMapping(value = "/{id}", method = RequestMethod.GET)

public ResponseEntity<Resource<MyObjectVO>> getMyObjectById(@PathVariable("id") String id) {
        MyObjectVO myObjectVO =  myService.getMyObjectById(id);

        Resource<MyObjectVO> resource = myObjectResourceAssembler.toResource(myObjectVO);
        return new ResponseEntity<Resource<MyObjectVO>>(resource, HttpStatus.OK);
    }
public class MyObjectVO extends ResourceSupport {
  private String id;
  // And some more private fields with getter and setter methods
}

@irfandawood
Copy link
Author

Hi @dilipkrish Any idea why it is not working when I use Spring Hateoas Resource class?

@dilipkrish
Copy link
Member

@irfandawood I'll investigate and try to patch if possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants