Swagger UI - How can I expand all the operations by default?

Gemasoft picture Gemasoft · Nov 27, 2015 · Viewed 14.9k times · Source

All the operations appear collapsed when I open it and I want it to be expanded by default.

Is there any property I need to change to achieve it?

This is my 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);
    }
}

Answer

fehguy picture fehguy · Nov 28, 2015

I believe you can set the docExpansion:"full" when creating swagger-ui.

See https://github.com/swagger-api/swagger-ui#parameters for details.

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'.