OpenAPI

Embeds the Swagger UI, using your OpenAPI specification

This is a module for Project Forge. It embeds the Swagger UI, using your OpenAPI specification

https://github.com/kyleu/projectforge/tree/master/module/openapi

License

Licensed under CC0

Usage

By default, no controller exposes the Swagger UI. To add your own, follow this example, then add a route to it with whatever security you prefer:

1
2
3
4
5
6
7
func OpenAPI(w http.ResponseWriter, r *http.Request) {
controller.Act("openapi", w, r, func(as *app.State, ps *cutil.PageState) (string, error) {
u := "http://localhost:{{{ .Port }}}/assets/openapi.json"
ps.SetTitleAndData("OpenAPI", u)
return controller.Render(w, r, as, &vopenapi.OpenAPI{URL: u}, ps, "breadcrumbs")
})
}