Skip to content

add docExpansion parameter #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ internal object SwaggerUI {
}


// see https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration for reference
/**
* See [Configuration | Swagger Docs](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration) for reference
*/
@Suppress("CyclomaticComplexMethod")
private fun buildProperties(config: SwaggerUIConfig, openApiUrls: Map<String, String>): String {
return PropertyBuilder().also { properties ->
Expand Down Expand Up @@ -96,6 +98,7 @@ internal object SwaggerUI {
}
properties["tryItOutEnabled"] = config.tryItOutEnabled
properties["requestSnippetsEnabled"] = config.requestSnippetsEnabled
properties["docExpansion"] = config.docExpansion

// Network
properties["oauth2RedirectUrl"] = config.oauth2RedirectUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.smiley4.ktorswaggerui.config

/**
* Configuration for the swagger ui.
* See https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration
* See [Configuration | Swagger Docs](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration)
*/
class SwaggerUIConfig internal constructor() {

Expand Down Expand Up @@ -98,6 +98,14 @@ class SwaggerUIConfig internal constructor() {
*/
var requestSnippetsEnabled: Boolean = true

/**
* `String=["list"*, "full", "none"]`.
* 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).
*/
var docExpansion: String? = null

// NETWORK ========================================

/**
Expand Down Expand Up @@ -127,7 +135,8 @@ class SwaggerUIConfig internal constructor() {
* List of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations.
* This does not filter the operations from the display.
*/
var supportedSubmitMethods: Collection<String> = setOf("get", "put", "post", "delete", "options", "head", "patch", "trace")
var supportedSubmitMethods: Collection<String> =
setOf("get", "put", "post", "delete", "options", "head", "patch", "trace")


/**
Expand Down