-
-
Notifications
You must be signed in to change notification settings - Fork 524
Support REST Controllers with default empty @RequestMapping (without any @RequestMethod) #378
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
Comments
Hi @neodem, By default, you just need to add the springdoc-ui dependency, and you should see all the API when browsing to /v3/api-docs <dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.28</version>
</dependency> You can have a look a the demos samples: Please read the section of Using GitHub Issues: If you are still facing this problem, please add the sample code or your git repository link to reproduce and this issue will be reopened. |
I have posted on stack overflow with no luck, so I decided to dig into this myself. After a few hours of debugging I figured out what is going on in my situation. when defining a REST Controller, spring allows you to declare If I explicitly define the method: I think that at the least you should mention this in your documentation: "when defining @RequestMapping annotations you must declare a method and not rely on Springs default because springdoc won't find it). I think a better solution would be to come up with a sensible default when nothing is explicity declared in the annotation. |
Your description is now more accurate about the reason why the controller was not displaying. The method value of Note that by default, all the following methods are accepted by Spring 5: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. |
I had the same issue and solved by replacing @controller by @RestController. It will be very good to indicate this in the documentation. |
You can have a look here: |
When I use @RequestMapping without explicitly specifying the HTTP method, and simultaneously set @operation(method = GET) in my controller, the Swagger UI displays all HTTP method types (GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS) for the endpoint. Observed Behavior: Questions:
Environment: |
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..
The text was updated successfully, but these errors were encountered: