File tree 2 files changed +9
-2
lines changed
_examples/advanced-generic-openapi31 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package main
4
4
5
5
import (
6
6
"context"
7
+ "encoding/json"
7
8
"errors"
8
9
"log"
9
10
"net/http"
@@ -36,7 +37,13 @@ func main() {
36
37
close (idleConnsClosed )
37
38
}()
38
39
39
- srv .Handler = NewRouter ()
40
+ r := NewRouter ()
41
+
42
+ // You can access OpenAPI schema of an instrumented *web.Service if you need.
43
+ j , _ := json .Marshal (r .OpenAPISchema ())
44
+ println ("OpenAPI schema head:" , string (j )[0 :300 ], "..." )
45
+
46
+ srv .Handler = r
40
47
srv .Addr = "localhost:8012"
41
48
42
49
log .Println ("http://localhost:8012/docs" )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import (
25
25
"github.com/swaggest/usecase"
26
26
)
27
27
28
- func NewRouter () http. Handler {
28
+ func NewRouter () * web. Service {
29
29
r := openapi31 .NewReflector ()
30
30
s := web .NewService (r )
31
31
You can’t perform that action at this time.
0 commit comments