question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support REST Controllers with default empty @RequestMapping (without any @RequestMethod)

See original GitHub issue

I’m having trouble getting this to work. I’ve started with a working SpringBoot (v2.2.2) app with a working @RestController. To get springdoc to work I’ve included the dependency in my pom, built and started my service. I’ve then browsed to the api-docs endpoint and I get : {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost:8081","description":"Generated server url"}],"paths":{},"components":{}}

Am I missing a step? I was assuming at runtime it would scan my code, find the @RestController, find the @RequestMapping methods and generate the api from that.

As a second attempt, I decided to annotate one of my methods with swagger @Operation annotations and still things don’t get picked up.

Lastly, I tried specifying the package with my Controller manually using springdoc.packagesToScan and that didn’t work either.

This feels like springdoc isn’t seeing my Controller… even though spring does… it’s perfectly active and it works…

Not sure what I’m missing…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maratondiadelvidrierocommented, Sep 26, 2020

I had the same issue and solved by replacing @Controller by @RestController. It will be very good to indicate this in the documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to have empty RequestParam values use the ...
You could explicitly set it to your default value in the controller method: @RequestMapping(value = "/test", method = RequestMethod.
Read more >
Using the Spring @RequestMapping Annotation - DZone
This annotation maps HTTP requests to handler methods of MVC and REST controllers. In this post, you'll see how versatile the @RequestMapping ......
Read more >
Spring MVC @RequestMapping Annotation Example with ...
@RequestMapping default method: If value is empty for a method, it works as default method for the controller class. For example:.
Read more >
RequestMapping (Spring Framework 6.0.2 API)
NOTE: A handler method that is not mapped to any path explicitly is effectively mapped to an empty path. Since: 4.2. Default: {}....
Read more >
Using @RequestMapping without path on a handler method
If there's no @RequestMapping used on the class level and @RequestMapping without path used on a method then it will act as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found