From 919f867ebac1fb934423641ac783f28a24d03cd5 Mon Sep 17 00:00:00 2001 From: Oleksandr Slynko Date: Sun, 7 Jan 2018 03:53:55 +0000 Subject: [PATCH] [go] Fix go client formatting (#7283) * Fix some go client formatting issues * Fix go client go imports * Run `goimports -w .` on examples directory * Sort imports in api * Add new line between each property Before secret feature was used to add new line using two property declaration in the same line. There should be no new line before first property. The easiest way is to use `-first` special property https://github.com/samskivert/jmustache#-first-and--last New line are required so `goimports` won't reformat whitespaces between property name and type. * Change whitespaces to tabs * Fix whitespaces in api_client There is a new line between each service to prevent `goimports` from adding whitespaces between types and names * Fix more whitespaces There was a need to set special delimeter for formatting in the commit. Go slices use curly braces and `jmustache` got confused when found triple curly braces. * Fix whitespaces in configuration.mustache * Fix whitespaces for api response * Support for optional description Do not add whitespace if description is missing * Add new lines between enum values to prevent formatting * Generate go code from current code - imports are not sorted :( - there are extra whitespaces for different languages. I don't know why * Run generate for security tests --- .../src/main/resources/go/api.mustache | 41 ++- .../src/main/resources/go/api_client.mustache | 55 ++-- .../main/resources/go/api_response.mustache | 8 +- .../main/resources/go/configuration.mustache | 32 +-- .../src/main/resources/go/model.mustache | 12 +- .../petstore-security-test/go/README.md | 2 +- .../petstore-security-test/go/api_client.go | 59 ++-- .../petstore-security-test/go/api_response.go | 8 +- .../go/configuration.go | 32 +-- .../petstore-security-test/go/fake_api.go | 31 +- .../petstore-security-test/go/model_return.go | 1 - .../additional_properties_class.go | 1 - .../client/petstore/go/go-petstore/animal.go | 1 - .../go/go-petstore/another_fake_api.go | 28 +- .../petstore/go/go-petstore/api_client.go | 70 ++--- .../petstore/go/go-petstore/api_response.go | 8 +- .../array_of_array_of_number_only.go | 1 - .../go/go-petstore/array_of_number_only.go | 1 - .../petstore/go/go-petstore/array_test.go | 1 - .../petstore/go/go-petstore/capitalization.go | 1 - samples/client/petstore/go/go-petstore/cat.go | 1 - .../petstore/go/go-petstore/category.go | 1 - .../petstore/go/go-petstore/class_model.go | 1 - .../client/petstore/go/go-petstore/client.go | 1 - .../petstore/go/go-petstore/configuration.go | 32 +-- samples/client/petstore/go/go-petstore/dog.go | 1 - .../petstore/go/go-petstore/enum_arrays.go | 1 - .../petstore/go/go-petstore/enum_class.go | 2 + .../petstore/go/go-petstore/enum_test.go | 1 - .../petstore/go/go-petstore/fake_api.go | 269 ++++++++---------- .../go-petstore/fake_classname_tags123_api.go | 26 +- .../petstore/go/go-petstore/format_test.go | 1 - .../go/go-petstore/has_only_read_only.go | 1 - .../client/petstore/go/go-petstore/list.go | 1 - .../petstore/go/go-petstore/map_test.go | 1 - ...perties_and_additional_properties_class.go | 1 - .../go/go-petstore/model_200_response.go | 1 - .../go/go-petstore/model_api_response.go | 1 - .../petstore/go/go-petstore/model_return.go | 1 - .../client/petstore/go/go-petstore/name.go | 1 - .../petstore/go/go-petstore/number_only.go | 1 - .../client/petstore/go/go-petstore/order.go | 1 - .../go/go-petstore/outer_composite.go | 1 - .../petstore/go/go-petstore/outer_enum.go | 2 + samples/client/petstore/go/go-petstore/pet.go | 1 - .../client/petstore/go/go-petstore/pet_api.go | 211 ++++++-------- .../go/go-petstore/read_only_first.go | 1 - .../go/go-petstore/special_model_name.go | 1 - .../petstore/go/go-petstore/store_api.go | 99 +++---- samples/client/petstore/go/go-petstore/tag.go | 1 - .../client/petstore/go/go-petstore/user.go | 1 - .../petstore/go/go-petstore/user_api.go | 194 +++++-------- 52 files changed, 536 insertions(+), 716 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index cf81557adf6..5692c3f3d99 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -4,8 +4,8 @@ package {{packageName}} {{#operations}} import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" {{#imports}} "{{import}}" @@ -18,24 +18,23 @@ var ( ) type {{classname}}Service service - {{#operation}} -/* {{{classname}}}Service {{summary}}{{#notes}} - {{notes}}{{/notes}} +/* {{{classname}}}Service{{#summary}} {{.}}{{/summary}}{{#notes}} +{{notes}}{{/notes}} * @param ctx context.Context for authentication, logging, tracing, etc. -{{#allParams}}{{#required}} @param {{paramName}} {{description}} -{{/required}}{{/allParams}}{{#hasOptionalParams}} @param optional (nil or map[string]interface{}) with one or more of: -{{#allParams}}{{^required}} @param "{{paramName}}" ({{dataType}}) {{description}} -{{/required}}{{/allParams}}{{/hasOptionalParams}} @return {{#returnType}}{{{returnType}}}{{/returnType}}*/ -func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals map[string]interface{}{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}} *http.Response, error) { +{{#allParams}}{{#required}}@param {{paramName}}{{#description}} {{.}}{{/description}} +{{/required}}{{/allParams}}{{#hasOptionalParams}}@param optional (nil or map[string]interface{}) with one or more of: +{{#allParams}}{{^required}} @param "{{paramName}}" ({{dataType}}){{#description}} {{.}}{{/description}} +{{/required}}{{/allParams}}{{/hasOptionalParams}}@return {{#returnType}}{{{returnType}}}{{/returnType}}*/ +func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals map[string]interface{}{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("{{httpMethod}}") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte {{#returnType}} - successPayload {{returnType}} + successPayload {{returnType}} {{/returnType}} ) @@ -46,7 +45,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - {{#allParams}} {{^required}} {{#isPrimitiveType}} @@ -114,7 +112,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{/queryParams}} {{/hasQueryParams}} // to determine the Content-Type header - localVarHttpContentTypes := []string{ {{#consumes}}"{{{mediaType}}}", {{/consumes}} } +{{=<% %>=}} + localVarHttpContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>} +<%={{ }}=%> // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -123,11 +123,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - {{#produces}} - "{{{mediaType}}}", - {{/produces}} - } +{{=<% %>=}} + localVarHttpHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>} +<%={{ }}=%> // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -223,7 +221,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} } {{/returnType}} - return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err } -{{/operation}}{{/operations}} +{{/operation}}{{/operations}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index c8d6afa8e99..38c7a7e2720 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -5,40 +5,42 @@ import ( "bytes" "encoding/json" "encoding/xml" - "fmt" "errors" + "fmt" "io" "mime/multipart" - "golang.org/x/oauth2" - "golang.org/x/net/context" "net/http" "net/url" - "time" "os" "path/filepath" "reflect" "regexp" - "strings" - "unicode/utf8" "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/net/context" + "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the {{appName}} API v{{version}} // In most cases there should be only one, shared, APIClient. type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. - // API Services + // API Services {{#apiInfo}} {{#apis}} {{#operations}} - {{classname}} *{{classname}}Service + + {{classname}} *{{classname}}Service {{/operations}} {{/apis}} {{/apiInfo}} @@ -75,7 +77,6 @@ func atoi(in string) (int, error) { return strconv.Atoi(in) } - // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { @@ -146,18 +147,18 @@ func parameterToString(obj interface{}, collectionFormat string) string { return fmt.Sprintf("%v", obj) } -// callAPI do the request. +// callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) + return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks -func (c *APIClient) ChangeBasePath (path string) { +func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request -func (c *APIClient) prepareRequest ( +func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, @@ -217,7 +218,7 @@ func (c *APIClient) prepareRequest ( // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } - + // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() @@ -263,10 +264,9 @@ func (c *APIClient) prepareRequest ( if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } - + // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - if ctx != nil { // add context to the request @@ -292,18 +292,17 @@ func (c *APIClient) prepareRequest ( // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { - localVarRequest.Header.Add("Authorization", "Bearer " + auth) + localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } - + return localVarRequest, nil } - // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -322,7 +321,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error { } // Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) (error) { +func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } @@ -359,7 +358,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() - + switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" @@ -376,7 +375,6 @@ func detectContentType(body interface{}) string { return contentType } - // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string @@ -399,7 +397,7 @@ func parseCacheControl(headers http.Header) cacheControl { } // CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) (time.Time) { +func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) @@ -407,7 +405,7 @@ func CacheExpires(r *http.Response) (time.Time) { return time.Now() } respCacheControl := parseCacheControl(r.Header) - + if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { @@ -426,7 +424,6 @@ func CacheExpires(r *http.Response) (time.Time) { return expires } -func strlen(s string) (int) { +func strlen(s string) int { return utf8.RuneCountInString(s) } - diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache index 00ab14a5124..a2617ea0680 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_response.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -7,15 +7,15 @@ import ( type APIResponse struct { *http.Response `json:"-"` - Message string `json:"message,omitempty"` + Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. - Operation string `json:"operation,omitempty"` + Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` + RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` + Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index 3a13d41ffdd..1b583e54270 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -17,37 +17,37 @@ func (c contextKey) String() string { var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. - ContextOAuth2 = contextKey("token") + ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. - ContextBasicAuth = contextKey("basic") + ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. - ContextAccessToken = contextKey("accesstoken") + ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request - ContextAPIKey = contextKey("apikey") + ContextAPIKey = contextKey("apikey") ) -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { - Key string - Prefix string + Key string + Prefix string } type Configuration struct { - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - HTTPClient *http.Client + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { @@ -61,4 +61,4 @@ func NewConfiguration() *Configuration { func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/go/model.mustache b/modules/swagger-codegen/src/main/resources/go/model.mustache index 7c9e5c88aab..e69220ae550 100644 --- a/modules/swagger-codegen/src/main/resources/go/model.mustache +++ b/modules/swagger-codegen/src/main/resources/go/model.mustache @@ -11,14 +11,22 @@ type {{{name}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/form const ( {{#allowableValues}} {{#enumVars}} + {{^-first}} + + {{/-first}} {{name}} {{{classname}}} = "{{{value}}}" {{/enumVars}} {{/allowableValues}} ){{/isEnum}}{{^isEnum}}{{#description}} // {{{description}}}{{/description}} type {{classname}} struct { -{{#vars}}{{#description}} - // {{{description}}}{{/description}} +{{#vars}} +{{^-first}} + +{{/-first}} +{{#description}} + // {{{description}}} +{{/description}} {{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"` {{/vars}} }{{/isEnum}}{{/model}}{{/models}} diff --git a/samples/client/petstore-security-test/go/README.md b/samples/client/petstore-security-test/go/README.md index fa4b2d48d8c..d092ab5477f 100644 --- a/samples/client/petstore-security-test/go/README.md +++ b/samples/client/petstore-security-test/go/README.md @@ -56,7 +56,7 @@ Example r, err := client.Service.Operation(auth, args) ``` -Or via OAuth2 module to automaticly refresh tokens and perform user authentication. +Or via OAuth2 module to automatically refresh tokens and perform user authentication. ``` import "golang.org/x/oauth2" diff --git a/samples/client/petstore-security-test/go/api_client.go b/samples/client/petstore-security-test/go/api_client.go index 4d8da312591..7bff3262432 100644 --- a/samples/client/petstore-security-test/go/api_client.go +++ b/samples/client/petstore-security-test/go/api_client.go @@ -14,37 +14,39 @@ import ( "bytes" "encoding/json" "encoding/xml" - "fmt" "errors" + "fmt" "io" "mime/multipart" - "golang.org/x/oauth2" - "golang.org/x/net/context" "net/http" "net/url" - "time" "os" "path/filepath" "reflect" "regexp" - "strings" - "unicode/utf8" "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/net/context" + "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r API v1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r // In most cases there should be only one, shared, APIClient. type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. - // API Services - FakeApi *FakeApiService + // API Services + + FakeApi *FakeApiService } type service struct { @@ -72,7 +74,6 @@ func atoi(in string) (int, error) { return strconv.Atoi(in) } - // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { @@ -143,18 +144,18 @@ func parameterToString(obj interface{}, collectionFormat string) string { return fmt.Sprintf("%v", obj) } -// callAPI do the request. +// callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) + return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks -func (c *APIClient) ChangeBasePath (path string) { +func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request -func (c *APIClient) prepareRequest ( +func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, @@ -180,7 +181,7 @@ func (c *APIClient) prepareRequest ( } } - // add form paramters and file if available. + // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") @@ -214,13 +215,13 @@ func (c *APIClient) prepareRequest ( // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } - + // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } - // Setup path and query paramters + // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err @@ -260,10 +261,9 @@ func (c *APIClient) prepareRequest ( if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } - + // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - if ctx != nil { // add context to the request @@ -289,18 +289,17 @@ func (c *APIClient) prepareRequest ( // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { - localVarRequest.Header.Add("Authorization", "Bearer " + auth) + localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } - + return localVarRequest, nil } - // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -319,7 +318,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error { } // Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) (error) { +func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } @@ -356,7 +355,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() - + switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" @@ -373,7 +372,6 @@ func detectContentType(body interface{}) string { return contentType } - // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string @@ -396,7 +394,7 @@ func parseCacheControl(headers http.Header) cacheControl { } // CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) (time.Time) { +func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) @@ -404,7 +402,7 @@ func CacheExpires(r *http.Response) (time.Time) { return time.Now() } respCacheControl := parseCacheControl(r.Header) - + if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { @@ -423,7 +421,6 @@ func CacheExpires(r *http.Response) (time.Time) { return expires } -func strlen(s string) (int) { +func strlen(s string) int { return utf8.RuneCountInString(s) } - diff --git a/samples/client/petstore-security-test/go/api_response.go b/samples/client/petstore-security-test/go/api_response.go index 8b8f3b928ed..05fd1dc4e90 100644 --- a/samples/client/petstore-security-test/go/api_response.go +++ b/samples/client/petstore-security-test/go/api_response.go @@ -16,15 +16,15 @@ import ( type APIResponse struct { *http.Response `json:"-"` - Message string `json:"message,omitempty"` + Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. - Operation string `json:"operation,omitempty"` + Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` + RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` + Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. diff --git a/samples/client/petstore-security-test/go/configuration.go b/samples/client/petstore-security-test/go/configuration.go index 8dfd09bc59c..b63460d45f0 100644 --- a/samples/client/petstore-security-test/go/configuration.go +++ b/samples/client/petstore-security-test/go/configuration.go @@ -26,37 +26,37 @@ func (c contextKey) String() string { var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. - ContextOAuth2 = contextKey("token") + ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. - ContextBasicAuth = contextKey("basic") + ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. - ContextAccessToken = contextKey("accesstoken") + ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request - ContextAPIKey = contextKey("apikey") + ContextAPIKey = contextKey("apikey") ) -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { - Key string - Prefix string + Key string + Prefix string } type Configuration struct { - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - HTTPClient *http.Client + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { @@ -70,4 +70,4 @@ func NewConfiguration() *Configuration { func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} \ No newline at end of file +} diff --git a/samples/client/petstore-security-test/go/fake_api.go b/samples/client/petstore-security-test/go/fake_api.go index 99f7638fe7d..13d021b9f54 100644 --- a/samples/client/petstore-security-test/go/fake_api.go +++ b/samples/client/petstore-security-test/go/fake_api.go @@ -11,8 +11,9 @@ package swagger import ( - "net/url" + "io/ioutil" "net/http" + "net/url" "strings" "golang.org/x/net/context" ) @@ -24,18 +25,17 @@ var ( type FakeApiService service - /* FakeApiService To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "testCodeInjectEndRnNR" (string) To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - @return */ -func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals map[string]interface{}) ( *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "testCodeInjectEndRnNR" (string) To test code injection *_/ ' \" =end -- \\r\\n \\n \\r +@return */ +func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals map[string]interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -44,13 +44,12 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if err := typeCheckParameter(localVarOptionals["testCodeInjectEndRnNR"], "string", "testCodeInjectEndRnNR"); err != nil { return nil, err } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", "*_/ ' =end -- ", } + localVarHttpContentTypes := []string{"application/json", "*_/ ' =end -- "} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -59,10 +58,7 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - "*_/ ' =end -- ", - } + localVarHttpHeaderAccepts := []string{"application/json", "*_/ ' =end -- "} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -83,9 +79,8 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOpti } defer localVarHttpResponse.Body.Close() if localVarHttpResponse.StatusCode >= 300 { - return localVarHttpResponse, reportError(localVarHttpResponse.Status) + bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) + return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } - diff --git a/samples/client/petstore-security-test/go/model_return.go b/samples/client/petstore-security-test/go/model_return.go index d1a82197416..3616e2759aa 100644 --- a/samples/client/petstore-security-test/go/model_return.go +++ b/samples/client/petstore-security-test/go/model_return.go @@ -12,7 +12,6 @@ package swagger // Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r type ModelReturn struct { - // property description *_/ ' \" =end -- \\r\\n \\n \\r Return_ int32 `json:"return,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/additional_properties_class.go b/samples/client/petstore/go/go-petstore/additional_properties_class.go index ff018d60e14..47449ea592d 100644 --- a/samples/client/petstore/go/go-petstore/additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore/additional_properties_class.go @@ -11,7 +11,6 @@ package petstore type AdditionalPropertiesClass struct { - MapProperty map[string]string `json:"map_property,omitempty"` MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/animal.go b/samples/client/petstore/go/go-petstore/animal.go index 4ae6c33a58a..318e9fddaef 100644 --- a/samples/client/petstore/go/go-petstore/animal.go +++ b/samples/client/petstore/go/go-petstore/animal.go @@ -11,7 +11,6 @@ package petstore type Animal struct { - ClassName string `json:"className"` Color string `json:"color,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/another_fake_api.go b/samples/client/petstore/go/go-petstore/another_fake_api.go index 503ca40cbba..8e1c565507b 100644 --- a/samples/client/petstore/go/go-petstore/another_fake_api.go +++ b/samples/client/petstore/go/go-petstore/another_fake_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "encoding/json" @@ -26,19 +26,18 @@ var ( type AnotherFakeApiService service - /* AnotherFakeApiService To test special tags - To test special tags +To test special tags * @param ctx context.Context for authentication, logging, tracing, etc. - @param body client model - @return Client*/ -func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) { +@param body client model +@return Client*/ +func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Client + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Client ) // create path and map variables @@ -48,9 +47,8 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -59,9 +57,7 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -89,7 +85,5 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } - diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 3c0ed8e3d52..d2f8f3092c3 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -14,42 +14,49 @@ import ( "bytes" "encoding/json" "encoding/xml" - "fmt" "errors" + "fmt" "io" "mime/multipart" - "golang.org/x/oauth2" - "golang.org/x/net/context" "net/http" "net/url" - "time" "os" "path/filepath" "reflect" "regexp" - "strings" - "unicode/utf8" "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/net/context" + "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") - xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") + xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the Swagger Petstore API v1.0.0 // In most cases there should be only one, shared, APIClient. type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. - // API Services - AnotherFakeApi *AnotherFakeApiService - FakeApi *FakeApiService - FakeClassnameTags123Api *FakeClassnameTags123ApiService - PetApi *PetApiService - StoreApi *StoreApiService - UserApi *UserApiService + // API Services + + AnotherFakeApi *AnotherFakeApiService + + FakeApi *FakeApiService + + FakeClassnameTags123Api *FakeClassnameTags123ApiService + + PetApi *PetApiService + + StoreApi *StoreApiService + + UserApi *UserApiService } type service struct { @@ -82,7 +89,6 @@ func atoi(in string) (int, error) { return strconv.Atoi(in) } - // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { @@ -153,18 +159,18 @@ func parameterToString(obj interface{}, collectionFormat string) string { return fmt.Sprintf("%v", obj) } -// callAPI do the request. +// callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) + return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks -func (c *APIClient) ChangeBasePath (path string) { +func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request -func (c *APIClient) prepareRequest ( +func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, @@ -224,7 +230,7 @@ func (c *APIClient) prepareRequest ( // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } - + // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() @@ -270,10 +276,9 @@ func (c *APIClient) prepareRequest ( if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } - + // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - if ctx != nil { // add context to the request @@ -299,18 +304,17 @@ func (c *APIClient) prepareRequest ( // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { - localVarRequest.Header.Add("Authorization", "Bearer " + auth) + localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } - + return localVarRequest, nil } - // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -329,7 +333,7 @@ func addFile(w *multipart.Writer, fieldName, path string) error { } // Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) (error) { +func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } @@ -366,7 +370,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() - + switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" @@ -383,7 +387,6 @@ func detectContentType(body interface{}) string { return contentType } - // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string @@ -406,7 +409,7 @@ func parseCacheControl(headers http.Header) cacheControl { } // CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) (time.Time) { +func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) @@ -414,7 +417,7 @@ func CacheExpires(r *http.Response) (time.Time) { return time.Now() } respCacheControl := parseCacheControl(r.Header) - + if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { @@ -433,7 +436,6 @@ func CacheExpires(r *http.Response) (time.Time) { return expires } -func strlen(s string) (int) { +func strlen(s string) int { return utf8.RuneCountInString(s) } - diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go index 2e6e99e3e72..2f5f69231fe 100644 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ b/samples/client/petstore/go/go-petstore/api_response.go @@ -16,15 +16,15 @@ import ( type APIResponse struct { *http.Response `json:"-"` - Message string `json:"message,omitempty"` + Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. - Operation string `json:"operation,omitempty"` + Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` + RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` + Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. diff --git a/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go b/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go index 2ea01100c1b..183f8096afd 100644 --- a/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go +++ b/samples/client/petstore/go/go-petstore/array_of_array_of_number_only.go @@ -11,6 +11,5 @@ package petstore type ArrayOfArrayOfNumberOnly struct { - ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/array_of_number_only.go b/samples/client/petstore/go/go-petstore/array_of_number_only.go index af7ceb14160..5d91b0f0a84 100644 --- a/samples/client/petstore/go/go-petstore/array_of_number_only.go +++ b/samples/client/petstore/go/go-petstore/array_of_number_only.go @@ -11,6 +11,5 @@ package petstore type ArrayOfNumberOnly struct { - ArrayNumber []float32 `json:"ArrayNumber,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/array_test.go b/samples/client/petstore/go/go-petstore/array_test.go index 1b7a9a8a170..7a99a6e6662 100644 --- a/samples/client/petstore/go/go-petstore/array_test.go +++ b/samples/client/petstore/go/go-petstore/array_test.go @@ -11,7 +11,6 @@ package petstore type ArrayTest struct { - ArrayOfString []string `json:"array_of_string,omitempty"` ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/capitalization.go b/samples/client/petstore/go/go-petstore/capitalization.go index 399f39b12b2..1c259e09e85 100644 --- a/samples/client/petstore/go/go-petstore/capitalization.go +++ b/samples/client/petstore/go/go-petstore/capitalization.go @@ -11,7 +11,6 @@ package petstore type Capitalization struct { - SmallCamel string `json:"smallCamel,omitempty"` CapitalCamel string `json:"CapitalCamel,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/cat.go b/samples/client/petstore/go/go-petstore/cat.go index ac2e7e72db7..e5044651054 100644 --- a/samples/client/petstore/go/go-petstore/cat.go +++ b/samples/client/petstore/go/go-petstore/cat.go @@ -11,7 +11,6 @@ package petstore type Cat struct { - ClassName string `json:"className"` Color string `json:"color,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/category.go b/samples/client/petstore/go/go-petstore/category.go index 20d3921d22c..048a144bdfc 100644 --- a/samples/client/petstore/go/go-petstore/category.go +++ b/samples/client/petstore/go/go-petstore/category.go @@ -11,7 +11,6 @@ package petstore type Category struct { - Id int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/class_model.go b/samples/client/petstore/go/go-petstore/class_model.go index 7982d3482c0..c6440c2ed9d 100644 --- a/samples/client/petstore/go/go-petstore/class_model.go +++ b/samples/client/petstore/go/go-petstore/class_model.go @@ -12,6 +12,5 @@ package petstore // Model for testing model with \"_class\" property type ClassModel struct { - Class string `json:"_class,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index 1053b95cecd..fb393f1f9ce 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -11,6 +11,5 @@ package petstore type Client struct { - Client string `json:"client,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index 630e03a82bd..8cfb8a5a272 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -26,37 +26,37 @@ func (c contextKey) String() string { var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. - ContextOAuth2 = contextKey("token") + ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. - ContextBasicAuth = contextKey("basic") + ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. - ContextAccessToken = contextKey("accesstoken") + ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request - ContextAPIKey = contextKey("apikey") + ContextAPIKey = contextKey("apikey") ) -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { - Key string - Prefix string + Key string + Prefix string } type Configuration struct { - BasePath string `json:"basePath,omitempty"` - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - HTTPClient *http.Client + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + HTTPClient *http.Client } func NewConfiguration() *Configuration { @@ -70,4 +70,4 @@ func NewConfiguration() *Configuration { func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value -} \ No newline at end of file +} diff --git a/samples/client/petstore/go/go-petstore/dog.go b/samples/client/petstore/go/go-petstore/dog.go index ae45406c754..eb94fa1278a 100644 --- a/samples/client/petstore/go/go-petstore/dog.go +++ b/samples/client/petstore/go/go-petstore/dog.go @@ -11,7 +11,6 @@ package petstore type Dog struct { - ClassName string `json:"className"` Color string `json:"color,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/enum_arrays.go b/samples/client/petstore/go/go-petstore/enum_arrays.go index 0ff0813a1d2..0c7c4e8db90 100644 --- a/samples/client/petstore/go/go-petstore/enum_arrays.go +++ b/samples/client/petstore/go/go-petstore/enum_arrays.go @@ -11,7 +11,6 @@ package petstore type EnumArrays struct { - JustSymbol string `json:"just_symbol,omitempty"` ArrayEnum []string `json:"array_enum,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/enum_class.go b/samples/client/petstore/go/go-petstore/enum_class.go index 4950a03e747..b0180356b4a 100644 --- a/samples/client/petstore/go/go-petstore/enum_class.go +++ b/samples/client/petstore/go/go-petstore/enum_class.go @@ -15,6 +15,8 @@ type EnumClass string // List of EnumClass const ( ABC EnumClass = "_abc" + EFG EnumClass = "-efg" + XYZ EnumClass = "(xyz)" ) diff --git a/samples/client/petstore/go/go-petstore/enum_test.go b/samples/client/petstore/go/go-petstore/enum_test.go index 58e4ea6a746..d985723c96e 100644 --- a/samples/client/petstore/go/go-petstore/enum_test.go +++ b/samples/client/petstore/go/go-petstore/enum_test.go @@ -11,7 +11,6 @@ package petstore type EnumTest struct { - EnumString string `json:"enum_string,omitempty"` EnumInteger int32 `json:"enum_integer,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/fake_api.go b/samples/client/petstore/go/go-petstore/fake_api.go index 51cb2d6e463..a42fc29c2ca 100644 --- a/samples/client/petstore/go/go-petstore/fake_api.go +++ b/samples/client/petstore/go/go-petstore/fake_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "time" @@ -27,20 +27,19 @@ var ( type FakeApiService service - -/* FakeApiService - Test serialization of outer boolean types +/* FakeApiService +Test serialization of outer boolean types * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "body" (OuterBoolean) Input boolean as post body - @return OuterBoolean*/ -func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterBoolean, *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "body" (OuterBoolean) Input boolean as post body +@return OuterBoolean*/ +func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterBoolean, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload OuterBoolean + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload OuterBoolean ) // create path and map variables @@ -50,9 +49,8 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -61,8 +59,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -92,23 +89,22 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } -/* FakeApiService - Test serialization of object with outer number type +/* FakeApiService +Test serialization of object with outer number type * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "body" (OuterComposite) Input composite as post body - @return OuterComposite*/ -func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterComposite, *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "body" (OuterComposite) Input composite as post body +@return OuterComposite*/ +func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterComposite, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload OuterComposite + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload OuterComposite ) // create path and map variables @@ -118,9 +114,8 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -129,8 +124,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -160,23 +154,22 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } -/* FakeApiService - Test serialization of outer number types +/* FakeApiService +Test serialization of outer number types * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "body" (OuterNumber) Input number as post body - @return OuterNumber*/ -func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterNumber, *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "body" (OuterNumber) Input number as post body +@return OuterNumber*/ +func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterNumber, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload OuterNumber + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload OuterNumber ) // create path and map variables @@ -186,9 +179,8 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -197,8 +189,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -228,23 +219,22 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } -/* FakeApiService - Test serialization of outer string types +/* FakeApiService +Test serialization of outer string types * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "body" (OuterString) Input string as post body - @return OuterString*/ -func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterString, *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "body" (OuterString) Input string as post body +@return OuterString*/ +func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterString, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload OuterString + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload OuterString ) // create path and map variables @@ -254,9 +244,8 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -265,8 +254,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -296,22 +284,21 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* FakeApiService To test \"client\" model - To test \"client\" model +To test \"client\" model * @param ctx context.Context for authentication, logging, tracing, etc. - @param body client model - @return Client*/ -func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) { +@param body client model +@return Client*/ +func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Client + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Client ) // create path and map variables @@ -321,9 +308,8 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -332,9 +318,7 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -362,35 +346,34 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * @param ctx context.Context for authentication, logging, tracing, etc. - @param number None - @param double None - @param patternWithoutDelimiter None - @param byte_ None - @param optional (nil or map[string]interface{}) with one or more of: - @param "integer" (int32) None - @param "int32_" (int32) None - @param "int64_" (int64) None - @param "float" (float32) None - @param "string_" (string) None - @param "binary" (string) None - @param "date" (string) None - @param "dateTime" (time.Time) None - @param "password" (string) None - @param "callback" (string) None - @return */ -func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals map[string]interface{}) ( *http.Response, error) { +@param number None +@param double None +@param patternWithoutDelimiter None +@param byte_ None +@param optional (nil or map[string]interface{}) with one or more of: + @param "integer" (int32) None + @param "int32_" (int32) None + @param "int64_" (int64) None + @param "float" (float32) None + @param "string_" (string) None + @param "binary" (string) None + @param "date" (string) None + @param "dateTime" (time.Time) None + @param "password" (string) None + @param "callback" (string) None +@return */ +func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals map[string]interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -399,7 +382,6 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if number < 32.1 { return nil, reportError("number must be greater than 32.1") } @@ -444,7 +426,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/xml; charset=utf-8", "application/json; charset=utf-8", } + localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -453,10 +435,7 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml; charset=utf-8", - "application/json; charset=utf-8", - } + localVarHttpHeaderAccepts := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -511,29 +490,28 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* FakeApiService To test enum parameters - To test enum parameters +To test enum parameters * @param ctx context.Context for authentication, logging, tracing, etc. - @param optional (nil or map[string]interface{}) with one or more of: - @param "enumFormStringArray" ([]string) Form parameter enum test (string array) - @param "enumFormString" (string) Form parameter enum test (string) - @param "enumHeaderStringArray" ([]string) Header parameter enum test (string array) - @param "enumHeaderString" (string) Header parameter enum test (string) - @param "enumQueryStringArray" ([]string) Query parameter enum test (string array) - @param "enumQueryString" (string) Query parameter enum test (string) - @param "enumQueryInteger" (int32) Query parameter enum test (double) - @param "enumQueryDouble" (float64) Query parameter enum test (double) - @return */ -func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals map[string]interface{}) ( *http.Response, error) { +@param optional (nil or map[string]interface{}) with one or more of: + @param "enumFormStringArray" ([]string) Form parameter enum test (string array) + @param "enumFormString" (string) Form parameter enum test (string) + @param "enumHeaderStringArray" ([]string) Header parameter enum test (string array) + @param "enumHeaderString" (string) Header parameter enum test (string) + @param "enumQueryStringArray" ([]string) Query parameter enum test (string array) + @param "enumQueryString" (string) Query parameter enum test (string) + @param "enumQueryInteger" (int32) Query parameter enum test (double) + @param "enumQueryDouble" (float64) Query parameter enum test (double) +@return */ +func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals map[string]interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -542,7 +520,6 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if err := typeCheckParameter(localVarOptionals["enumFormString"], "string", "enumFormString"); err != nil { return nil, err } @@ -569,7 +546,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, "")) } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "*/*", } + localVarHttpContentTypes := []string{"*/*"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -578,9 +555,7 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "*/*", - } + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -616,21 +591,20 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* FakeApiService test inline additionalProperties - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param param request body - @return */ -func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) ( *http.Response, error) { +@param param request body +@return */ +func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -640,9 +614,8 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -651,8 +624,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -675,22 +647,21 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* FakeApiService test json serialization of form data - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param param field1 - @param param2 field2 - @return */ -func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) ( *http.Response, error) { +@param param field1 +@param param2 field2 +@return */ +func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -700,9 +671,8 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -711,8 +681,7 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - } + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -735,7 +704,5 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } - diff --git a/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go b/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go index 95faf08358d..9da799e4160 100644 --- a/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go +++ b/samples/client/petstore/go/go-petstore/fake_classname_tags123_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "encoding/json" @@ -26,18 +26,17 @@ var ( type FakeClassnameTags123ApiService service - /* FakeClassnameTags123ApiService To test class name in snake case * @param ctx context.Context for authentication, logging, tracing, etc. - @param body client model - @return Client*/ -func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) { +@param body client model +@return Client*/ +func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Client + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Client ) // create path and map variables @@ -47,9 +46,8 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -58,9 +56,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -100,7 +96,5 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } - diff --git a/samples/client/petstore/go/go-petstore/format_test.go b/samples/client/petstore/go/go-petstore/format_test.go index b8bcb738fd6..2674ef255ca 100644 --- a/samples/client/petstore/go/go-petstore/format_test.go +++ b/samples/client/petstore/go/go-petstore/format_test.go @@ -15,7 +15,6 @@ import ( ) type FormatTest struct { - Integer int32 `json:"integer,omitempty"` Int32_ int32 `json:"int32,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/has_only_read_only.go b/samples/client/petstore/go/go-petstore/has_only_read_only.go index a9231320059..c290b54c4a7 100644 --- a/samples/client/petstore/go/go-petstore/has_only_read_only.go +++ b/samples/client/petstore/go/go-petstore/has_only_read_only.go @@ -11,7 +11,6 @@ package petstore type HasOnlyReadOnly struct { - Bar string `json:"bar,omitempty"` Foo string `json:"foo,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/list.go b/samples/client/petstore/go/go-petstore/list.go index 1d4033a09c0..44d4cb982ea 100644 --- a/samples/client/petstore/go/go-petstore/list.go +++ b/samples/client/petstore/go/go-petstore/list.go @@ -11,6 +11,5 @@ package petstore type List struct { - Var123List string `json:"123-list,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/map_test.go b/samples/client/petstore/go/go-petstore/map_test.go index c94c171040a..0b51a0103bf 100644 --- a/samples/client/petstore/go/go-petstore/map_test.go +++ b/samples/client/petstore/go/go-petstore/map_test.go @@ -11,7 +11,6 @@ package petstore type MapTest struct { - MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty"` MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go index ea21910e4ee..b5d120dfa3d 100644 --- a/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore/mixed_properties_and_additional_properties_class.go @@ -15,7 +15,6 @@ import ( ) type MixedPropertiesAndAdditionalPropertiesClass struct { - Uuid string `json:"uuid,omitempty"` DateTime time.Time `json:"dateTime,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/model_200_response.go b/samples/client/petstore/go/go-petstore/model_200_response.go index ab8f557f377..8de1415bb85 100644 --- a/samples/client/petstore/go/go-petstore/model_200_response.go +++ b/samples/client/petstore/go/go-petstore/model_200_response.go @@ -12,7 +12,6 @@ package petstore // Model for testing model name starting with number type Model200Response struct { - Name int32 `json:"name,omitempty"` Class string `json:"class,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go index 2ca2e3c8160..1852fcd25d3 100644 --- a/samples/client/petstore/go/go-petstore/model_api_response.go +++ b/samples/client/petstore/go/go-petstore/model_api_response.go @@ -11,7 +11,6 @@ package petstore type ModelApiResponse struct { - Code int32 `json:"code,omitempty"` Type_ string `json:"type,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/model_return.go b/samples/client/petstore/go/go-petstore/model_return.go index b2cfff1d727..ff17ce95228 100644 --- a/samples/client/petstore/go/go-petstore/model_return.go +++ b/samples/client/petstore/go/go-petstore/model_return.go @@ -12,6 +12,5 @@ package petstore // Model for testing reserved words type ModelReturn struct { - Return_ int32 `json:"return,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/name.go b/samples/client/petstore/go/go-petstore/name.go index c4d3cd5a099..42baa928740 100644 --- a/samples/client/petstore/go/go-petstore/name.go +++ b/samples/client/petstore/go/go-petstore/name.go @@ -12,7 +12,6 @@ package petstore // Model for testing model name same as property name type Name struct { - Name int32 `json:"name"` SnakeCase int32 `json:"snake_case,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/number_only.go b/samples/client/petstore/go/go-petstore/number_only.go index 3c5adb8ba79..631de12e68a 100644 --- a/samples/client/petstore/go/go-petstore/number_only.go +++ b/samples/client/petstore/go/go-petstore/number_only.go @@ -11,6 +11,5 @@ package petstore type NumberOnly struct { - JustNumber float32 `json:"JustNumber,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/order.go b/samples/client/petstore/go/go-petstore/order.go index 8e6f48e265a..afa590475c0 100644 --- a/samples/client/petstore/go/go-petstore/order.go +++ b/samples/client/petstore/go/go-petstore/order.go @@ -15,7 +15,6 @@ import ( ) type Order struct { - Id int64 `json:"id,omitempty"` PetId int64 `json:"petId,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/outer_composite.go b/samples/client/petstore/go/go-petstore/outer_composite.go index 3b40bfc5b52..7108ccc25a6 100644 --- a/samples/client/petstore/go/go-petstore/outer_composite.go +++ b/samples/client/petstore/go/go-petstore/outer_composite.go @@ -11,7 +11,6 @@ package petstore type OuterComposite struct { - MyNumber *OuterNumber `json:"my_number,omitempty"` MyString *OuterString `json:"my_string,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/outer_enum.go b/samples/client/petstore/go/go-petstore/outer_enum.go index 0e724d17c5c..5ad5712734c 100644 --- a/samples/client/petstore/go/go-petstore/outer_enum.go +++ b/samples/client/petstore/go/go-petstore/outer_enum.go @@ -15,6 +15,8 @@ type OuterEnum string // List of OuterEnum const ( PLACED OuterEnum = "placed" + APPROVED OuterEnum = "approved" + DELIVERED OuterEnum = "delivered" ) diff --git a/samples/client/petstore/go/go-petstore/pet.go b/samples/client/petstore/go/go-petstore/pet.go index 11bf78166c5..fcf57074eca 100644 --- a/samples/client/petstore/go/go-petstore/pet.go +++ b/samples/client/petstore/go/go-petstore/pet.go @@ -11,7 +11,6 @@ package petstore type Pet struct { - Id int64 `json:"id,omitempty"` Category *Category `json:"category,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 1b929dcdd8d..44170b2adb8 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "os" @@ -28,18 +28,17 @@ var ( type PetApiService service - /* PetApiService Add a new pet to the store - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param body Pet object that needs to be added to the store - @return */ -func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response, error) { +@param body Pet object that needs to be added to the store +@return */ +func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -49,9 +48,8 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response, localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", "application/xml", } + localVarHttpContentTypes := []string{"application/json", "application/xml"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -60,10 +58,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response, } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -86,23 +81,22 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) ( *http.Response, bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* PetApiService Deletes a pet - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param petId Pet id to delete - @param optional (nil or map[string]interface{}) with one or more of: - @param "apiKey" (string) - @return */ -func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) ( *http.Response, error) { +@param petId Pet id to delete +@param optional (nil or map[string]interface{}) with one or more of: + @param "apiKey" (string) +@return */ +func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -112,13 +106,12 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if err := typeCheckParameter(localVarOptionals["apiKey"], "string", "apiKey"); err != nil { return nil, err } // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -127,10 +120,7 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -154,22 +144,21 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* PetApiService Finds Pets by status - Multiple status values can be provided with comma separated strings +Multiple status values can be provided with comma separated strings * @param ctx context.Context for authentication, logging, tracing, etc. - @param status Status values that need to be considered for filter - @return []Pet*/ -func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) { +@param status Status values that need to be considered for filter +@return []Pet*/ +func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload []Pet + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload []Pet ) // create path and map variables @@ -179,10 +168,9 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - localVarQueryParams.Add("status", parameterToString(status, "csv")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -191,10 +179,7 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -220,22 +205,21 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* PetApiService Finds Pets by tags - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param ctx context.Context for authentication, logging, tracing, etc. - @param tags Tags to filter by - @return []Pet*/ -func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) { +@param tags Tags to filter by +@return []Pet*/ +func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload []Pet + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload []Pet ) // create path and map variables @@ -245,10 +229,9 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - localVarQueryParams.Add("tags", parameterToString(tags, "csv")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -257,10 +240,7 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -286,22 +266,21 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* PetApiService Find pet by ID - Returns a single pet +Returns a single pet * @param ctx context.Context for authentication, logging, tracing, etc. - @param petId ID of pet to return - @return Pet*/ -func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) { +@param petId ID of pet to return +@return Pet*/ +func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Pet + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Pet ) // create path and map variables @@ -312,9 +291,8 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -323,10 +301,7 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -364,21 +339,20 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *htt return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* PetApiService Update an existing pet - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param body Pet object that needs to be added to the store - @return */ -func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Response, error) { +@param body Pet object that needs to be added to the store +@return */ +func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -388,9 +362,8 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", "application/xml", } + localVarHttpContentTypes := []string{"application/json", "application/xml"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -399,10 +372,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -425,24 +395,23 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) ( *http.Respons bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* PetApiService Updates a pet in the store with form data - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param petId ID of pet that needs to be updated - @param optional (nil or map[string]interface{}) with one or more of: - @param "name" (string) Updated name of the pet - @param "status" (string) Updated status of the pet - @return */ -func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) ( *http.Response, error) { +@param petId ID of pet that needs to be updated +@param optional (nil or map[string]interface{}) with one or more of: + @param "name" (string) Updated name of the pet + @param "status" (string) Updated status of the pet +@return */ +func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -452,7 +421,6 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if err := typeCheckParameter(localVarOptionals["name"], "string", "name"); err != nil { return nil, err } @@ -461,7 +429,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/x-www-form-urlencoded", } + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -470,10 +438,7 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -500,25 +465,24 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* PetApiService uploads an image - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param petId ID of pet to update - @param optional (nil or map[string]interface{}) with one or more of: - @param "additionalMetadata" (string) Additional data to pass to server - @param "file" (*os.File) file to upload - @return ModelApiResponse*/ -func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (ModelApiResponse, *http.Response, error) { +@param petId ID of pet to update +@param optional (nil or map[string]interface{}) with one or more of: + @param "additionalMetadata" (string) Additional data to pass to server + @param "file" (*os.File) file to upload +@return ModelApiResponse*/ +func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (ModelApiResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload ModelApiResponse + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload ModelApiResponse ) // create path and map variables @@ -528,13 +492,12 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if err := typeCheckParameter(localVarOptionals["additionalMetadata"], "string", "additionalMetadata"); err != nil { return successPayload, nil, err } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "multipart/form-data", } + localVarHttpContentTypes := []string{"multipart/form-data"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -543,9 +506,7 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -584,7 +545,5 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } - diff --git a/samples/client/petstore/go/go-petstore/read_only_first.go b/samples/client/petstore/go/go-petstore/read_only_first.go index ec46cccb099..c2d44d32eea 100644 --- a/samples/client/petstore/go/go-petstore/read_only_first.go +++ b/samples/client/petstore/go/go-petstore/read_only_first.go @@ -11,7 +11,6 @@ package petstore type ReadOnlyFirst struct { - Bar string `json:"bar,omitempty"` Baz string `json:"baz,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/special_model_name.go b/samples/client/petstore/go/go-petstore/special_model_name.go index 46f51fab939..252c3779f09 100644 --- a/samples/client/petstore/go/go-petstore/special_model_name.go +++ b/samples/client/petstore/go/go-petstore/special_model_name.go @@ -11,6 +11,5 @@ package petstore type SpecialModelName struct { - SpecialPropertyName int64 `json:"$special[property.name],omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 5b3d23d1e5b..16aea981031 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "encoding/json" @@ -27,18 +27,17 @@ var ( type StoreApiService service - /* StoreApiService Delete purchase order by ID - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param ctx context.Context for authentication, logging, tracing, etc. - @param orderId ID of the order that needs to be deleted - @return */ -func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *http.Response, error) { +@param orderId ID of the order that needs to be deleted +@return */ +func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -49,9 +48,8 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -60,10 +58,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -84,21 +79,20 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) ( *ht bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* StoreApiService Returns pet inventories by status - Returns a map of status codes to quantities +Returns a map of status codes to quantities * @param ctx context.Context for authentication, logging, tracing, etc. - @return map[string]int32*/ -func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) { +@return map[string]int32*/ +func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload map[string]int32 + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload map[string]int32 ) // create path and map variables @@ -108,9 +102,8 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -119,9 +112,7 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -159,22 +150,21 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* StoreApiService Find purchase order by ID - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param ctx context.Context for authentication, logging, tracing, etc. - @param orderId ID of pet that needs to be fetched - @return Order*/ -func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) { +@param orderId ID of pet that needs to be fetched +@return Order*/ +func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Order + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Order ) // create path and map variables @@ -184,7 +174,6 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - if orderId < 1 { return successPayload, nil, reportError("orderId must be greater than 1") } @@ -193,7 +182,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde } // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -202,10 +191,7 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -231,22 +217,21 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* StoreApiService Place an order for a pet - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param body order placed for purchasing the pet - @return Order*/ -func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) { +@param body order placed for purchasing the pet +@return Order*/ +func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload Order + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload Order ) // create path and map variables @@ -256,9 +241,8 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, * localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -267,10 +251,7 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, * } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -298,7 +279,5 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, * return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } - diff --git a/samples/client/petstore/go/go-petstore/tag.go b/samples/client/petstore/go/go-petstore/tag.go index 4c0c279e41c..9a584a09b41 100644 --- a/samples/client/petstore/go/go-petstore/tag.go +++ b/samples/client/petstore/go/go-petstore/tag.go @@ -11,7 +11,6 @@ package petstore type Tag struct { - Id int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/user.go b/samples/client/petstore/go/go-petstore/user.go index 6577365f61c..99ae1c71567 100644 --- a/samples/client/petstore/go/go-petstore/user.go +++ b/samples/client/petstore/go/go-petstore/user.go @@ -11,7 +11,6 @@ package petstore type User struct { - Id int64 `json:"id,omitempty"` Username string `json:"username,omitempty"` diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index c3ccd2e040e..9fb8a37f653 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -12,8 +12,8 @@ package petstore import ( "io/ioutil" - "net/url" "net/http" + "net/url" "strings" "golang.org/x/net/context" "encoding/json" @@ -27,18 +27,17 @@ var ( type UserApiService service - /* UserApiService Create user - This can only be done by the logged in user. +This can only be done by the logged in user. * @param ctx context.Context for authentication, logging, tracing, etc. - @param body Created user object - @return */ -func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Response, error) { +@param body Created user object +@return */ +func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -48,9 +47,8 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -59,10 +57,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -85,21 +80,20 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) ( *http.Resp bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* UserApiService Creates list of users with given input array - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param body List of user object - @return */ -func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) ( *http.Response, error) { +@param body List of user object +@return */ +func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -109,9 +103,8 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -120,10 +113,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -146,21 +136,20 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* UserApiService Creates list of users with given input array - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param body List of user object - @return */ -func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) ( *http.Response, error) { +@param body List of user object +@return */ +func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -170,9 +159,8 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -181,10 +169,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -207,21 +192,20 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* UserApiService Delete user - This can only be done by the logged in user. +This can only be done by the logged in user. * @param ctx context.Context for authentication, logging, tracing, etc. - @param username The name that needs to be deleted - @return */ -func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *http.Response, error) { +@param username The name that needs to be deleted +@return */ +func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -232,9 +216,8 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -243,10 +226,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -267,22 +247,21 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) ( *htt bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* UserApiService Get user by user name - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param username The name that needs to be fetched. Use user1 for testing. - @return User*/ -func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) { +@param username The name that needs to be fetched. Use user1 for testing. +@return User*/ +func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload User + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload User ) // create path and map variables @@ -293,9 +272,8 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -304,10 +282,7 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -333,23 +308,22 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* UserApiService Logs user into the system - + * @param ctx context.Context for authentication, logging, tracing, etc. - @param username The user name for login - @param password The password for login in clear text - @return string*/ -func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) { +@param username The user name for login +@param password The password for login in clear text +@return string*/ +func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte - successPayload string + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + successPayload string ) // create path and map variables @@ -359,11 +333,10 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - localVarQueryParams.Add("username", parameterToString(username, "")) localVarQueryParams.Add("password", parameterToString(password, "")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -372,10 +345,7 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -401,20 +371,19 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor return successPayload, localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err } /* UserApiService Logs out current logged in user session - + * @param ctx context.Context for authentication, logging, tracing, etc. - @return */ -func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error) { +@return */ +func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -424,9 +393,8 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -435,10 +403,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -459,22 +424,21 @@ func (a *UserApiService) LogoutUser(ctx context.Context) ( *http.Response, error bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } /* UserApiService Updated user - This can only be done by the logged in user. +This can only be done by the logged in user. * @param ctx context.Context for authentication, logging, tracing, etc. - @param username name that need to be deleted - @param body Updated user object - @return */ -func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) ( *http.Response, error) { +@param username name that need to be deleted +@param body Updated user object +@return */ +func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") - localVarPostBody interface{} - localVarFileName string - localVarFileBytes []byte + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte ) // create path and map variables @@ -485,9 +449,8 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U localVarQueryParams := url.Values{} localVarFormParams := url.Values{} - // to determine the Content-Type header - localVarHttpContentTypes := []string{ } + localVarHttpContentTypes := []string{} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -496,10 +459,7 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U } // to determine the Accept header - localVarHttpHeaderAccepts := []string{ - "application/xml", - "application/json", - } + localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -522,7 +482,5 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) } - return localVarHttpResponse, err } -