diff --git a/blacklist.txt b/blacklist.txt index 7f8bf2b..12b2f0e 100644 --- a/blacklist.txt +++ b/blacklist.txt @@ -1,11 +1,10 @@ # Transitional file to disable generation for selected services -#assumerole +assumerole #customer #openstack kms airflow -edge customer vpn privateendpoint \ No newline at end of file diff --git a/templates/go/api_test.mustache b/templates/go/api_test.mustache index a90f630..e0e6892 100644 --- a/templates/go/api_test.mustache +++ b/templates/go/api_test.mustache @@ -28,7 +28,19 @@ func Test_{{packageName}}_{{classname}}Service(t *testing.T) { {{#operation}} t.Run("Test {{classname}}Service {{{nickname}}}", func(t *testing.T) { _apiUrlPath := "{{{path}}}"{{#pathParams}} - {{paramName}}Value := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}{{#isUuid}}uuid.NewString(){{/isUuid}}{{^isUuid}}"{{paramName}}-value"{{/isUuid}}{{/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}} + {{^minLength}} + {{^maxLength}} + {{paramName}}Value := {{#isAnyType}}"unspecified type"{{/isAnyType}}{{#isString}}{{#isUuid}}uuid.NewString(){{/isUuid}}{{^isUuid}}"{{paramName}}-value"{{/isUuid}}{{/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}} + {{/maxLength}} + {{/minLength}} + {{#minLength}} + {{paramName}}Value := randString({{minLength}}) + {{/minLength}} + {{#maxLength}} + {{^minLength}} + {{paramName}}Value := randString({{maxLength}}) + {{/minLength}} + {{/maxLength}} _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"{{baseName}}"+"}", url.PathEscape(ParameterValueToString({{paramName}}Value, "{{paramName}}")), -1){{/pathParams}} test{{classname}}ServeMux := http.NewServeMux() diff --git a/templates/go/utils.mustache b/templates/go/utils.mustache index 4bd0284..6b84931 100644 --- a/templates/go/utils.mustache +++ b/templates/go/utils.mustache @@ -362,3 +362,14 @@ func IsNil(i interface{}) bool { type MappedNullable interface { ToMap() (map[string]interface{}, error) } + +const letterRunes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +// randString returns a random string with a specified length. It panics if n <= 0. +func randString(n int) string { + b := make([]byte, n) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +} \ No newline at end of file