mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 09:50:00 +08:00
feature/goctl-api-swagger (#4780)
This commit is contained in:
25
tools/goctl/api/swagger/swagger_test.go
Normal file
25
tools/goctl/api/swagger/swagger_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package swagger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_pathVariable2SwaggerVariable(t *testing.T) {
|
||||
testCases := []struct {
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{input: "/api/:id", expected: "/api/{id}"},
|
||||
{input: "/api/:id/details", expected: "/api/{id}/details"},
|
||||
{input: "/:version/api/:id", expected: "/{version}/api/{id}"},
|
||||
{input: "/api/v1", expected: "/api/v1"},
|
||||
{input: "/api/:id/:action", expected: "/api/{id}/{action}"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
result := pathVariable2SwaggerVariable(tc.input)
|
||||
assert.Equal(t, tc.expected, result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user