spring - Swagger UI - 默认情况下如何扩展所有操作?

标签 spring api spring-mvc swagger swagger-ui

当我打开它时所有操作都显示为折叠状态,我希望它默认展开。

我需要更改任何属性来实现它吗?

这是我的 Swagger bean :

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket restApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .paths(regex("/api/.*"))
                .build()
                .directModelSubstitute(XMLGregorianCalendar.class, Date.class)
                .apiInfo(apiInfo())                
                .useDefaultResponseMessages(false);
    }
}

最佳答案

相信你可以在创建swagger-ui的时候设置docExpansion:"full"

https://github.com/swagger-api/swagger-ui#parameters了解详情。

docExpansion: Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default is 'list'.

关于spring - Swagger UI - 默认情况下如何扩展所有操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33948742/

相关文章:

java - CamelContext 已加载,但路由定义为空

java - Spring Data JPA Select Distinct

c# - 有没有办法在 C# 中限制 API 的处理器资源?

java - 如何从 REST URL 获取路径变量?

spring - log4j2 中 xwEx 的含义?

xml - Spring <sws :interceptors> to annotation based configuration

api - 如何从linkedin获取用户和页面/公司帖子

javascript - 继承了一个引用 fast.fonts.net 的网站 - 它是什么?

java - 使用 jaxb 注释映射 XML 子子项

java - @PreAuthorize 中的 hasRole 在 Spring 中从哪里获取其值?