Skip to content
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

How examples/server-complete implements swaggerUI? #2754

Open
Icarus9913 opened this issue Apr 10, 2022 · 2 comments
Open

How examples/server-complete implements swaggerUI? #2754

Icarus9913 opened this issue Apr 10, 2022 · 2 comments

Comments

@Icarus9913
Copy link

Hello! I checked examples/tutorials/todo-list/server-complete source codes and did not find api property useSwaggerUI set to be true or method func (o *TodoListAPI) UseSwaggerUI() is called. But I still can visit swaggerUI with route /docs. How does it possible? Is there any flags did it which I ignored?

Environment

swagger version: 42c184c
OS: darwin

@casualjim
Copy link
Member

The UseSwaggerUI is a toggle between a redoc docs site and a swagger ui docs site.

// UseRedoc for documentation at /docs
func (o *TodoListAPI) UseRedoc() {
o.useSwaggerUI = false
}
// UseSwaggerUI for documentation at /docs
func (o *TodoListAPI) UseSwaggerUI() {
o.useSwaggerUI = true
}

if you want to disable /docs you can use a global middleware that returns not found for the /docs path.

@Icarus9913
Copy link
Author

Icarus9913 commented Apr 11, 2022

Copied by @casualjim :
A server project built by go-swagger owns the capability to provide a UI. And the property 'useSwaggerUI' is a toggle between a redoc docs site and a swagger ui docs site, which could be thought as a UI theme.

The UI is very small, it's a single js you include in a basic html5 page. All the capability provided by 'go-openapi' project.

For details, you can find below:
https://github.com/go-openapi/runtime/blob/master/middleware/redoc.go
https://github.com/go-openapi/runtime/blob/master/middleware/swaggerui.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants