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

Disable ControllerAdvice generic responses per controller endpoint method #2934

Closed
gnfpt opened this issue Mar 7, 2025 · 1 comment
Closed
Labels
question Further information is requested

Comments

@gnfpt
Copy link

gnfpt commented Mar 7, 2025

Currently we have springdoc.override-with-generic-response=false to disable generic responses based on ControllerAdvices.

It's also possible to use @hidden in a ControllerAdvice to hide generic responses from all controllers methods.

But, AFAIK, there's no possibility to disable generic responses on a controller endpoint method.

Something like:

@RestController
@RequestMapping("/greeting")
public class  ExampleController {

  @DisableGenericResponses
  @ReponseStastus(OK) 
  @ApiResponse(responseCode="200")
  @GetMapping
   public  String getGreeting() {
     return "Hello World";
   }

  @ReponseStastus(OK) 
  @ApiResponse(responseCode="200")
  @GetMapping
   public  String sayHi() {
     return "Hi";
   }
}

This would be helpful because it would allow to continue using generic responses based on ControllerAdvices and disable those responses on specific endpoints, as needed.

Thank you

@gnfpt gnfpt changed the title Disabling ControllerAdvice generic responses on a per Controller endpoint method Disabling ControllerAdvice generic responses per controller endpoint method Mar 7, 2025
@gnfpt gnfpt changed the title Disabling ControllerAdvice generic responses per controller endpoint method Disable ControllerAdvice generic responses per controller endpoint method Mar 12, 2025
@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Mar 22, 2025

@gnfpt,

You can customize it based on OperationCustomizer .
For any other options, you can directly propose a PR.

@bnasslahsen bnasslahsen added the question Further information is requested label Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants