Skip to content

Commit 26f159a

Browse files
committed
fix: Workaround for a bug in the openapi generator that returns an unspecified type for a path parameter
1 parent ded79be commit 26f159a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

templates/go/api_test.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) {
2828
{{#operation}}
2929
t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) {
3030
_apiUrlPath := "{{{path}}}"{{#pathParams}}
31-
{{paramName}}Value := {{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}}
31+
{{paramName}}Value := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}}
3232
_apiUrlPath = strings.Replace(_apiUrlPath, "{"+"{{baseName}}"+"}", url.PathEscape(ParameterValueToString({{paramName}}Value, "{{paramName}}")), -1){{/pathParams}}
3333

3434
test{{classname}}ServeMux := http.NewServeMux()
@@ -79,7 +79,7 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) {
7979
{{#allParams}}
8080
{{#required}}
8181
{{#isPathParam}}
82-
{{paramName}} := {{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}}
82+
{{paramName}} := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}"{{paramName}}"{{/isString}}{{#isNumber}}123{{/isNumber}}{{#isFloat}}float32(123){{/isFloat}}{{#isDouble}}float64(123){{/isDouble}}{{#isInteger}}int32(123){{/isInteger}}{{#isLong}}int64(123){{/isLong}}{{^isString}}{{^isInteger}}{{defaultValue}}{{/isInteger}}{{/isString}}
8383
{{/isPathParam}}
8484
{{^isPathParam}}
8585
{{#isPrimitiveType}}

0 commit comments

Comments
 (0)