Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions blacklist.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Transitional file to disable generation for selected services
#assumerole
assumerole
#customer
#openstack
kms

airflow
edge
customer
vpn
privateendpoint
14 changes: 13 additions & 1 deletion templates/go/api_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions templates/go/utils.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading