OpenApiCustomiser bean does not contain all info

1.3k views Asked by At

With this controller definition, with a tag:

@RestController
@RequestMapping("/some_path")
@Tag(name = "MyController")
public class MyController {
   ...
}

When trying to customize OpenApi, I can't get the value of tags:

@Bean
public OpenApiCustomiser order() {
    return openApi -> openApi.setTags(openApi.getTags() ...

openApi.getTags() always returns null, I was expecting a list with MyController tag.

Any suggestion?

1

There are 1 answers

0
brianbro On

You can use the OperationCustomizer, which is more relevant for your case:

@Bean
public OperationCustomizer operationCustomizer() {
    return (operation, handlerMethod) -> {
        operation.setTags(operation.getTags()); // to adapt
        //operation.addTagsItem("my new tag");
        return operation;
    };
}