swaggest / rest

Web services with OpenAPI and JSON Schema done quick in Go
https://pkg.go.dev/github.com/swaggest/rest
MIT License
335 stars 17 forks source link

Data Schema's not showing on swagger docs site #171

Closed shortwavedave closed 10 months ago

shortwavedave commented 10 months ago

Describe the bug Data Schema's not showing on swagger docs site. Usually the schema is near the bottom. The json schema looks correct image

To Reproduce

git clone https://github.com/swaggest/rest.git
cd /home/david/src/swaggest_ex/_examples/advanced-generic-openapi31
go get ./..
go run .

Expected behavior At the bottom of the docs site there should be a section for schema

vearutop commented 10 months ago

This is a default behavior, defined in

        "defaultModelsExpandDepth": "-1", // Hides schemas, override with value "1" in Config.SettingsUI to show schemas.

https://github.com/swaggest/swgui/blob/v1.7.2/internal/index.tpl.go#L29

You can disable it with custom settings for swgui.

    // Swagger UI endpoint at /docs.
    s.Docs("/docs", func(title, schemaURL, basePath string) http.Handler {
        return swguiv5.NewHandlerWithConfig(swgui.Config{
            Title:       title,
            SwaggerJSON: schemaURL,
            BasePath:    basePath,
            SettingsUI: map[string]string{
                "defaultModelsExpandDepth": "1",
            },
        })
    })

instead of

    // Swagger UI endpoint at /docs.
    s.Docs("/docs", swgui.New)
shortwavedave commented 10 months ago

thank you!