0

i have a controller with 2 paths as below, @PostMapping(path = {"/user/vehicle", "/user/car"}) public UserVehicle getUserVehicle(

But i want only "/user/vehicle" to be included in open api doc (and hide the "/user/car") in open api specs/doc. Is there a way to do it?

(i am generating open api specs from code.)

Rajan
  • 49
  • 6

2 Answers2

0

Set the hidden parameter to true in the @Operation annotation as shown in the below example

@Operation(hidden = true)
@PostMapping(path = {"/user/vehicle", "/user/car"})
Debargha Roy
  • 2,320
  • 1
  • 15
  • 34
0

I know this is an old thread, but I stumbled upon it while attempting the same and the solution by @DerbarghaRoy would hide all paths, which dosent answer the question.

To exclude certain paths from your spring boot openapi doc, you can set the path to exclude in your application.yml, such as in the following example:

springdoc:
  pathsToExclude: /user/car

For a more general approach, ant style path patterns or regex can be used to exclude paths here.

Hope this helps anyone looking to accomplish the same