2

I enabled API documentation using Swagger 2.6.1 in my spring boot app. The page(swagger-ui.html) loads fine but controller documentation contains all the verbs(PUT, GET, PATCH, POST, etc) even if my controller only has a GET operation. How can I disable the other verbs in the UI doc?

enter image description here

alltej
  • 6,787
  • 10
  • 46
  • 87

1 Answers1

3

This happens when you have mapping like this in your controller

@RequestMapping(value = "/productDetails")

Springfox cannot identify what is the requestMethod hence it provides all mapping.(Eventhough the default is GET)

If you change this to

@RequestMapping(value = "/productDetails", method = RequestMethod.GET)  

Then you will see only GET mapping and not others.
If you use newer versions of Sprinboot, you can use @GetMapping or @PostMapping instead of @RequestMapping

pvpkiran
  • 25,582
  • 8
  • 87
  • 134