File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ func (s *App) Sync() {
6565 for _ , e := range s .endpoints {
6666 s .framework .Register (e .path , e .method , s .createHandler (e .handlers ... ))
6767 if e .addToSpec {
68- s .spec .Register (e .path , e .method , e .handlers ... )
68+ s .spec .Register (s . framework . GetOpenAPICompatiblePathPattern ( e .path ) , e .method , e .handlers ... )
6969 }
7070 }
7171}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package fiberframework
33import (
44 "net/http"
55 "net/http/httptest"
6+ "strings"
67
78 "github.com/go-simpl/simplapi/pkg/context"
89 "github.com/go-simpl/simplapi/pkg/framework"
@@ -25,6 +26,16 @@ func (f *fiberFramework) GetNativeApp() interface{} {
2526 return f .app
2627}
2728
29+ func (f * fiberFramework ) GetOpenAPICompatiblePathPattern (path string ) string {
30+ pathParts := strings .Split (path , "/" )
31+ for i , part := range pathParts {
32+ if strings .HasPrefix (part , ":" ) {
33+ pathParts [i ] = "{" + part [1 :] + "}"
34+ }
35+ }
36+ return strings .Join (pathParts , "/" )
37+ }
38+
2839func (f * fiberFramework ) Register (path string , method string , handler framework.FrameworkHandler ) {
2940 switch method {
3041 case http .MethodGet :
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ func (g *ginFramework) GetNativeApp() interface{} {
2727 return g .engine
2828}
2929
30+ func (g * ginFramework ) GetOpenAPICompatiblePathPattern (path string ) string {
31+ return path
32+ }
33+
3034func (g * ginFramework ) Register (path string , method string , handler framework.FrameworkHandler ) {
3135 switch method {
3236 case http .MethodGet :
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ type Framework interface {
1414 Shutdown () error
1515
1616 GetNativeApp () interface {}
17+ GetOpenAPICompatiblePathPattern (path string ) string
1718
1819 TestRequest (req * http.Request ) (* http.Response , error )
1920}
You can’t perform that action at this time.
0 commit comments