Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable default response massages SpringDoc Open API 3

I want to migrate from SpringFox library to SpringDoc in order to generate API docs in Open API v3 format. In my SpringFox configuration, I have disabled default response messages:

@Bean
public Docket publicApi(ServletContext servletContext) {
    Docket docket = new Docket(DocumentationType.SWAGGER_2)
        ...
        .useDefaultResponseMessages(false);

But I can't find a way to do it in SpringDoc. Migration guide says "remove Docket and use application.properties instead". But there is no such property.

SpringFox version - 2.9.2 and SpringDoc version - 1.5.2

Is it possible to disable default response messages in SpringDoc?

Thanks

like image 848
Yurii_P Avatar asked Sep 06 '25 03:09

Yurii_P


1 Answers

In order to disable responses described in @ControllerAdvice you should add

springdoc.override-with-generic-response=false

to .properties file

By default, it's set to "true" which automatically adds @ControllerAdvice responses to all generated responses. You can find it in docs

Thanks a lot to bnasslahsen for answering my questions on springdoc github

like image 179
Yurii_P Avatar answered Sep 09 '25 18:09

Yurii_P