feature/goctl-api-swagger (#4780)

This commit is contained in:
kesonan
2025-04-17 22:38:55 +08:00
committed by GitHub
parent 801c283478
commit 9c478626d2
38 changed files with 2445 additions and 23 deletions

View 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)
}
}