简体   繁体   中英

How can I expose my Rest services in multiple swagger pages.

I am using Spring boot to create some Rest services. How can I expose my Rest services in multiple swagger pages. For example All delete methods be in a separated page!

You may use tags to alter the grouping like explained here : Grouping Operations With Tags .

Here is an example annotation you could have on your controller methods :

@ApiOperation(tags = { "delete" }, value = "this API operation will be grouped under the delete section", nickname = "myMethod")

If you are using springdoc-openapi you can create multiple @RestController classes and separate them into Groups as scribed here .

As described int to the link above you have to enable the entry springdoc.api-docs.groups.enabled=true

And create a Group in your config

@Bean
public GroupedOpenApi storeOpenApi() {
    String paths[] = {"/store/**"};
    return GroupedOpenApi.builder().setGroup("stores").pathsToMatch(paths)
            .build();
}

The store open-api json will be available on http://host:port/v3/api-docs/store

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM