diff --git a/_examples/advanced-generic-openapi31/main.go b/_examples/advanced-generic-openapi31/main.go index 6b31471..aa33ab8 100644 --- a/_examples/advanced-generic-openapi31/main.go +++ b/_examples/advanced-generic-openapi31/main.go @@ -4,6 +4,7 @@ package main import ( "context" + "encoding/json" "errors" "log" "net/http" @@ -36,7 +37,13 @@ func main() { close(idleConnsClosed) }() - srv.Handler = NewRouter() + r := NewRouter() + + // You can access OpenAPI schema of an instrumented *web.Service if you need. + j, _ := json.Marshal(r.OpenAPISchema()) + println("OpenAPI schema head:", string(j)[0:300], "...") + + srv.Handler = r srv.Addr = "localhost:8012" log.Println("http://localhost:8012/docs") diff --git a/_examples/advanced-generic-openapi31/router.go b/_examples/advanced-generic-openapi31/router.go index 93c0063..9e65613 100644 --- a/_examples/advanced-generic-openapi31/router.go +++ b/_examples/advanced-generic-openapi31/router.go @@ -25,7 +25,7 @@ import ( "github.com/swaggest/usecase" ) -func NewRouter() http.Handler { +func NewRouter() *web.Service { r := openapi31.NewReflector() s := web.NewService(r)