gradle-swagger-generator-plugin icon indicating copy to clipboard operation
gradle-swagger-generator-plugin copied to clipboard

Configurable collapse mode for swagger UI

Open Michal-Kubricht opened this issue 6 years ago • 2 comments

Describe the feature

Introduce new configuration option to choose collapse mode of generated swagger UI documentation.

The template of swagger UI itself allows easily to define default collapsing behavior over "docExpansion" property in SwaggerUIBundle definition.

See: https://github.com/int128/gradle-swagger-generator-plugin/blob/0857fe89d0134a38678f1f510669b8510d22e33a/src/main/resources/swagger-ui.html#L78

Swagger UI documentation defines "docExpansion" with three available modes "none", "list", "full". All three defines default view on page load and all make sense for different use-cases. See https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#display

Currently, only fixed value with "full" value is possible to be generated using gradle-swagger-generator-plugin.

Why do you want the feature?

It would be really useful to have this option, because there are some use-cases especially for larger projects (with several tags defined) where default behavior of everything expanded is super-annoying for readers. It all the time leads for reader to manually collapse all UI elements and then start using the documentation.

Anyone who wants to workaround this issue can do same trick as me: generate HTML documentation using gradle plugin and then post-process the output by another script. The script does an easy work, replace "docExpansion" value with the one you need in a file index.html. The workaround is a bit fragile and hacky, but works up to this point.

Michal-Kubricht avatar Mar 29 '19 09:03 Michal-Kubricht

Thank you for your suggestion.

At this time the plugin does not support Swagger UI options. You can replace the default index.html with your one after the task. See the example as https://github.com/int128/gradle-swagger-generator-plugin/blob/master/README.md#configure-swagger-ui.

This is because Swagger UI has many options and I don't want to maintain the options.

int128 avatar Mar 30 '19 05:03 int128

just a thought but if this option is a default option present in the json object we should be able to interact with me as i found that i would like it collapsed as well. just a thought. i would not mind trying to contribute this feature.

tjb avatar Apr 18 '19 14:04 tjb