feat(ui): configure default expansion depth for models (#158)

* feat(ui): configure default expansion depth for models

This commit adds possibility to configure defaultModelsExpandDepth,
which controls how models (at the bottom of the API doc) are displayed.

Default value is 1, but it can be set to -1 completely hide the models.

https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#display

* doc: update README.md

Added Configuration section describing available configuration options.
This commit is contained in:
Anton Troyanov
2021-09-25 01:45:34 +03:00
committed by GitHub
parent 92cfa4c8ef
commit 6433b1c297
3 changed files with 53 additions and 10 deletions
+23 -1
View File
@@ -126,4 +126,26 @@ Demo project tree, `swag init` is run at relative `.`
├── go.mod
├── go.sum
└── main.go
```
```
## Configuration
You can configure Swagger using different configuration options
```go
func main() {
r := gin.New()
ginSwagger.WrapHandler(swaggerFiles.Handler,
ginSwagger.URL("http://localhost:8080/swagger/doc.json"),
ginSwagger.DefaultModelsExpandDepth(-1)))
r.Run()
}
```
| Option | Type | Default | Description |
|--------------------------|--------|------------|---------------------------------------------------------------------------|
| URL | string | "doc.json" | URL pointing to API definition |
| DeepLinking | bool | true | Swagger deeplinking configuration |
| DefaultModelsExpandDepth | int | 1 | Default expansion depth for models (set to -1 completely hide the models) |