diff --git a/bin/go-petstore-withxml.sh b/bin/go-petstore-withxml.sh old mode 100644 new mode 100755 diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index 1aa817ca8d1b..75cda41fd7ab 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -244,11 +244,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} } {{#responses}}{{#dataType}} if localVarHttpResponse.StatusCode == {{{code}}} { - localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) - if err != nil { - return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err - } - var v {{{dataType}}} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { diff --git a/samples/client/petstore-security-test/go/.openapi-generator/VERSION b/samples/client/petstore-security-test/go/.openapi-generator/VERSION index f9f7450d1359..096bf47efe31 100644 --- a/samples/client/petstore-security-test/go/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/go/.openapi-generator/VERSION @@ -1 +1 @@ -2.3.0-SNAPSHOT \ No newline at end of file +3.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/go/README.md b/samples/client/petstore-security-test/go/README.md index d092ab5477fa..9b2e1fad4190 100644 --- a/samples/client/petstore-security-test/go/README.md +++ b/samples/client/petstore-security-test/go/README.md @@ -7,17 +7,17 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - Package version: 1.0.0 -- Build package: io.swagger.codegen.languages.GoClientCodegen +- Build package: org.openapitools.codegen.languages.GoClientCodegen ## Installation Put the package under your project folder and add the following in import: -``` - "./swagger" +```golang +import "./swagger" ``` ## Documentation for API Endpoints -All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* +All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- @@ -35,12 +35,12 @@ Class | Method | HTTP request | Description - **Type**: API key Example -``` - auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ - Key: "APIKEY", - Prefix: "Bearer", // Omit if not necessary. - }) - r, err := client.Service.Operation(auth, args) +```golang +auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ + Key: "APIKEY", + Prefix: "Bearer", // Omit if not necessary. +}) +r, err := client.Service.Operation(auth, args) ``` ## petstore_auth - **Type**: OAuth @@ -51,20 +51,20 @@ Example - **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r Example -``` - auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") - r, err := client.Service.Operation(auth, args) +```golang +auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") +r, err := client.Service.Operation(auth, args) ``` Or via OAuth2 module to automatically refresh tokens and perform user authentication. -``` - import "golang.org/x/oauth2" +```golang +import "golang.org/x/oauth2" - / .. Perform OAuth2 round trip request and obtain a token .. // +/* Perform OAuth2 round trip request and obtain a token */ - tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) - auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) - r, err := client.Service.Operation(auth, args) +tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) +auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) +r, err := client.Service.Operation(auth, args) ``` ## Author diff --git a/samples/client/petstore-security-test/go/api/openapi.yaml b/samples/client/petstore-security-test/go/api/openapi.yaml new file mode 100644 index 000000000000..495e4fee09f9 --- /dev/null +++ b/samples/client/petstore-security-test/go/api/openapi.yaml @@ -0,0 +1,74 @@ +openapi: 3.0.1 +info: + title: Swagger Petstore */ ' " =end -- \r\n \n \r + description: "This spec is mainly for testing Petstore server and contains fake\ + \ endpoints, models. Please do not use this for any other purpose. Special characters:\ + \ \" \\ */ ' \" =end -- \r\n \n \r" + termsOfService: http://swagger.io/terms/ */ ' " =end -- \r\n \n \r + contact: + email: apiteam@swagger.io */ ' " =end -- \r\n \n \r + license: + name: Apache-2.0 */ ' " =end -- \r\n \n \r + url: http://www.apache.org/licenses/LICENSE-2.0.html */ ' " =end -- \r\n \n \r + version: 1.0.0 */ ' " =end -- \r\n \n \r +externalDocs: + description: Find out more about Swagger */ ' " =end -- \r\n \n \r + url: http://swagger.io +servers: +- url: petstore.swagger.io */ ' " =end -- \r\n \n \r/v2 */ ' " =end -- \r\n \n \r +tags: +- name: fake + description: Everything about your Pets */ ' " =end -- \r\n \n \r + externalDocs: + description: Find out more */ ' " =end -- \r\n \n \r + url: http://swagger.io +paths: + /fake: + put: + tags: + - fake + summary: To test code injection */ ' " =end -- \r\n \n \r + operationId: testCodeInject */ ' " =end -- \r\n \n \r + requestBody: + content: + application/json: + schema: + properties: + test code inject */ ' " =end -- \r\n \n \r: + type: string + description: To test code injection */ ' " =end -- \r\n \n \r + ? "*/ ' \" =end -- \r\n \n \r" + : schema: + properties: + test code inject */ ' " =end -- \r\n \n \r: + type: string + description: To test code injection */ ' " =end -- \r\n \n \r + responses: + 400: + description: To test code injection */ ' " =end -- \r\n \n \r + content: {} +components: + schemas: + Return: + type: object + properties: + return: + type: integer + description: property description */ ' " =end -- \r\n \n \r + format: int32 + description: Model for testing reserved words */ ' " =end -- \r\n \n \r + xml: + name: Return + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account */ ' " =end -- \r\n \n \r + read:pets: read your pets */ ' " =end -- \r\n \n \r + api_key: + type: apiKey + name: api_key */ ' " =end -- \r\n \n \r + in: header diff --git a/samples/client/petstore-security-test/go/api_fake.go b/samples/client/petstore-security-test/go/api_fake.go new file mode 100644 index 000000000000..df441f97dd08 --- /dev/null +++ b/samples/client/petstore-security-test/go/api_fake.go @@ -0,0 +1,110 @@ +/* + * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "io/ioutil" + "net/http" + "net/url" + "strings" + "context" +) + +// Linger please +var ( + _ context.Context +) + +type FakeApiService service + +/* +FakeApiService To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *TestCodeInjectEndRnNROpts - Optional Parameters: + * @param "" (optional.Interface of ErrorUnknown) - + + +*/ + +type TestCodeInjectEndRnNROpts struct { + optional.Interface +} + +func (a *FakeApiService) TestCodeInjectEndRnNR(ctx context.Context, localVarOptionals *TestCodeInjectEndRnNROpts) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/fake" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json", "*_/ ' =end -- "} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + if localVarOptionals != nil && localVarOptionals..IsSet() { + + localVarOptional, localVarOptionalok := localVarOptionals..Value().(ErrorUnknown) + if !localVarOptionalok { + return nil, reportError("uNKNOWNBASETYPE should be ErrorUnknown") + } + localVarPostBody = &localVarOptional + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil +} diff --git a/samples/client/petstore-security-test/go/client.go b/samples/client/petstore-security-test/go/client.go new file mode 100644 index 000000000000..1cec111dd7d8 --- /dev/null +++ b/samples/client/petstore-security-test/go/client.go @@ -0,0 +1,465 @@ +/* + * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "bytes" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "context" + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") + 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. + + // API Services + + FakeApi *FakeApiService +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.FakeApi = (*FakeApiService)(&c.common) + + return c +} + +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 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insenstive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.ToLower(a) == strings.ToLower(needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +// parameterToString convert interface{} parameters to string, using a delimiter if format is provided. +func parameterToString(obj interface{}, collectionFormat string) string { + var delimiter string + + switch collectionFormat { + case "pipes": + delimiter = "|" + case "ssv": + delimiter = " " + case "tsv": + delimiter = "\t" + case "csv": + delimiter = "," + } + + if reflect.TypeOf(obj).Kind() == reflect.Slice { + return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") + } + + return fmt.Sprintf("%v", obj) +} + +// callAPI do the request. +func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { + return c.cfg.HTTPClient.Do(request) +} + +// Change base path to allow switching to mocks +func (c *APIClient) ChangeBasePath(path string) { + c.cfg.BasePath = path +} + +// prepareRequest build the request +func (c *APIClient) prepareRequest( + ctx context.Context, + path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams url.Values, + formParams url.Values, + fileName string, + fileBytes []byte) (localVarRequest *http.Request, err error) { + + var body *bytes.Buffer + + // Detect postBody type and post. + if postBody != nil { + contentType := headerParams["Content-Type"] + if contentType == "" { + contentType = detectContentType(postBody) + headerParams["Content-Type"] = contentType + } + + body, err = setBody(postBody, contentType) + if err != nil { + return nil, err + } + } + + // 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.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + if len(fileBytes) > 0 && fileName != "" { + w.Boundary() + //_, fileNm := filepath.Split(fileName) + part, err := w.CreateFormFile("file", filepath.Base(fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(fileBytes) + if err != nil { + return nil, err + } + // 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 parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = query.Encode() + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers.Set(h, v) + } + localVarRequest.Header = headers + } + + // Override request host, if applicable + 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 + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + // Basic HTTP Authentication + if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { + localVarRequest.SetBasicAuth(auth.UserName, auth.Password) + } + + // AccessToken Authentication + if auth, ok := ctx.Value(ContextAccessToken).(string); ok { + localVarRequest.Header.Add("Authorization", "Bearer "+auth) + } + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("Invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +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" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +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")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } + expires = now.Add(lifetime) + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/samples/client/petstore-security-test/go/configuration.go b/samples/client/petstore-security-test/go/configuration.go index b63460d45f07..fd41f41036d8 100644 --- a/samples/client/petstore-security-test/go/configuration.go +++ b/samples/client/petstore-security-test/go/configuration.go @@ -61,7 +61,7 @@ type Configuration struct { func NewConfiguration() *Configuration { cfg := &Configuration{ - BasePath: "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r", + BasePath: "petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } diff --git a/samples/client/petstore-security-test/go/docs/FakeApi.md b/samples/client/petstore-security-test/go/docs/FakeApi.md index f855aef7bc30..bb9b81723d3d 100644 --- a/samples/client/petstore-security-test/go/docs/FakeApi.md +++ b/samples/client/petstore-security-test/go/docs/FakeApi.md @@ -1,6 +1,6 @@ # \FakeApi -All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* +All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* Method | HTTP request | Description ------------- | ------------- | ------------- @@ -15,15 +15,15 @@ To test code injection *_/ ' \" =end -- \\r\\n \\n \\r Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***TestCodeInjectEndRnNROpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a TestCodeInjectEndRnNROpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **testCodeInjectEndRnNR** | **string**| To test code injection *_/ ' \" =end -- \\r\\n \\n \\r | + **uNKNOWNBASETYPE** | [**optional.Interface of ErrorUnknown**](UNKNOWN_BASE_TYPE.md)| | ### Return type @@ -36,7 +36,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json, *_/ ' =end -- - - **Accept**: application/json, *_/ ' =end -- + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore-security-test/go/response.go b/samples/client/petstore-security-test/go/response.go new file mode 100644 index 000000000000..05fd1dc4e900 --- /dev/null +++ b/samples/client/petstore-security-test/go/response.go @@ -0,0 +1,44 @@ +/* + * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package swagger + +import ( + "net/http" +) + +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the swagger operation. + 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"` + // 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"` + // 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. + Payload []byte `json:"-"` +} + +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION b/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION index 855ff9501eb8..096bf47efe31 100644 --- a/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION +++ b/samples/client/petstore/go/go-petstore-withXml/.openapi-generator/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +3.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore-withXml/README.md b/samples/client/petstore/go/go-petstore-withXml/README.md index 35dea62225ef..365dcec4a138 100644 --- a/samples/client/petstore/go/go-petstore-withXml/README.md +++ b/samples/client/petstore/go/go-petstore-withXml/README.md @@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 - Package version: 1.0.0 -- Build package: io.swagger.codegen.languages.GoClientCodegen +- Build package: org.openapitools.codegen.languages.GoClientCodegen ## Installation Put the package under your project folder and add the following in import: @@ -26,6 +26,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite | *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **Post** /fake/outer/string | +*FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **Put** /fake/body-with-query-params | *FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **Patch** /fake | To test \"client\" model *FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **Get** /fake | To test enum parameters @@ -63,9 +64,11 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) + - [Dog](docs/Dog.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -90,8 +93,6 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) - - [Cat](docs/Cat.md) - - [Dog](docs/Dog.md) ## Documentation For Authorization diff --git a/samples/client/petstore/go/go-petstore-withXml/api/openapi.yaml b/samples/client/petstore/go/go-petstore-withXml/api/openapi.yaml new file mode 100644 index 000000000000..f87e7d7a0a74 --- /dev/null +++ b/samples/client/petstore/go/go-petstore-withXml/api/openapi.yaml @@ -0,0 +1,1508 @@ +openapi: 3.0.1 +info: + title: Swagger Petstore + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + termsOfService: http://swagger.io/terms/ + contact: + email: apiteam@swagger.io + license: + name: Apache-2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io:80/v2 +tags: +- name: pet + description: Everything about your Pets + externalDocs: + description: Find out more + url: http://swagger.io +- name: store + description: Access to Petstore orders +- name: user + description: Operations about user + externalDocs: + description: Find out more about our store + url: http://swagger.io +paths: + /pet: + put: + tags: + - pet + summary: Update an existing pet + operationId: updatePet + requestBody: + description: Pet object that needs to be added to the store + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + required: true + responses: + 400: + description: Invalid ID supplied + content: {} + 404: + description: Pet not found + content: {} + 405: + description: Validation exception + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + post: + tags: + - pet + summary: Add a new pet to the store + operationId: addPet + requestBody: + description: Pet object that needs to be added to the store + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + required: true + responses: + 405: + description: Invalid input + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + explode: false + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + 200: + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid status value + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + explode: false + schema: + type: array + items: + type: string + responses: + 200: + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid tag value + content: {} + deprecated: true + security: + - petstore_auth: + - write:pets + - read:pets + /pet/{petId}: + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid ID supplied + content: {} + 404: + description: Pet not found + content: {} + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + type: string + description: Updated name of the pet + status: + type: string + description: Updated status of the pet + responses: + 405: + description: Invalid input + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + delete: + tags: + - pet + summary: Deletes a pet + operationId: deletePet + parameters: + - name: api_key + in: header + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + 400: + description: Invalid pet value + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/{petId}/uploadImage: + post: + tags: + - pet + summary: uploads an image + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + type: string + description: Additional data to pass to server + file: + type: string + description: file to upload + format: binary + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - write:pets + - read:pets + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + 200: + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + operationId: placeOrder + requestBody: + description: order placed for purchasing the pet + content: + '*/*': + schema: + $ref: '#/components/schemas/Order' + required: true + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + 400: + description: Invalid Order + content: {} + /store/order/{order_id}: + get: + tags: + - store + summary: Find purchase order by ID + description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + maximum: 5 + minimum: 1 + type: integer + format: int64 + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + 400: + description: Invalid ID supplied + content: {} + 404: + description: Order not found + content: {} + delete: + tags: + - store + summary: Delete purchase order by ID + description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + 400: + description: Invalid ID supplied + content: {} + 404: + description: Order not found + content: {} + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + description: Created user object + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + operationId: createUsersWithArrayInput + requestBody: + description: List of user object + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + operationId: createUsersWithListInput + requestBody: + description: List of user object + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/login: + get: + tags: + - user + summary: Logs user into the system + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + 200: + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + 400: + description: Invalid username/password supplied + content: {} + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + operationId: logoutUser + responses: + default: + description: successful operation + content: {} + /user/{username}: + get: + tags: + - user + summary: Get user by user name + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + requestBody: + description: Updated user object + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + required: true + responses: + 400: + description: Invalid user supplied + content: {} + 404: + description: User not found + content: {} + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + /fake_classname_test: + patch: + tags: + - fake_classname_tags 123#$%^ + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + /fake: + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + enum: + - '>' + - $ + default: $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + explode: false + schema: + type: array + items: + type: string + enum: + - '>' + - $ + default: $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + type: array + description: Form parameter enum test (string array) + items: + type: string + enum: + - '>' + - $ + default: $ + enum_form_string: + type: string + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + default: -efg + responses: + 400: + description: Invalid request + content: {} + 404: + description: Not found + content: {} + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + required: + - byte + - double + - number + - pattern_without_delimiter + properties: + integer: + maximum: 100 + minimum: 10 + type: integer + description: None + int32: + maximum: 200 + minimum: 20 + type: integer + description: None + format: int32 + int64: + type: integer + description: None + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + description: None + float: + maximum: 987.6 + type: number + description: None + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + description: None + format: double + string: + pattern: /[a-z]/i + type: string + description: None + pattern_without_delimiter: + pattern: ^[A-Z].* + type: string + description: None + byte: + type: string + description: None + format: byte + binary: + type: string + description: None + format: binary + date: + type: string + description: None + format: date + dateTime: + type: string + description: None + format: date-time + password: + maxLength: 64 + minLength: 10 + type: string + description: None + format: password + callback: + type: string + description: None + required: true + responses: + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + security: + - http_basic_test: [] + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + description: Input number as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + required: false + responses: + 200: + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + description: Input string as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + required: false + responses: + 200: + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + description: Input boolean as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + required: false + responses: + 200: + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + description: Input composite as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + required: false + responses: + 200: + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + required: + - param + - param2 + properties: + param: + type: string + description: field1 + param2: + type: string + description: field2 + required: true + responses: + 200: + description: successful operation + content: {} + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + operationId: testInlineAdditionalProperties + requestBody: + description: request body + content: + application/json: + schema: + type: object + additionalProperties: + type: string + required: true + responses: + 200: + description: successful operation + content: {} + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + 200: + description: Success + content: {} + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags + operationId: test_special_tags + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' +components: + schemas: + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + example: + name: name + id: 6 + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + description: User Status + format: int32 + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + xml: + name: User + OuterNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + type: string + description: | + Name of the pet + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Name: + required: + - name + type: object + properties: + name: + type: integer + format: int32 + snake_case: + type: integer + format: int32 + readOnly: true + property: + type: string + 123Number: + type: integer + readOnly: true + description: Model for testing model name same as property name + xml: + name: Name + EnumClass: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + List: + type: object + properties: + 123-list: + type: string + NumberOnly: + type: object + properties: + JustNumber: + type: number + 200_response: + type: object + properties: + name: + type: integer + format: int32 + class: + type: string + description: Model for testing model name starting with number + xml: + name: Name + Client: + type: object + properties: + client: + type: string + example: + client: client + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Enum_Test: + required: + - enum_string_required + type: object + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - "" + enum_string_required: + type: string + enum: + - UPPER + - lower + - "" + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + xml: + name: Order + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + $special[model.name]: + type: object + properties: + $special[property.name]: + type: integer + format: int64 + xml: + name: $special[model.name] + Return: + type: object + properties: + return: + type: integer + format: int32 + description: Model for testing reserved words + xml: + name: Return + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + OuterEnum: + type: string + enum: + - placed + - approved + - delivered + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + example: {} + format_test: + required: + - byte + - date + - number + - password + type: object + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + maximum: 2E+2 + minimum: 2E+1 + type: integer + format: int32 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + maximum: 987.6 + minimum: 54.3 + type: number + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + format: double + string: + pattern: /[a-z]/i + type: string + byte: + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + password: + maxLength: 64 + minLength: 10 + type: string + format: password + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterString: + type: string + ClassModel: + type: object + properties: + _class: + type: string + description: Model for testing model with "_class" property + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + Animal: + required: + - className + type: object + properties: + className: + type: string + color: + type: string + default: red + discriminator: + propertyName: className + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + example: + name: name + id: 1 + xml: + name: Tag + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + Pet: + required: + - name + - photoUrls + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + xml: + name: Pet + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + http_basic_test: + type: http + scheme: basic + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query diff --git a/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go b/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go index 62fca5694e13..b37a21249b70 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_another_fake.go @@ -15,9 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" - "encoding/xml" + "context" ) // Linger please @@ -27,18 +25,21 @@ var ( type AnotherFakeApiService service -/* AnotherFakeApiService To test special tags +/* +AnotherFakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -66,33 +67,50 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/api_fake.go b/samples/client/petstore/go/go-petstore-withXml/api_fake.go index d809d9ad179d..ca8392914b5e 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_fake.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_fake.go @@ -15,10 +15,9 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "time" - "encoding/json" - "encoding/xml" + "context" + "github.com/antihax/optional" + "os" ) // Linger please @@ -28,19 +27,27 @@ var ( type FakeApiService service -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterBooleanSerializeOpts - Optional Parameters: + * @param "" (optional.Bool) - Input boolean as post body + +@return OuterBoolean +*/ + +type FakeOuterBooleanSerializeOpts struct { + optional.Bool +} + +func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals *FakeOuterBooleanSerializeOpts) (OuterBoolean, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterBoolean + localVarReturnValue OuterBoolean ) // create path and map variables @@ -60,7 +67,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -68,52 +75,78 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterBoolean); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterBoolean + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterCompositeSerializeOpts - Optional Parameters: + * @param "" (optional.Interface of OuterComposite) - Input composite as post body + +@return OuterComposite +*/ + +type FakeOuterCompositeSerializeOpts struct { + optional.Interface +} + +func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals *FakeOuterCompositeSerializeOpts) (OuterComposite, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterComposite + localVarReturnValue OuterComposite ) // create path and map variables @@ -133,7 +166,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -141,52 +174,82 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterComposite); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + + localVarOptional, localVarOptionalok := localVarOptionals..Value().(OuterComposite) + if !localVarOptionalok { + return localVarReturnValue, nil, reportError("outerComposite should be OuterComposite") + } + localVarPostBody = &localVarOptional } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterComposite + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterNumberSerializeOpts - Optional Parameters: + * @param "" (optional.Float32) - Input number as post body + +@return OuterNumber +*/ + +type FakeOuterNumberSerializeOpts struct { + optional.Float32 +} + +func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals *FakeOuterNumberSerializeOpts) (OuterNumber, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterNumber + localVarReturnValue OuterNumber ) // create path and map variables @@ -206,7 +269,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -214,52 +277,78 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterNumber); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterNumber + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterStringSerializeOpts - Optional Parameters: + * @param "" (optional.String) - Input string as post body + +@return OuterString +*/ + +type FakeOuterStringSerializeOpts struct { + optional.String +} + +func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals *FakeOuterStringSerializeOpts) (OuterString, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterString + localVarReturnValue OuterString ) // create path and map variables @@ -279,7 +368,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -287,51 +376,145 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterString); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterString + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +FakeApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param query + * @param user + + +*/ +func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, query string, user User) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/fake/body-with-query-params" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + localVarQueryParams.Add("query", parameterToString(query, "csv")) + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} - return successPayload, localVarHttpResponse, err + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &user + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err } - return successPayload, localVarHttpResponse, err + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil } -/* FakeApiService To test \"client\" model +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -359,62 +542,97 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param number None + * @param double None + * @param patternWithoutDelimiter None + * @param byte None + * @param optional nil or *TestEndpointParametersOpts - Optional Parameters: + * @param "" (optional.Int32) - None + * @param "" (optional.Int32) - None + * @param "" (optional.Int64) - None + * @param "" (optional.Float32) - None + * @param "" (optional.String) - None + * @param "" (optional.*os.File) - None + * @param "" (optional.String) - None + * @param "" (optional.Time) - None + * @param "" (optional.String) - None + * @param "" (optional.String) - None + + +*/ + +type TestEndpointParametersOpts struct { + optional.Int32 + optional.Int32 + optional.Int64 + optional.Float32 + optional.String + optional.*os.File + optional.String + optional.Time + optional.String + optional.String +} + +func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte string, localVarOptionals *TestEndpointParametersOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -435,39 +653,9 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa if double > 123.4 { return nil, reportError("double must be less than 123.4") } - if err := typeCheckParameter(localVarOptionals["integer"], "int32", "integer"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["int32_"], "int32", "int32_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["int64_"], "int64", "int64_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["float"], "float32", "float"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["string_"], "string", "string_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["binary"], "string", "binary"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["date"], "string", "date"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["dateTime"], "time.Time", "dateTime"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["callback"], "string", "callback"); err != nil { - return nil, err - } // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -476,46 +664,57 @@ 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{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["integer"].(int32); localVarOk { - localVarFormParams.Add("integer", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("integer", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["int32_"].(int32); localVarOk { - localVarFormParams.Add("int32", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("int32", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["int64_"].(int64); localVarOk { - localVarFormParams.Add("int64", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("int64", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("number", parameterToString(number, "")) - if localVarTempParam, localVarOk := localVarOptionals["float"].(float32); localVarOk { - localVarFormParams.Add("float", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("float", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("double", parameterToString(double, "")) - if localVarTempParam, localVarOk := localVarOptionals["string_"].(string); localVarOk { - localVarFormParams.Add("string", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("string", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, "")) - localVarFormParams.Add("byte", parameterToString(byte_, "")) - if localVarTempParam, localVarOk := localVarOptionals["binary"].(string); localVarOk { - localVarFormParams.Add("binary", parameterToString(localVarTempParam, "")) + localVarFormParams.Add("byte", parameterToString(byte, "")) + var localVarFile *os.File + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFileOk := false + localVarFile, localVarFileOk = localVarOptionals..Value().(*os.File) + if !localVarFileOk { + return nil, reportError("binary should be *os.File") + } + } + if localVarFile != nil { + fbs, _ := ioutil.ReadAll(localVarFile) + localVarFileBytes = fbs + localVarFileName = localVarFile.Name() + localVarFile.Close() } - if localVarTempParam, localVarOk := localVarOptionals["date"].(string); localVarOk { - localVarFormParams.Add("date", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("date", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["dateTime"].(time.Time); localVarOk { - localVarFormParams.Add("dateTime", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("dateTime", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk { - localVarFormParams.Add("password", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("password", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["callback"].(string); localVarOk { - localVarFormParams.Add("callback", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("callback", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -526,33 +725,61 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService To test enum parameters +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *TestEnumParametersOpts - Optional Parameters: + * @param "EnumHeaderStringArray" (optional.Interface of []string) - Header parameter enum test (string array) + * @param "EnumHeaderString" (optional.String) - Header parameter enum test (string) + * @param "EnumQueryStringArray" (optional.Interface of []string) - Query parameter enum test (string array) + * @param "EnumQueryString" (optional.String) - Query parameter enum test (string) + * @param "EnumQueryInteger" (optional.Int32) - Query parameter enum test (double) + * @param "EnumQueryDouble" (optional.Float64) - Query parameter enum test (double) + * @param "" (optional.Interface of []string) - Form parameter enum test (string array) + * @param "" (optional.String) - Form parameter enum test (string) + + +*/ + +type TestEnumParametersOpts struct { + EnumHeaderStringArray optional.Interface + EnumHeaderString optional.String + EnumQueryStringArray optional.Interface + EnumQueryString optional.String + EnumQueryInteger optional.Int32 + EnumQueryDouble optional.Float64 + optional.Interface + optional.String +} + +func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals *TestEnumParametersOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -561,33 +788,21 @@ 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 - } - if err := typeCheckParameter(localVarOptionals["enumHeaderString"], "string", "enumHeaderString"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryString"], "string", "enumQueryString"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryInteger"], "int32", "enumQueryInteger"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryDouble"], "float64", "enumQueryDouble"); err != nil { - return nil, err - } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryStringArray"].([]string); localVarOk { - localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarTempParam, "csv")) + if localVarOptionals != nil && localVarOptionals.EnumQueryStringArray.IsSet() { + localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarOptionals.EnumQueryStringArray.Value(), "csv")) + } + if localVarOptionals != nil && localVarOptionals.EnumQueryString.IsSet() { + localVarQueryParams.Add("enum_query_string", parameterToString(localVarOptionals.EnumQueryString.Value(), "csv")) } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryString"].(string); localVarOk { - localVarQueryParams.Add("enum_query_string", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals.EnumQueryInteger.IsSet() { + localVarQueryParams.Add("enum_query_integer", parameterToString(localVarOptionals.EnumQueryInteger.Value(), "csv")) } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryInteger"].(int32); localVarOk { - localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals.EnumQueryDouble.IsSet() { + localVarQueryParams.Add("enum_query_double", parameterToString(localVarOptionals.EnumQueryDouble.Value(), "csv")) } // to determine the Content-Type header - localVarHttpContentTypes := []string{"*/*"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -596,27 +811,24 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"*/*"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["enumHeaderStringArray"].([]string); localVarOk { - localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarTempParam, "csv") - } - if localVarTempParam, localVarOk := localVarOptionals["enumHeaderString"].(string); localVarOk { - localVarHeaderParams["enum_header_string"] = parameterToString(localVarTempParam, "") + if localVarOptionals != nil && localVarOptionals.EnumHeaderStringArray.IsSet() { + localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarOptionals.EnumHeaderStringArray.Value(), "csv") } - if localVarTempParam, localVarOk := localVarOptionals["enumFormStringArray"].([]string); localVarOk { - localVarFormParams.Add("enum_form_string_array", parameterToString(localVarTempParam, "csv")) + if localVarOptionals != nil && localVarOptionals.EnumHeaderString.IsSet() { + localVarHeaderParams["enum_header_string"] = parameterToString(localVarOptionals.EnumHeaderString.Value(), "csv") } - if localVarTempParam, localVarOk := localVarOptionals["enumFormString"].(string); localVarOk { - localVarFormParams.Add("enum_form_string", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("enum_form_string_array", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryDouble"].(float64); localVarOk { - localVarFormParams.Add("enum_query_double", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("enum_form_string", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -627,25 +839,40 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService test inline additionalProperties +/* +FakeApiService test inline additionalProperties + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param requestBody request body + - * @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) { +*/ +func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, requestBody string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -673,7 +900,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = ¶m + localVarPostBody = &requestBody r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -683,26 +910,41 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService test json serialization of form data +/* +FakeApiService test json serialization of form data + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param param field1 + * @param param2 field2 + - * @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) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -713,7 +955,7 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par localVarFormParams := url.Values{} // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -740,10 +982,22 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go b/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go index 690d57466ff1..d4ea4dc99801 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go @@ -15,9 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" - "encoding/xml" + "context" ) // Linger please @@ -27,17 +25,21 @@ 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) { +/* +FakeClassnameTags123ApiService To test class name in snake case +To test class name in snake case + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -65,7 +67,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { @@ -75,35 +77,53 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body } else { key = auth.Key } + localVarQueryParams.Add("api_key_query", key) } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/api_pet.go b/samples/client/petstore/go/go-petstore-withXml/api_pet.go index 6cc64ee94dc0..2958e8d4320c 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_pet.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_pet.go @@ -15,11 +15,10 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "os" - "encoding/json" - "encoding/xml" + "context" "fmt" + "github.com/antihax/optional" + "os" ) // Linger please @@ -29,17 +28,20 @@ var ( type PetApiService service -/* PetApiService Add a new pet to the store +/* +PetApiService Add a new pet to the store + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param pet Pet object that needs to be added 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) { +*/ +func (a *PetApiService) AddPet(ctx context.Context, pet Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -59,7 +61,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -67,7 +69,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &pet r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -77,27 +79,47 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Deletes a pet +/* +PetApiService Deletes a pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId Pet id to delete + * @param optional nil or *DeletePetOpts - Optional Parameters: + * @param "ApiKey" (optional.String) - - * @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) { + +*/ + +type DeletePetOpts struct { + ApiKey optional.String +} + +func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals *DeletePetOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -107,9 +129,6 @@ 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{} @@ -121,15 +140,15 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["apiKey"].(string); localVarOk { - localVarHeaderParams["api_key"] = parameterToString(localVarTempParam, "") + if localVarOptionals != nil && localVarOptionals.ApiKey.IsSet() { + localVarHeaderParams["api_key"] = parameterToString(localVarOptionals.ApiKey.Value(), "csv") } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -140,26 +159,41 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Finds Pets by status +/* +PetApiService Finds Pets by status 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue []Pet ) // create path and map variables @@ -189,46 +223,66 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Finds Pets by tags +/* +PetApiService Finds Pets by tags 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue []Pet ) // create path and map variables @@ -258,46 +312,66 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Find pet by ID +/* +PetApiService Find pet by ID Returns a single pet - * @param ctx context.Context for authentication, logging, tracing, etc. -@param petId ID of pet to return -@return Pet*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue Pet ) // create path and map variables @@ -335,49 +409,70 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http key = auth.Key } localVarHeaderParams["api_key"] = key + } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Update an existing pet +/* +PetApiService Update an existing pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param pet Pet object that needs to be added 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) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) { +*/ +func (a *PetApiService) UpdatePet(ctx context.Context, pet Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -397,7 +492,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -405,7 +500,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &pet r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -415,28 +510,49 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Updates a pet in the store with form data +/* +PetApiService Updates a pet in the store with form data + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId ID of pet that needs to be updated + * @param optional nil or *UpdatePetWithFormOpts - Optional Parameters: + * @param "" (optional.String) - Updated name of the pet + * @param "" (optional.String) - Updated status of the pet + - * @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) { +*/ + +type UpdatePetWithFormOpts struct { + optional.String + optional.String +} + +func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals *UpdatePetWithFormOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -446,12 +562,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 - } - if err := typeCheckParameter(localVarOptionals["status"], "string", "status"); err != nil { - return nil, err - } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} @@ -463,18 +573,18 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["name"].(string); localVarOk { - localVarFormParams.Add("name", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("name", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["status"].(string); localVarOk { - localVarFormParams.Add("status", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("status", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -485,29 +595,49 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService uploads an image +/* +PetApiService uploads an image + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId ID of pet to update + * @param optional nil or *UploadFileOpts - Optional Parameters: + * @param "" (optional.String) - Additional data to pass to server + * @param "" (optional.*os.File) - file to upload + +@return ModelApiResponse +*/ - * @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) { +type UploadFileOpts struct { + optional.String + optional.*os.File +} + +func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals *UploadFileOpts) (ModelApiResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload ModelApiResponse + localVarReturnValue ModelApiResponse ) // create path and map variables @@ -517,9 +647,6 @@ 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"} @@ -538,12 +665,16 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["additionalMetadata"].(string); localVarOk { - localVarFormParams.Add("additionalMetadata", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals..Value(), "")) } - var localVarFile (*os.File) - if localVarTempParam, localVarOk := localVarOptionals["file"].(*os.File); localVarOk { - localVarFile = localVarTempParam + var localVarFile *os.File + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFileOk := false + localVarFile, localVarFileOk = localVarOptionals..Value().(*os.File) + if !localVarFileOk { + return localVarReturnValue, nil, reportError("file should be *os.File") + } } if localVarFile != nil { fbs, _ := ioutil.ReadAll(localVarFile) @@ -553,30 +684,47 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ModelApiResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/api_store.go b/samples/client/petstore/go/go-petstore-withXml/api_store.go index 8e4f26478d7b..3fad36ed610e 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_store.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_store.go @@ -15,9 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" - "encoding/xml" + "context" "fmt" ) @@ -28,17 +26,21 @@ var ( type StoreApiService service -/* StoreApiService Delete purchase order by ID +/* +StoreApiService Delete purchase order by ID 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 */ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param orderId ID of the order that needs to be deleted + + +*/ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -59,7 +61,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -75,25 +77,40 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* StoreApiService Returns pet inventories by status +/* +StoreApiService Returns pet inventories by status Returns a map of status codes to quantities - * @param ctx context.Context for authentication, logging, tracing, etc. -@return map[string]int32*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@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 + localVarReturnValue map[string]int32 ) // create path and map variables @@ -130,50 +147,71 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * key = auth.Key } localVarHeaderParams["api_key"] = key + } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v map[string]int32 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* StoreApiService Find purchase order by ID +/* +StoreApiService Find purchase order by ID 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue Order ) // create path and map variables @@ -184,10 +222,10 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if orderId < 1 { - return successPayload, nil, reportError("orderId must be greater than 1") + return localVarReturnValue, nil, reportError("orderId must be greater than 1") } if orderId > 5 { - return successPayload, nil, reportError("orderId must be less than 5") + return localVarReturnValue, nil, reportError("orderId must be less than 5") } // to determine the Content-Type header @@ -209,46 +247,65 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* StoreApiService Place an order for a pet +/* +StoreApiService Place an order for a pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param order order placed for purchasing the 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) { +@return Order +*/ +func (a *StoreApiService) PlaceOrder(ctx context.Context, order Order) (Order, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Order + localVarReturnValue Order ) // create path and map variables @@ -276,33 +333,50 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &order r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/api_user.go b/samples/client/petstore/go/go-petstore-withXml/api_user.go index 05b0f3b329ae..4f1d061162bb 100644 --- a/samples/client/petstore/go/go-petstore-withXml/api_user.go +++ b/samples/client/petstore/go/go-petstore-withXml/api_user.go @@ -15,9 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" - "encoding/xml" + "context" "fmt" ) @@ -28,17 +26,21 @@ var ( type UserApiService service -/* UserApiService Create user +/* +UserApiService Create 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user Created user object + + +*/ +func (a *UserApiService) CreateUser(ctx context.Context, user User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -58,7 +60,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -66,7 +68,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -76,25 +78,40 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Creates list of users with given input array +/* +UserApiService Creates list of users with given input array + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user List of user object + - * @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) { +*/ +func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, user []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -114,7 +131,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -122,7 +139,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -132,25 +149,40 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Creates list of users with given input array +/* +UserApiService Creates list of users with given input array + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user List of user object + - * @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) { +*/ +func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, user []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -170,7 +202,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -178,7 +210,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -188,25 +220,41 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Delete user +/* +UserApiService Delete 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 */ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The name that needs to be deleted + + +*/ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -227,7 +275,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -243,26 +291,40 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Get user by user name +/* +UserApiService Get user by user name + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The name that needs to be fetched. Use user1 for testing. - * @param ctx context.Context for authentication, logging, tracing, etc. -@param username The name that needs to be fetched. Use user1 for testing. -@return User*/ +@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 + localVarReturnValue User ) // create path and map variables @@ -292,47 +354,66 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v User + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* UserApiService Logs user into the system +/* +UserApiService Logs user into the system + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The user name for login + * @param password The password for login in clear text - * @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*/ +@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 + localVarReturnValue string ) // create path and map variables @@ -342,8 +423,8 @@ 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, "")) + localVarQueryParams.Add("username", parameterToString(username, "csv")) + localVarQueryParams.Add("password", parameterToString(password, "csv")) // to determine the Content-Type header localVarHttpContentTypes := []string{} @@ -363,44 +444,64 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* UserApiService Logs out current logged in user session +/* +UserApiService Logs out current logged in user session + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @param ctx context.Context for authentication, logging, tracing, etc. -@return */ + +*/ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -420,7 +521,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -436,26 +537,42 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Updated user +/* +UserApiService Updated 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username name that need to be deleted + * @param user Updated user object + + +*/ +func (a *UserApiService) UpdateUser(ctx context.Context, username string, user User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -476,7 +593,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{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -484,7 +601,7 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -494,10 +611,22 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore-withXml/client.go b/samples/client/petstore/go/go-petstore-withXml/client.go index d2f8f3092c33..c3c62e6da28a 100644 --- a/samples/client/petstore/go/go-petstore-withXml/client.go +++ b/samples/client/petstore/go/go-petstore-withXml/client.go @@ -29,7 +29,7 @@ import ( "time" "unicode/utf8" - "golang.org/x/net/context" + "context" "golang.org/x/oauth2" ) @@ -315,6 +315,21 @@ func (c *APIClient) prepareRequest( return localVarRequest, nil } +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -349,6 +364,8 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { @@ -439,3 +456,25 @@ func CacheExpires(r *http.Response) time.Time { func strlen(s string) int { return utf8.RuneCountInString(s) } + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/AnotherFakeApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/AnotherFakeApi.md index 1bc1af9ddd69..ce9779af2648 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/AnotherFakeApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/AnotherFakeApi.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **TestSpecialTags** -> Client TestSpecialTags(ctx, body) +> Client TestSpecialTags(ctx, client) To test special tags To test special tags @@ -17,8 +17,8 @@ To test special tags Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/EnumTest.md b/samples/client/petstore/go/go-petstore-withXml/docs/EnumTest.md index d51101dd40be..c286c17df388 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/EnumTest.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/EnumTest.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **EnumString** | **string** | | [optional] [default to null] +**EnumStringRequired** | **string** | | [default to null] **EnumInteger** | **int32** | | [optional] [default to null] **EnumNumber** | **float64** | | [optional] [default to null] **OuterEnum** | [***OuterEnum**](OuterEnum.md) | | [optional] [default to null] diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md index 5565e370e211..b77bf10cb749 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md @@ -8,6 +8,7 @@ Method | HTTP request | Description [**FakeOuterCompositeSerialize**](FakeApi.md#FakeOuterCompositeSerialize) | **Post** /fake/outer/composite | [**FakeOuterNumberSerialize**](FakeApi.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number | [**FakeOuterStringSerialize**](FakeApi.md#FakeOuterStringSerialize) | **Post** /fake/outer/string | +[**TestBodyWithQueryParams**](FakeApi.md#TestBodyWithQueryParams) | **Put** /fake/body-with-query-params | [**TestClientModel**](FakeApi.md#TestClientModel) | **Patch** /fake | To test \"client\" model [**TestEndpointParameters**](FakeApi.md#TestEndpointParameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**TestEnumParameters**](FakeApi.md#TestEnumParameters) | **Get** /fake | To test enum parameters @@ -25,15 +26,15 @@ Test serialization of outer boolean types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterBooleanSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterBooleanSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterBoolean**](OuterBoolean.md)| Input boolean as post body | + **booleanPostBody** | **optional.Bool**| Input boolean as post body | ### Return type @@ -46,7 +47,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -60,15 +61,15 @@ Test serialization of object with outer number type Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterCompositeSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterCompositeSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | + **outerComposite** | [**optional.Interface of OuterComposite**](OuterComposite.md)| Input composite as post body | ### Return type @@ -81,7 +82,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -95,15 +96,15 @@ Test serialization of outer number types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterNumberSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterNumberSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterNumber**](OuterNumber.md)| Input number as post body | + **body** | **optional.Float32**| Input number as post body | ### Return type @@ -116,7 +117,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -130,15 +131,15 @@ Test serialization of outer string types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterStringSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterStringSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterString**](OuterString.md)| Input string as post body | + **body** | **optional.String**| Input string as post body | ### Return type @@ -151,12 +152,39 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **TestBodyWithQueryParams** +> TestBodyWithQueryParams(ctx, query, user) + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **query** | **string**| | + **user** | [**User**](User.md)| | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestClientModel** -> Client TestClientModel(ctx, body) +> Client TestClientModel(ctx, client) To test \"client\" model To test \"client\" model @@ -165,8 +193,8 @@ To test \"client\" model Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type @@ -184,7 +212,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestEndpointParameters** -> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte_, optional) +> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte, optional) Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -193,32 +221,32 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **number** | **float32**| None | **double** | **float64**| None | **patternWithoutDelimiter** | **string**| None | - **byte_** | **string**| None | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **byte** | **string**| None | + **optional** | ***TestEndpointParametersOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a TestEndpointParametersOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **float32**| None | - **double** | **float64**| None | - **patternWithoutDelimiter** | **string**| None | - **byte_** | **string**| None | - **integer** | **int32**| None | - **int32_** | **int32**| None | - **int64_** | **int64**| None | - **float** | **float32**| None | - **string_** | **string**| None | - **binary** | **string**| None | - **date** | **string**| None | - **dateTime** | **time.Time**| None | - **password** | **string**| None | - **callback** | **string**| None | + + + + + **integer** | **optional.Int32**| None | + **int32** | **optional.Int32**| None | + **int64** | **optional.Int64**| None | + **float** | **optional.Float32**| None | + **string** | **optional.String**| None | + **binary** | **optional.Interface of *os.File****optional.*os.File**| None | + **date** | **optional.String**| None | + **dateTime** | **optional.Time**| None | + **password** | **optional.String**| None | + **callback** | **optional.String**| None | ### Return type @@ -230,8 +258,8 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 - - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -245,22 +273,22 @@ To test enum parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***TestEnumParametersOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a TestEnumParametersOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **enumFormStringArray** | [**[]string**](string.md)| Form parameter enum test (string array) | - **enumFormString** | **string**| Form parameter enum test (string) | [default to -efg] - **enumHeaderStringArray** | [**[]string**](string.md)| Header parameter enum test (string array) | - **enumHeaderString** | **string**| Header parameter enum test (string) | [default to -efg] - **enumQueryStringArray** | [**[]string**](string.md)| Query parameter enum test (string array) | - **enumQueryString** | **string**| Query parameter enum test (string) | [default to -efg] - **enumQueryInteger** | **int32**| Query parameter enum test (double) | - **enumQueryDouble** | **float64**| Query parameter enum test (double) | + **enumHeaderStringArray** | [**optional.Interface of []string**](string.md)| Header parameter enum test (string array) | + **enumHeaderString** | **optional.String**| Header parameter enum test (string) | [default to -efg] + **enumQueryStringArray** | [**optional.Interface of []string**](string.md)| Query parameter enum test (string array) | + **enumQueryString** | **optional.String**| Query parameter enum test (string) | [default to -efg] + **enumQueryInteger** | **optional.Int32**| Query parameter enum test (double) | + **enumQueryDouble** | **optional.Float64**| Query parameter enum test (double) | + **enumFormStringArray** | [**optional.Interface of []string**](array.md)| Form parameter enum test (string array) | + **enumFormString** | **optional.String**| Form parameter enum test (string) | ### Return type @@ -272,23 +300,21 @@ No authorization required ### HTTP request headers - - **Content-Type**: */* - - **Accept**: */* + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestInlineAdditionalProperties** -> TestInlineAdditionalProperties(ctx, param) +> TestInlineAdditionalProperties(ctx, requestBody) test inline additionalProperties - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **param** | [**interface{}**](interface{}.md)| request body | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **requestBody** | [**string**](string.md)| request body | ### Return type @@ -309,13 +335,11 @@ No authorization required > TestJsonFormData(ctx, param, param2) test json serialization of form data - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **param** | **string**| field1 | **param2** | **string**| field2 | @@ -329,7 +353,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/FakeClassnameTags123Api.md b/samples/client/petstore/go/go-petstore-withXml/docs/FakeClassnameTags123Api.md index 5690bc3e1e70..db334ab5689b 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/FakeClassnameTags123Api.md @@ -8,15 +8,17 @@ Method | HTTP request | Description # **TestClassname** -> Client TestClassname(ctx, body) +> Client TestClassname(ctx, client) +To test class name in snake case + To test class name in snake case ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/FormatTest.md b/samples/client/petstore/go/go-petstore-withXml/docs/FormatTest.md index 10e6c2ee5da7..025da8e72b75 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/FormatTest.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/FormatTest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes **Double** | **float64** | | [optional] [default to null] **String_** | **string** | | [optional] [default to null] **Byte_** | **string** | | [default to null] -**Binary** | **string** | | [optional] [default to null] +**Binary** | [****os.File**](*os.File.md) | | [optional] [default to null] **Date** | **string** | | [default to null] **DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] **Uuid** | **string** | | [optional] [default to null] diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md index 61271c1a2114..fa20c7e699c4 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md @@ -15,17 +15,15 @@ Method | HTTP request | Description # **AddPet** -> AddPet(ctx, body) +> AddPet(ctx, pet) Add a new pet to the store - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -38,7 +36,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -46,23 +44,21 @@ Name | Type | Description | Notes > DeletePet(ctx, petId, optional) Deletes a pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| Pet id to delete | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***DeletePetOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a DeletePetOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| Pet id to delete | - **apiKey** | **string**| | + + **apiKey** | **optional.String**| | ### Return type @@ -75,7 +71,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -89,7 +85,7 @@ Multiple status values can be provided with comma separated strings Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **status** | [**[]string**](string.md)| Status values that need to be considered for filter | ### Return type @@ -117,7 +113,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **tags** | [**[]string**](string.md)| Tags to filter by | ### Return type @@ -145,7 +141,7 @@ Returns a single pet Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet to return | ### Return type @@ -164,17 +160,15 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **UpdatePet** -> UpdatePet(ctx, body) +> UpdatePet(ctx, pet) Update an existing pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -187,7 +181,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -195,24 +189,22 @@ Name | Type | Description | Notes > UpdatePetWithForm(ctx, petId, optional) Updates a pet in the store with form data - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet that needs to be updated | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***UpdatePetWithFormOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a UpdatePetWithFormOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| ID of pet that needs to be updated | - **name** | **string**| Updated name of the pet | - **status** | **string**| Updated status of the pet | + + **name** | **optional.String**| Updated name of the pet | + **status** | **optional.String**| Updated status of the pet | ### Return type @@ -225,7 +217,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -233,24 +225,22 @@ Name | Type | Description | Notes > ModelApiResponse UploadFile(ctx, petId, optional) uploads an image - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet to update | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***UploadFileOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a UploadFileOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| ID of pet to update | - **additionalMetadata** | **string**| Additional data to pass to server | - **file** | ***os.File**| file to upload | + + **additionalMetadata** | **optional.String**| Additional data to pass to server | + **file** | **optional.Interface of *os.File****optional.*os.File**| file to upload | ### Return type diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md index 30fc16cb974a..e424e2d966fc 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md @@ -20,7 +20,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **string**| ID of the order that needs to be deleted | ### Return type @@ -34,7 +34,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -72,7 +72,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **int64**| ID of pet that needs to be fetched | ### Return type @@ -91,17 +91,15 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **PlaceOrder** -> Order PlaceOrder(ctx, body) +> Order PlaceOrder(ctx, order) Place an order for a pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Order**](Order.md)| order placed for purchasing the pet | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **order** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md b/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md index 0634a959ea6a..82210d18310e 100644 --- a/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md +++ b/samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **CreateUser** -> CreateUser(ctx, body) +> CreateUser(ctx, user) Create user This can only be done by the logged in user. @@ -24,8 +24,8 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**User**](User.md)| Created user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**User**](User.md)| Created user object | ### Return type @@ -38,22 +38,20 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **CreateUsersWithArrayInput** -> CreateUsersWithArrayInput(ctx, body) +> CreateUsersWithArrayInput(ctx, user) Creates list of users with given input array - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**[]User**](User.md)| List of user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**[]User**](array.md)| List of user object | ### Return type @@ -66,22 +64,20 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **CreateUsersWithListInput** -> CreateUsersWithListInput(ctx, body) +> CreateUsersWithListInput(ctx, user) Creates list of users with given input array - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**[]User**](User.md)| List of user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**[]User**](array.md)| List of user object | ### Return type @@ -94,7 +90,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -108,7 +104,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| The name that needs to be deleted | ### Return type @@ -122,7 +118,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -130,14 +126,12 @@ No authorization required > User GetUserByName(ctx, username) Get user by user name - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | ### Return type @@ -158,13 +152,11 @@ No authorization required > string LoginUser(ctx, username, password) Logs user into the system - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| The user name for login | **password** | **string**| The password for login in clear text | @@ -187,8 +179,6 @@ No authorization required > LogoutUser(ctx, ) Logs out current logged in user session - - ### Required Parameters This endpoint does not need any parameter. @@ -203,12 +193,12 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **UpdateUser** -> UpdateUser(ctx, username, body) +> UpdateUser(ctx, username, user) Updated user This can only be done by the logged in user. @@ -217,9 +207,9 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | + **user** | [**User**](User.md)| Updated user object | ### Return type @@ -232,7 +222,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/go/go-petstore-withXml/model_200_response.go b/samples/client/petstore/go/go-petstore-withXml/model_200_response.go index 9c816620730f..a07426f41ea5 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_200_response.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_200_response.go @@ -13,6 +13,5 @@ package petstore // Model for testing model name starting with number type Model200Response struct { Name int32 `json:"name,omitempty" xml:"name"` - Class string `json:"class,omitempty" xml:"class"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_additional_properties_class.go b/samples/client/petstore/go/go-petstore-withXml/model_additional_properties_class.go index 835d1e0f16a0..949cf7f3bc8d 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_additional_properties_class.go @@ -12,6 +12,5 @@ package petstore type AdditionalPropertiesClass struct { MapProperty map[string]string `json:"map_property,omitempty" xml:"map_property"` - MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty" xml:"map_of_map_property"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_animal.go b/samples/client/petstore/go/go-petstore-withXml/model_animal.go index 188e98e6d048..1b67b89a8e7c 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_animal.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_animal.go @@ -12,6 +12,5 @@ package petstore type Animal struct { ClassName string `json:"className" xml:"className"` - Color string `json:"color,omitempty" xml:"color"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_api_response.go b/samples/client/petstore/go/go-petstore-withXml/model_api_response.go index 5a510904814e..dd75096b629f 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_api_response.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_api_response.go @@ -12,8 +12,6 @@ package petstore type ModelApiResponse struct { Code int32 `json:"code,omitempty" xml:"code"` - Type_ string `json:"type,omitempty" xml:"type"` - Message string `json:"message,omitempty" xml:"message"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_array_test.go b/samples/client/petstore/go/go-petstore-withXml/model_array_test.go index 0857f990d929..28fb87e5f0da 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_array_test.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_array_test.go @@ -12,8 +12,6 @@ package petstore type ArrayTest struct { ArrayOfString []string `json:"array_of_string,omitempty" xml:"array_of_string"` - ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty" xml:"array_array_of_integer"` - ArrayArrayOfModel [][]ReadOnlyFirst `json:"array_array_of_model,omitempty" xml:"array_array_of_model"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_capitalization.go b/samples/client/petstore/go/go-petstore-withXml/model_capitalization.go index e7c2b9cf97be..74c537c45886 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_capitalization.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_capitalization.go @@ -12,15 +12,10 @@ package petstore type Capitalization struct { SmallCamel string `json:"smallCamel,omitempty" xml:"smallCamel"` - CapitalCamel string `json:"CapitalCamel,omitempty" xml:"CapitalCamel"` - SmallSnake string `json:"small_Snake,omitempty" xml:"small_Snake"` - CapitalSnake string `json:"Capital_Snake,omitempty" xml:"Capital_Snake"` - SCAETHFlowPoints string `json:"SCA_ETH_Flow_Points,omitempty" xml:"SCA_ETH_Flow_Points"` - // Name of the pet ATT_NAME string `json:"ATT_NAME,omitempty" xml:"ATT_NAME"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_cat.go b/samples/client/petstore/go/go-petstore-withXml/model_cat.go index 93d24c7e8e97..4c29c98ae4d3 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_cat.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_cat.go @@ -12,8 +12,6 @@ package petstore type Cat struct { ClassName string `json:"className" xml:"className"` - Color string `json:"color,omitempty" xml:"color"` - Declawed bool `json:"declawed,omitempty" xml:"declawed"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_category.go b/samples/client/petstore/go/go-petstore-withXml/model_category.go index 73095a1450e4..204290147a8a 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_category.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_category.go @@ -12,6 +12,5 @@ package petstore type Category struct { Id int64 `json:"id,omitempty" xml:"id"` - Name string `json:"name,omitempty" xml:"name"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_dog.go b/samples/client/petstore/go/go-petstore-withXml/model_dog.go index cf09a41fad66..b8cc43615db2 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_dog.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_dog.go @@ -12,8 +12,6 @@ package petstore type Dog struct { ClassName string `json:"className" xml:"className"` - Color string `json:"color,omitempty" xml:"color"` - Breed string `json:"breed,omitempty" xml:"breed"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_enum_arrays.go b/samples/client/petstore/go/go-petstore-withXml/model_enum_arrays.go index c7e3d188b05c..a457eb278148 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_enum_arrays.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_enum_arrays.go @@ -12,6 +12,5 @@ package petstore type EnumArrays struct { JustSymbol string `json:"just_symbol,omitempty" xml:"just_symbol"` - ArrayEnum []string `json:"array_enum,omitempty" xml:"array_enum"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go b/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go index b0180356b4a7..4950a03e747c 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_enum_class.go @@ -15,8 +15,6 @@ 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-withXml/model_enum_test.go b/samples/client/petstore/go/go-petstore-withXml/model_enum_test.go index c5c19a8784f4..3dc4896a3cce 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_enum_test.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_enum_test.go @@ -12,10 +12,8 @@ package petstore type EnumTest struct { EnumString string `json:"enum_string,omitempty" xml:"enum_string"` - + EnumStringRequired string `json:"enum_string_required" xml:"enum_string_required"` EnumInteger int32 `json:"enum_integer,omitempty" xml:"enum_integer"` - EnumNumber float64 `json:"enum_number,omitempty" xml:"enum_number"` - OuterEnum *OuterEnum `json:"outerEnum,omitempty" xml:"outerEnum"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_format_test.go b/samples/client/petstore/go/go-petstore-withXml/model_format_test.go index 6c7a47c6c7d2..b1c7246c3f19 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_format_test.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_format_test.go @@ -11,33 +11,25 @@ package petstore import ( +import ( + "os" "time" ) +) + type FormatTest struct { Integer int32 `json:"integer,omitempty" xml:"integer"` - Int32_ int32 `json:"int32,omitempty" xml:"int32"` - Int64_ int64 `json:"int64,omitempty" xml:"int64"` - Number float32 `json:"number" xml:"number"` - Float float32 `json:"float,omitempty" xml:"float"` - Double float64 `json:"double,omitempty" xml:"double"` - String_ string `json:"string,omitempty" xml:"string"` - Byte_ string `json:"byte" xml:"byte"` - - Binary string `json:"binary,omitempty" xml:"binary"` - + Binary **os.File `json:"binary,omitempty" xml:"binary"` Date string `json:"date" xml:"date"` - DateTime time.Time `json:"dateTime,omitempty" xml:"dateTime"` - Uuid string `json:"uuid,omitempty" xml:"uuid"` - Password string `json:"password" xml:"password"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_has_only_read_only.go b/samples/client/petstore/go/go-petstore-withXml/model_has_only_read_only.go index f4e97f7c8c87..f00cae577d06 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_has_only_read_only.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_has_only_read_only.go @@ -12,6 +12,5 @@ package petstore type HasOnlyReadOnly struct { Bar string `json:"bar,omitempty" xml:"bar"` - Foo string `json:"foo,omitempty" xml:"foo"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_map_test.go b/samples/client/petstore/go/go-petstore-withXml/model_map_test.go index f9155712d6e7..dea5730c205b 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_map_test.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_map_test.go @@ -12,6 +12,5 @@ package petstore type MapTest struct { MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty" xml:"map_map_of_string"` - MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty" xml:"map_of_enum_string"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore-withXml/model_mixed_properties_and_additional_properties_class.go index 4e8860b2af50..95ced6ff26df 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_mixed_properties_and_additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_mixed_properties_and_additional_properties_class.go @@ -16,8 +16,6 @@ import ( type MixedPropertiesAndAdditionalPropertiesClass struct { Uuid string `json:"uuid,omitempty" xml:"uuid"` - DateTime time.Time `json:"dateTime,omitempty" xml:"dateTime"` - Map_ map[string]Animal `json:"map,omitempty" xml:"map"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_name.go b/samples/client/petstore/go/go-petstore-withXml/model_name.go index e5c990657b62..151895376816 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_name.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_name.go @@ -13,10 +13,7 @@ package petstore // Model for testing model name same as property name type Name struct { Name int32 `json:"name" xml:"name"` - SnakeCase int32 `json:"snake_case,omitempty" xml:"snake_case"` - Property string `json:"property,omitempty" xml:"property"` - Var123Number int32 `json:"123Number,omitempty" xml:"123Number"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_order.go b/samples/client/petstore/go/go-petstore-withXml/model_order.go index b0bd474d61b3..20c120d02632 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_order.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_order.go @@ -16,15 +16,10 @@ import ( type Order struct { Id int64 `json:"id,omitempty" xml:"id"` - PetId int64 `json:"petId,omitempty" xml:"petId"` - Quantity int32 `json:"quantity,omitempty" xml:"quantity"` - ShipDate time.Time `json:"shipDate,omitempty" xml:"shipDate"` - // Order Status Status string `json:"status,omitempty" xml:"status"` - Complete bool `json:"complete,omitempty" xml:"complete"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_outer_composite.go b/samples/client/petstore/go/go-petstore-withXml/model_outer_composite.go index 21db0b42cc8a..54d1a7b874c7 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_outer_composite.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_outer_composite.go @@ -12,8 +12,6 @@ package petstore type OuterComposite struct { MyNumber *OuterNumber `json:"my_number,omitempty" xml:"my_number"` - MyString *OuterString `json:"my_string,omitempty" xml:"my_string"` - MyBoolean *OuterBoolean `json:"my_boolean,omitempty" xml:"my_boolean"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go b/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go index 5ad5712734cc..0e724d17c5c8 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_outer_enum.go @@ -15,8 +15,6 @@ 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-withXml/model_pet.go b/samples/client/petstore/go/go-petstore-withXml/model_pet.go index ef3d03a3aa95..af5d2cf82029 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_pet.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_pet.go @@ -12,15 +12,10 @@ package petstore type Pet struct { Id int64 `json:"id,omitempty" xml:"id"` - Category *Category `json:"category,omitempty" xml:"category"` - Name string `json:"name" xml:"name"` - PhotoUrls []string `json:"photoUrls" xml:"photoUrls"` - Tags []Tag `json:"tags,omitempty" xml:"tags"` - // pet status in the store Status string `json:"status,omitempty" xml:"status"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_read_only_first.go b/samples/client/petstore/go/go-petstore-withXml/model_read_only_first.go index f38ef39d0e81..e141f7fa75a0 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_read_only_first.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_read_only_first.go @@ -12,6 +12,5 @@ package petstore type ReadOnlyFirst struct { Bar string `json:"bar,omitempty" xml:"bar"` - Baz string `json:"baz,omitempty" xml:"baz"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_tag.go b/samples/client/petstore/go/go-petstore-withXml/model_tag.go index 7f5aa02c8134..f014074836a7 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_tag.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_tag.go @@ -12,6 +12,5 @@ package petstore type Tag struct { Id int64 `json:"id,omitempty" xml:"id"` - Name string `json:"name,omitempty" xml:"name"` } diff --git a/samples/client/petstore/go/go-petstore-withXml/model_user.go b/samples/client/petstore/go/go-petstore-withXml/model_user.go index 8393633890dc..bc8478b6961a 100644 --- a/samples/client/petstore/go/go-petstore-withXml/model_user.go +++ b/samples/client/petstore/go/go-petstore-withXml/model_user.go @@ -12,19 +12,12 @@ package petstore type User struct { Id int64 `json:"id,omitempty" xml:"id"` - Username string `json:"username,omitempty" xml:"username"` - FirstName string `json:"firstName,omitempty" xml:"firstName"` - LastName string `json:"lastName,omitempty" xml:"lastName"` - Email string `json:"email,omitempty" xml:"email"` - Password string `json:"password,omitempty" xml:"password"` - Phone string `json:"phone,omitempty" xml:"phone"` - // User Status UserStatus int32 `json:"userStatus,omitempty" xml:"userStatus"` } diff --git a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION index 855ff9501eb8..096bf47efe31 100644 --- a/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION +++ b/samples/client/petstore/go/go-petstore/.openapi-generator/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +3.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 35dea62225ef..365dcec4a138 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 - Package version: 1.0.0 -- Build package: io.swagger.codegen.languages.GoClientCodegen +- Build package: org.openapitools.codegen.languages.GoClientCodegen ## Installation Put the package under your project folder and add the following in import: @@ -26,6 +26,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite | *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **Post** /fake/outer/string | +*FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **Put** /fake/body-with-query-params | *FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **Patch** /fake | To test \"client\" model *FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **Get** /fake | To test enum parameters @@ -63,9 +64,11 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [Capitalization](docs/Capitalization.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) + - [Dog](docs/Dog.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -90,8 +93,6 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) - - [Cat](docs/Cat.md) - - [Dog](docs/Dog.md) ## Documentation For Authorization diff --git a/samples/client/petstore/go/go-petstore/api/openapi.yaml b/samples/client/petstore/go/go-petstore/api/openapi.yaml new file mode 100644 index 000000000000..f87e7d7a0a74 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/api/openapi.yaml @@ -0,0 +1,1508 @@ +openapi: 3.0.1 +info: + title: Swagger Petstore + description: 'This spec is mainly for testing Petstore server and contains fake + endpoints, models. Please do not use this for any other purpose. Special characters: + " \' + termsOfService: http://swagger.io/terms/ + contact: + email: apiteam@swagger.io + license: + name: Apache-2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io +servers: +- url: http://petstore.swagger.io:80/v2 +tags: +- name: pet + description: Everything about your Pets + externalDocs: + description: Find out more + url: http://swagger.io +- name: store + description: Access to Petstore orders +- name: user + description: Operations about user + externalDocs: + description: Find out more about our store + url: http://swagger.io +paths: + /pet: + put: + tags: + - pet + summary: Update an existing pet + operationId: updatePet + requestBody: + description: Pet object that needs to be added to the store + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + required: true + responses: + 400: + description: Invalid ID supplied + content: {} + 404: + description: Pet not found + content: {} + 405: + description: Validation exception + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + post: + tags: + - pet + summary: Add a new pet to the store + operationId: addPet + requestBody: + description: Pet object that needs to be added to the store + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + required: true + responses: + 405: + description: Invalid input + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + explode: false + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + 200: + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid status value + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + explode: false + schema: + type: array + items: + type: string + responses: + 200: + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid tag value + content: {} + deprecated: true + security: + - petstore_auth: + - write:pets + - read:pets + /pet/{petId}: + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + 400: + description: Invalid ID supplied + content: {} + 404: + description: Pet not found + content: {} + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + name: + type: string + description: Updated name of the pet + status: + type: string + description: Updated status of the pet + responses: + 405: + description: Invalid input + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + delete: + tags: + - pet + summary: Deletes a pet + operationId: deletePet + parameters: + - name: api_key + in: header + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + 400: + description: Invalid pet value + content: {} + security: + - petstore_auth: + - write:pets + - read:pets + /pet/{petId}/uploadImage: + post: + tags: + - pet + summary: uploads an image + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + requestBody: + content: + multipart/form-data: + schema: + properties: + additionalMetadata: + type: string + description: Additional data to pass to server + file: + type: string + description: file to upload + format: binary + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - write:pets + - read:pets + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + 200: + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + operationId: placeOrder + requestBody: + description: order placed for purchasing the pet + content: + '*/*': + schema: + $ref: '#/components/schemas/Order' + required: true + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + 400: + description: Invalid Order + content: {} + /store/order/{order_id}: + get: + tags: + - store + summary: Find purchase order by ID + description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + maximum: 5 + minimum: 1 + type: integer + format: int64 + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + 400: + description: Invalid ID supplied + content: {} + 404: + description: Order not found + content: {} + delete: + tags: + - store + summary: Delete purchase order by ID + description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + 400: + description: Invalid ID supplied + content: {} + 404: + description: Order not found + content: {} + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + requestBody: + description: Created user object + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + operationId: createUsersWithArrayInput + requestBody: + description: List of user object + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + operationId: createUsersWithListInput + requestBody: + description: List of user object + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/User' + required: true + responses: + default: + description: successful operation + content: {} + /user/login: + get: + tags: + - user + summary: Logs user into the system + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + 200: + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + 400: + description: Invalid username/password supplied + content: {} + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + operationId: logoutUser + responses: + default: + description: successful operation + content: {} + /user/{username}: + get: + tags: + - user + summary: Get user by user name + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + 200: + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + requestBody: + description: Updated user object + content: + '*/*': + schema: + $ref: '#/components/schemas/User' + required: true + responses: + 400: + description: Invalid user supplied + content: {} + 404: + description: User not found + content: {} + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + /fake_classname_test: + patch: + tags: + - fake_classname_tags 123#$%^ + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + /fake: + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + enum: + - '>' + - $ + default: $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + explode: false + schema: + type: array + items: + type: string + enum: + - '>' + - $ + default: $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + requestBody: + content: + application/x-www-form-urlencoded: + schema: + properties: + enum_form_string_array: + type: array + description: Form parameter enum test (string array) + items: + type: string + enum: + - '>' + - $ + default: $ + enum_form_string: + type: string + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + default: -efg + responses: + 400: + description: Invalid request + content: {} + 404: + description: Not found + content: {} + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + requestBody: + content: + application/x-www-form-urlencoded: + schema: + required: + - byte + - double + - number + - pattern_without_delimiter + properties: + integer: + maximum: 100 + minimum: 10 + type: integer + description: None + int32: + maximum: 200 + minimum: 20 + type: integer + description: None + format: int32 + int64: + type: integer + description: None + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + description: None + float: + maximum: 987.6 + type: number + description: None + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + description: None + format: double + string: + pattern: /[a-z]/i + type: string + description: None + pattern_without_delimiter: + pattern: ^[A-Z].* + type: string + description: None + byte: + type: string + description: None + format: byte + binary: + type: string + description: None + format: binary + date: + type: string + description: None + format: date + dateTime: + type: string + description: None + format: date-time + password: + maxLength: 64 + minLength: 10 + type: string + description: None + format: password + callback: + type: string + description: None + required: true + responses: + 400: + description: Invalid username supplied + content: {} + 404: + description: User not found + content: {} + security: + - http_basic_test: [] + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + requestBody: + description: Input number as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + required: false + responses: + 200: + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + requestBody: + description: Input string as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + required: false + responses: + 200: + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + requestBody: + description: Input boolean as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + required: false + responses: + 200: + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + requestBody: + description: Input composite as post body + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + required: false + responses: + 200: + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + operationId: testJsonFormData + requestBody: + content: + application/x-www-form-urlencoded: + schema: + required: + - param + - param2 + properties: + param: + type: string + description: field1 + param2: + type: string + description: field2 + required: true + responses: + 200: + description: successful operation + content: {} + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + operationId: testInlineAdditionalProperties + requestBody: + description: request body + content: + application/json: + schema: + type: object + additionalProperties: + type: string + required: true + responses: + 200: + description: successful operation + content: {} + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + 200: + description: Success + content: {} + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags + operationId: test_special_tags + requestBody: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + responses: + 200: + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' +components: + schemas: + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + example: + name: name + id: 6 + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + description: User Status + format: int32 + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username + xml: + name: User + OuterNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + type: string + description: | + Name of the pet + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Name: + required: + - name + type: object + properties: + name: + type: integer + format: int32 + snake_case: + type: integer + format: int32 + readOnly: true + property: + type: string + 123Number: + type: integer + readOnly: true + description: Model for testing model name same as property name + xml: + name: Name + EnumClass: + type: string + enum: + - _abc + - -efg + - (xyz) + default: -efg + List: + type: object + properties: + 123-list: + type: string + NumberOnly: + type: object + properties: + JustNumber: + type: number + 200_response: + type: object + properties: + name: + type: integer + format: int32 + class: + type: string + description: Model for testing model name starting with number + xml: + name: Name + Client: + type: object + properties: + client: + type: string + example: + client: client + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Enum_Test: + required: + - enum_string_required + type: object + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - "" + enum_string_required: + type: string + enum: + - UPPER + - lower + - "" + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + xml: + name: Order + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + $special[model.name]: + type: object + properties: + $special[property.name]: + type: integer + format: int64 + xml: + name: $special[model.name] + Return: + type: object + properties: + return: + type: integer + format: int32 + description: Model for testing reserved words + xml: + name: Return + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + OuterEnum: + type: string + enum: + - placed + - approved + - delivered + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + example: {} + format_test: + required: + - byte + - date + - number + - password + type: object + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + maximum: 2E+2 + minimum: 2E+1 + type: integer + format: int32 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + maximum: 987.6 + minimum: 54.3 + type: number + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + format: double + string: + pattern: /[a-z]/i + type: string + byte: + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + password: + maxLength: 64 + minLength: 10 + type: string + format: password + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterString: + type: string + ClassModel: + type: object + properties: + _class: + type: string + description: Model for testing model with "_class" property + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + Animal: + required: + - className + type: object + properties: + className: + type: string + color: + type: string + default: red + discriminator: + propertyName: className + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + example: + name: name + id: 1 + xml: + name: Tag + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + Pet: + required: + - name + - photoUrls + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + xml: + name: Pet + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + http_basic_test: + type: http + scheme: basic + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query diff --git a/samples/client/petstore/go/go-petstore/api_another_fake.go b/samples/client/petstore/go/go-petstore/api_another_fake.go index 8e1c565507b6..b37a21249b70 100644 --- a/samples/client/petstore/go/go-petstore/api_another_fake.go +++ b/samples/client/petstore/go/go-petstore/api_another_fake.go @@ -15,8 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" + "context" ) // Linger please @@ -26,18 +25,21 @@ var ( type AnotherFakeApiService service -/* AnotherFakeApiService To test special tags +/* +AnotherFakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -65,25 +67,50 @@ func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/api_fake.go b/samples/client/petstore/go/go-petstore/api_fake.go index a42fc29c2ca7..ca8392914b5e 100644 --- a/samples/client/petstore/go/go-petstore/api_fake.go +++ b/samples/client/petstore/go/go-petstore/api_fake.go @@ -15,9 +15,9 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "time" - "encoding/json" + "context" + "github.com/antihax/optional" + "os" ) // Linger please @@ -27,19 +27,27 @@ var ( type FakeApiService service -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterBooleanSerializeOpts - Optional Parameters: + * @param "" (optional.Bool) - Input boolean as post body + +@return OuterBoolean +*/ + +type FakeOuterBooleanSerializeOpts struct { + optional.Bool +} + +func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals *FakeOuterBooleanSerializeOpts) (OuterBoolean, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterBoolean + localVarReturnValue OuterBoolean ) // create path and map variables @@ -59,7 +67,7 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -67,44 +75,78 @@ func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVar localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterBoolean); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterBoolean + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterCompositeSerializeOpts - Optional Parameters: + * @param "" (optional.Interface of OuterComposite) - Input composite as post body + +@return OuterComposite +*/ + +type FakeOuterCompositeSerializeOpts struct { + optional.Interface +} + +func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals *FakeOuterCompositeSerializeOpts) (OuterComposite, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterComposite + localVarReturnValue OuterComposite ) // create path and map variables @@ -124,7 +166,7 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -132,44 +174,82 @@ func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localV localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterComposite); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + + localVarOptional, localVarOptionalok := localVarOptionals..Value().(OuterComposite) + if !localVarOptionalok { + return localVarReturnValue, nil, reportError("outerComposite should be OuterComposite") + } + localVarPostBody = &localVarOptional } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterComposite + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterNumberSerializeOpts - Optional Parameters: + * @param "" (optional.Float32) - Input number as post body + +@return OuterNumber +*/ + +type FakeOuterNumberSerializeOpts struct { + optional.Float32 +} + +func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals *FakeOuterNumberSerializeOpts) (OuterNumber, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterNumber + localVarReturnValue OuterNumber ) // create path and map variables @@ -189,7 +269,7 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -197,44 +277,78 @@ func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarO localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterNumber); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterNumber + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService +/* +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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *FakeOuterStringSerializeOpts - Optional Parameters: + * @param "" (optional.String) - Input string as post body + +@return OuterString +*/ + +type FakeOuterStringSerializeOpts struct { + optional.String +} + +func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals *FakeOuterStringSerializeOpts) (OuterString, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload OuterString + localVarReturnValue OuterString ) // create path and map variables @@ -254,7 +368,7 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO } // to determine the Accept header - localVarHttpHeaderAccepts := []string{} + localVarHttpHeaderAccepts := []string{"*/*"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -262,43 +376,145 @@ func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarO localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterString); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarPostBody = &localVarOptionals..Value() + } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v OuterString + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +FakeApiService + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param query + * @param user + + +*/ +func (a *FakeApiService) TestBodyWithQueryParams(ctx context.Context, query string, user User) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/fake/body-with-query-params" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + localVarQueryParams.Add("query", parameterToString(query, "csv")) + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + // body params + localVarPostBody = &user + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err } - return successPayload, localVarHttpResponse, err + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil } -/* FakeApiService To test \"client\" model +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *FakeApiService) TestClientModel(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -326,54 +542,97 @@ func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Clie localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param number None + * @param double None + * @param patternWithoutDelimiter None + * @param byte None + * @param optional nil or *TestEndpointParametersOpts - Optional Parameters: + * @param "" (optional.Int32) - None + * @param "" (optional.Int32) - None + * @param "" (optional.Int64) - None + * @param "" (optional.Float32) - None + * @param "" (optional.String) - None + * @param "" (optional.*os.File) - None + * @param "" (optional.String) - None + * @param "" (optional.Time) - None + * @param "" (optional.String) - None + * @param "" (optional.String) - None + + +*/ + +type TestEndpointParametersOpts struct { + optional.Int32 + optional.Int32 + optional.Int64 + optional.Float32 + optional.String + optional.*os.File + optional.String + optional.Time + optional.String + optional.String +} + +func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte string, localVarOptionals *TestEndpointParametersOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -394,39 +653,9 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa if double > 123.4 { return nil, reportError("double must be less than 123.4") } - if err := typeCheckParameter(localVarOptionals["integer"], "int32", "integer"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["int32_"], "int32", "int32_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["int64_"], "int64", "int64_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["float"], "float32", "float"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["string_"], "string", "string_"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["binary"], "string", "binary"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["date"], "string", "date"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["dateTime"], "time.Time", "dateTime"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["callback"], "string", "callback"); err != nil { - return nil, err - } // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -435,46 +664,57 @@ 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{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["integer"].(int32); localVarOk { - localVarFormParams.Add("integer", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("integer", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["int32_"].(int32); localVarOk { - localVarFormParams.Add("int32", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("int32", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["int64_"].(int64); localVarOk { - localVarFormParams.Add("int64", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("int64", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("number", parameterToString(number, "")) - if localVarTempParam, localVarOk := localVarOptionals["float"].(float32); localVarOk { - localVarFormParams.Add("float", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("float", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("double", parameterToString(double, "")) - if localVarTempParam, localVarOk := localVarOptionals["string_"].(string); localVarOk { - localVarFormParams.Add("string", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("string", parameterToString(localVarOptionals..Value(), "")) } localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, "")) - localVarFormParams.Add("byte", parameterToString(byte_, "")) - if localVarTempParam, localVarOk := localVarOptionals["binary"].(string); localVarOk { - localVarFormParams.Add("binary", parameterToString(localVarTempParam, "")) + localVarFormParams.Add("byte", parameterToString(byte, "")) + var localVarFile *os.File + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFileOk := false + localVarFile, localVarFileOk = localVarOptionals..Value().(*os.File) + if !localVarFileOk { + return nil, reportError("binary should be *os.File") + } } - if localVarTempParam, localVarOk := localVarOptionals["date"].(string); localVarOk { - localVarFormParams.Add("date", parameterToString(localVarTempParam, "")) + if localVarFile != nil { + fbs, _ := ioutil.ReadAll(localVarFile) + localVarFileBytes = fbs + localVarFileName = localVarFile.Name() + localVarFile.Close() } - if localVarTempParam, localVarOk := localVarOptionals["dateTime"].(time.Time); localVarOk { - localVarFormParams.Add("dateTime", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("date", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk { - localVarFormParams.Add("password", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("dateTime", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["callback"].(string); localVarOk { - localVarFormParams.Add("callback", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("password", parameterToString(localVarOptionals..Value(), "")) + } + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("callback", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -485,33 +725,61 @@ func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number floa if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService To test enum parameters +/* +FakeApiService 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *TestEnumParametersOpts - Optional Parameters: + * @param "EnumHeaderStringArray" (optional.Interface of []string) - Header parameter enum test (string array) + * @param "EnumHeaderString" (optional.String) - Header parameter enum test (string) + * @param "EnumQueryStringArray" (optional.Interface of []string) - Query parameter enum test (string array) + * @param "EnumQueryString" (optional.String) - Query parameter enum test (string) + * @param "EnumQueryInteger" (optional.Int32) - Query parameter enum test (double) + * @param "EnumQueryDouble" (optional.Float64) - Query parameter enum test (double) + * @param "" (optional.Interface of []string) - Form parameter enum test (string array) + * @param "" (optional.String) - Form parameter enum test (string) + + +*/ + +type TestEnumParametersOpts struct { + EnumHeaderStringArray optional.Interface + EnumHeaderString optional.String + EnumQueryStringArray optional.Interface + EnumQueryString optional.String + EnumQueryInteger optional.Int32 + EnumQueryDouble optional.Float64 + optional.Interface + optional.String +} + +func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals *TestEnumParametersOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -520,33 +788,21 @@ 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 - } - if err := typeCheckParameter(localVarOptionals["enumHeaderString"], "string", "enumHeaderString"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryString"], "string", "enumQueryString"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryInteger"], "int32", "enumQueryInteger"); err != nil { - return nil, err - } - if err := typeCheckParameter(localVarOptionals["enumQueryDouble"], "float64", "enumQueryDouble"); err != nil { - return nil, err - } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryStringArray"].([]string); localVarOk { - localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarTempParam, "csv")) + if localVarOptionals != nil && localVarOptionals.EnumQueryStringArray.IsSet() { + localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarOptionals.EnumQueryStringArray.Value(), "csv")) + } + if localVarOptionals != nil && localVarOptionals.EnumQueryString.IsSet() { + localVarQueryParams.Add("enum_query_string", parameterToString(localVarOptionals.EnumQueryString.Value(), "csv")) } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryString"].(string); localVarOk { - localVarQueryParams.Add("enum_query_string", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals.EnumQueryInteger.IsSet() { + localVarQueryParams.Add("enum_query_integer", parameterToString(localVarOptionals.EnumQueryInteger.Value(), "csv")) } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryInteger"].(int32); localVarOk { - localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals.EnumQueryDouble.IsSet() { + localVarQueryParams.Add("enum_query_double", parameterToString(localVarOptionals.EnumQueryDouble.Value(), "csv")) } // to determine the Content-Type header - localVarHttpContentTypes := []string{"*/*"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -555,27 +811,24 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"*/*"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["enumHeaderStringArray"].([]string); localVarOk { - localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarTempParam, "csv") + if localVarOptionals != nil && localVarOptionals.EnumHeaderStringArray.IsSet() { + localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarOptionals.EnumHeaderStringArray.Value(), "csv") } - if localVarTempParam, localVarOk := localVarOptionals["enumHeaderString"].(string); localVarOk { - localVarHeaderParams["enum_header_string"] = parameterToString(localVarTempParam, "") + if localVarOptionals != nil && localVarOptionals.EnumHeaderString.IsSet() { + localVarHeaderParams["enum_header_string"] = parameterToString(localVarOptionals.EnumHeaderString.Value(), "csv") } - if localVarTempParam, localVarOk := localVarOptionals["enumFormStringArray"].([]string); localVarOk { - localVarFormParams.Add("enum_form_string_array", parameterToString(localVarTempParam, "csv")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("enum_form_string_array", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["enumFormString"].(string); localVarOk { - localVarFormParams.Add("enum_form_string", parameterToString(localVarTempParam, "")) - } - if localVarTempParam, localVarOk := localVarOptionals["enumQueryDouble"].(float64); localVarOk { - localVarFormParams.Add("enum_query_double", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("enum_form_string", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -586,25 +839,40 @@ func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptiona if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService test inline additionalProperties +/* +FakeApiService test inline additionalProperties + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param requestBody request body - * @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) { + +*/ +func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, requestBody string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -632,7 +900,7 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = ¶m + localVarPostBody = &requestBody r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -642,26 +910,41 @@ func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, par if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* FakeApiService test json serialization of form data +/* +FakeApiService test json serialization of form data + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param param field1 + * @param param2 field2 + - * @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) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -672,7 +955,7 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par localVarFormParams := url.Values{} // to determine the Content-Type header - localVarHttpContentTypes := []string{"application/json"} + localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) @@ -699,10 +982,22 @@ func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, par if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go index 9da799e41603..d4ea4dc99801 100644 --- a/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go +++ b/samples/client/petstore/go/go-petstore/api_fake_classname_tags123.go @@ -15,8 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" + "context" ) // Linger please @@ -26,17 +25,21 @@ 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) { +/* +FakeClassnameTags123ApiService To test class name in snake case +To test class name in snake case + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param client client model + +@return Client +*/ +func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, client Client) (Client, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Client + localVarReturnValue Client ) // create path and map variables @@ -64,7 +67,7 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &client if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { @@ -74,27 +77,53 @@ func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body } else { key = auth.Key } + localVarQueryParams.Add("api_key_query", key) } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Client + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/api_pet.go b/samples/client/petstore/go/go-petstore/api_pet.go index 44170b2adb8c..2958e8d4320c 100644 --- a/samples/client/petstore/go/go-petstore/api_pet.go +++ b/samples/client/petstore/go/go-petstore/api_pet.go @@ -15,10 +15,10 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "os" - "encoding/json" + "context" "fmt" + "github.com/antihax/optional" + "os" ) // Linger please @@ -28,17 +28,20 @@ var ( type PetApiService service -/* PetApiService Add a new pet to the store +/* +PetApiService Add a new pet to the store + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param pet Pet object that needs to be added 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) { + +*/ +func (a *PetApiService) AddPet(ctx context.Context, pet Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -58,7 +61,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -66,7 +69,7 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &pet r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -76,27 +79,47 @@ func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, e if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Deletes a pet +/* +PetApiService Deletes a pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId Pet id to delete + * @param optional nil or *DeletePetOpts - Optional Parameters: + * @param "ApiKey" (optional.String) - + - * @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) { +*/ + +type DeletePetOpts struct { + ApiKey optional.String +} + +func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals *DeletePetOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -106,9 +129,6 @@ 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{} @@ -120,15 +140,15 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["apiKey"].(string); localVarOk { - localVarHeaderParams["api_key"] = parameterToString(localVarTempParam, "") + if localVarOptionals != nil && localVarOptionals.ApiKey.IsSet() { + localVarHeaderParams["api_key"] = parameterToString(localVarOptionals.ApiKey.Value(), "csv") } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -139,26 +159,41 @@ func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOpti if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Finds Pets by status +/* +PetApiService Finds Pets by status 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue []Pet ) // create path and map variables @@ -188,38 +223,66 @@ func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ( } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Finds Pets by tags +/* +PetApiService Finds Pets by tags 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue []Pet ) // create path and map variables @@ -249,38 +312,66 @@ func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pe } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v []Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Find pet by ID +/* +PetApiService Find pet by ID Returns a single pet - * @param ctx context.Context for authentication, logging, tracing, etc. -@param petId ID of pet to return -@return Pet*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue Pet ) // create path and map variables @@ -318,41 +409,70 @@ func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http key = auth.Key } localVarHeaderParams["api_key"] = key + } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Pet + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* PetApiService Update an existing pet +/* +PetApiService Update an existing pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param pet Pet object that needs to be added 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) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) { +*/ +func (a *PetApiService) UpdatePet(ctx context.Context, pet Pet) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -372,7 +492,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -380,7 +500,7 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &pet r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -390,28 +510,49 @@ func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService Updates a pet in the store with form data +/* +PetApiService Updates a pet in the store with form data + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId ID of pet that needs to be updated + * @param optional nil or *UpdatePetWithFormOpts - Optional Parameters: + * @param "" (optional.String) - Updated name of the pet + * @param "" (optional.String) - Updated status of the pet + - * @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) { +*/ + +type UpdatePetWithFormOpts struct { + optional.String + optional.String +} + +func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals *UpdatePetWithFormOpts) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -421,12 +562,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 - } - if err := typeCheckParameter(localVarOptionals["status"], "string", "status"); err != nil { - return nil, err - } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"} @@ -438,18 +573,18 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["name"].(string); localVarOk { - localVarFormParams.Add("name", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("name", parameterToString(localVarOptionals..Value(), "")) } - if localVarTempParam, localVarOk := localVarOptionals["status"].(string); localVarOk { - localVarFormParams.Add("status", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("status", parameterToString(localVarOptionals..Value(), "")) } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { @@ -460,29 +595,49 @@ func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, loca if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* PetApiService uploads an image +/* +PetApiService uploads an image + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param petId ID of pet to update + * @param optional nil or *UploadFileOpts - Optional Parameters: + * @param "" (optional.String) - Additional data to pass to server + * @param "" (optional.*os.File) - file to upload + +@return ModelApiResponse +*/ + +type UploadFileOpts struct { + optional.String + optional.*os.File +} - * @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) { +func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals *UploadFileOpts) (ModelApiResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload ModelApiResponse + localVarReturnValue ModelApiResponse ) // create path and map variables @@ -492,9 +647,6 @@ 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"} @@ -513,12 +665,16 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - if localVarTempParam, localVarOk := localVarOptionals["additionalMetadata"].(string); localVarOk { - localVarFormParams.Add("additionalMetadata", parameterToString(localVarTempParam, "")) + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFormParams.Add("additionalMetadata", parameterToString(localVarOptionals..Value(), "")) } - var localVarFile (*os.File) - if localVarTempParam, localVarOk := localVarOptionals["file"].(*os.File); localVarOk { - localVarFile = localVarTempParam + var localVarFile *os.File + if localVarOptionals != nil && localVarOptionals..IsSet() { + localVarFileOk := false + localVarFile, localVarFileOk = localVarOptionals..Value().(*os.File) + if !localVarFileOk { + return localVarReturnValue, nil, reportError("file should be *os.File") + } } if localVarFile != nil { fbs, _ := ioutil.ReadAll(localVarFile) @@ -528,22 +684,47 @@ func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOpt } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v ModelApiResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/api_store.go b/samples/client/petstore/go/go-petstore/api_store.go index 16aea9810318..3fad36ed610e 100644 --- a/samples/client/petstore/go/go-petstore/api_store.go +++ b/samples/client/petstore/go/go-petstore/api_store.go @@ -15,8 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" + "context" "fmt" ) @@ -27,17 +26,21 @@ var ( type StoreApiService service -/* StoreApiService Delete purchase order by ID +/* +StoreApiService Delete purchase order by ID 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 */ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param orderId ID of the order that needs to be deleted + + +*/ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -58,7 +61,7 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -74,25 +77,40 @@ func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*htt if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* StoreApiService Returns pet inventories by status +/* +StoreApiService Returns pet inventories by status Returns a map of status codes to quantities - * @param ctx context.Context for authentication, logging, tracing, etc. -@return map[string]int32*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + +@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 + localVarReturnValue map[string]int32 ) // create path and map variables @@ -129,42 +147,71 @@ func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, * key = auth.Key } localVarHeaderParams["api_key"] = key + } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v map[string]int32 + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* StoreApiService Find purchase order by ID +/* +StoreApiService Find purchase order by ID 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*/ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @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 + localVarReturnValue Order ) // create path and map variables @@ -175,10 +222,10 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if orderId < 1 { - return successPayload, nil, reportError("orderId must be greater than 1") + return localVarReturnValue, nil, reportError("orderId must be greater than 1") } if orderId > 5 { - return successPayload, nil, reportError("orderId must be less than 5") + return localVarReturnValue, nil, reportError("orderId must be less than 5") } // to determine the Content-Type header @@ -200,38 +247,65 @@ func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Orde } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } -/* StoreApiService Place an order for a pet +/* +StoreApiService Place an order for a pet + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param order order placed for purchasing the 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) { +@return Order +*/ +func (a *StoreApiService) PlaceOrder(ctx context.Context, order Order) (Order, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - successPayload Order + localVarReturnValue Order ) // create path and map variables @@ -259,25 +333,50 @@ func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *h localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &order r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v Order + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr } - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/api_user.go b/samples/client/petstore/go/go-petstore/api_user.go index 9fb8a37f6535..4f1d061162bb 100644 --- a/samples/client/petstore/go/go-petstore/api_user.go +++ b/samples/client/petstore/go/go-petstore/api_user.go @@ -15,8 +15,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" - "encoding/json" + "context" "fmt" ) @@ -27,17 +26,21 @@ var ( type UserApiService service -/* UserApiService Create user +/* +UserApiService Create 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user Created user object + + +*/ +func (a *UserApiService) CreateUser(ctx context.Context, user User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -57,7 +60,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -65,7 +68,7 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -75,25 +78,40 @@ func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Respo if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Creates list of users with given input array +/* +UserApiService Creates list of users with given input array + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user List of user object + - * @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) { +*/ +func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, user []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -113,7 +131,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -121,7 +139,7 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -131,25 +149,40 @@ func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []U if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Creates list of users with given input array +/* +UserApiService Creates list of users with given input array + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param user List of user object - * @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) { + +*/ +func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, user []User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -169,7 +202,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -177,7 +210,7 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -187,25 +220,41 @@ func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []Us if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Delete user +/* +UserApiService Delete 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 */ + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The name that needs to be deleted + + +*/ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -226,7 +275,7 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -242,26 +291,40 @@ func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Get user by user name +/* +UserApiService Get user by user name + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The name that needs to be fetched. Use user1 for testing. - * @param ctx context.Context for authentication, logging, tracing, etc. -@param username The name that needs to be fetched. Use user1 for testing. -@return User*/ +@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 + localVarReturnValue User ) // create path and map variables @@ -291,39 +354,66 @@ func (a *UserApiService) GetUserByName(ctx context.Context, username string) (Us } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v User + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* UserApiService Logs user into the system +/* +UserApiService Logs user into the system + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username The user name for login + * @param password The password for login in clear text - * @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*/ +@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 + localVarReturnValue string ) // create path and map variables @@ -333,8 +423,8 @@ 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, "")) + localVarQueryParams.Add("username", parameterToString(username, "csv")) + localVarQueryParams.Add("password", parameterToString(password, "csv")) // to determine the Content-Type header localVarHttpContentTypes := []string{} @@ -354,36 +444,64 @@ func (a *UserApiService) LoginUser(ctx context.Context, username string, passwor } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return successPayload, nil, err + return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return successPayload, localVarHttpResponse, err + return localVarReturnValue, localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err } - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } } - return successPayload, localVarHttpResponse, err + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + if localVarHttpResponse.StatusCode == 200 { + var v string + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil } -/* UserApiService Logs out current logged in user session +/* +UserApiService Logs out current logged in user session + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - * @param ctx context.Context for authentication, logging, tracing, etc. -@return */ +*/ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -403,7 +521,7 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) } // to determine the Accept header - localVarHttpHeaderAccepts := []string{"application/xml", "application/json"} + localVarHttpHeaderAccepts := []string{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -419,26 +537,42 @@ func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } -/* UserApiService Updated user +/* +UserApiService Updated 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 ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param username name that need to be deleted + * @param user Updated user object + + +*/ +func (a *UserApiService) UpdateUser(ctx context.Context, username string, user User) (*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte + ) // create path and map variables @@ -459,7 +593,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{} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) @@ -467,7 +601,7 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params - localVarPostBody = &body + localVarPostBody = &user r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -477,10 +611,22 @@ func (a *UserApiService) UpdateUser(ctx context.Context, username string, body U if err != nil || localVarHttpResponse == nil { return localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + + return localVarHttpResponse, newErr } - return localVarHttpResponse, err + + return localVarHttpResponse, nil } diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index d2f8f3092c33..c3c62e6da28a 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -29,7 +29,7 @@ import ( "time" "unicode/utf8" - "golang.org/x/net/context" + "context" "golang.org/x/oauth2" ) @@ -315,6 +315,21 @@ func (c *APIClient) prepareRequest( return localVarRequest, nil } +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -349,6 +364,8 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { @@ -439,3 +456,25 @@ func CacheExpires(r *http.Response) time.Time { func strlen(s string) int { return utf8.RuneCountInString(s) } + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/docs/AnotherFakeApi.md b/samples/client/petstore/go/go-petstore/docs/AnotherFakeApi.md index 1bc1af9ddd69..ce9779af2648 100644 --- a/samples/client/petstore/go/go-petstore/docs/AnotherFakeApi.md +++ b/samples/client/petstore/go/go-petstore/docs/AnotherFakeApi.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **TestSpecialTags** -> Client TestSpecialTags(ctx, body) +> Client TestSpecialTags(ctx, client) To test special tags To test special tags @@ -17,8 +17,8 @@ To test special tags Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type diff --git a/samples/client/petstore/go/go-petstore/docs/EnumTest.md b/samples/client/petstore/go/go-petstore/docs/EnumTest.md index d51101dd40be..c286c17df388 100644 --- a/samples/client/petstore/go/go-petstore/docs/EnumTest.md +++ b/samples/client/petstore/go/go-petstore/docs/EnumTest.md @@ -4,6 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **EnumString** | **string** | | [optional] [default to null] +**EnumStringRequired** | **string** | | [default to null] **EnumInteger** | **int32** | | [optional] [default to null] **EnumNumber** | **float64** | | [optional] [default to null] **OuterEnum** | [***OuterEnum**](OuterEnum.md) | | [optional] [default to null] diff --git a/samples/client/petstore/go/go-petstore/docs/FakeApi.md b/samples/client/petstore/go/go-petstore/docs/FakeApi.md index 5565e370e211..b77bf10cb749 100644 --- a/samples/client/petstore/go/go-petstore/docs/FakeApi.md +++ b/samples/client/petstore/go/go-petstore/docs/FakeApi.md @@ -8,6 +8,7 @@ Method | HTTP request | Description [**FakeOuterCompositeSerialize**](FakeApi.md#FakeOuterCompositeSerialize) | **Post** /fake/outer/composite | [**FakeOuterNumberSerialize**](FakeApi.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number | [**FakeOuterStringSerialize**](FakeApi.md#FakeOuterStringSerialize) | **Post** /fake/outer/string | +[**TestBodyWithQueryParams**](FakeApi.md#TestBodyWithQueryParams) | **Put** /fake/body-with-query-params | [**TestClientModel**](FakeApi.md#TestClientModel) | **Patch** /fake | To test \"client\" model [**TestEndpointParameters**](FakeApi.md#TestEndpointParameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**TestEnumParameters**](FakeApi.md#TestEnumParameters) | **Get** /fake | To test enum parameters @@ -25,15 +26,15 @@ Test serialization of outer boolean types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterBooleanSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterBooleanSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterBoolean**](OuterBoolean.md)| Input boolean as post body | + **booleanPostBody** | **optional.Bool**| Input boolean as post body | ### Return type @@ -46,7 +47,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -60,15 +61,15 @@ Test serialization of object with outer number type Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterCompositeSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterCompositeSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | + **outerComposite** | [**optional.Interface of OuterComposite**](OuterComposite.md)| Input composite as post body | ### Return type @@ -81,7 +82,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -95,15 +96,15 @@ Test serialization of outer number types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterNumberSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterNumberSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterNumber**](OuterNumber.md)| Input number as post body | + **body** | **optional.Float32**| Input number as post body | ### Return type @@ -116,7 +117,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: Not defined + - **Accept**: */* [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -130,15 +131,15 @@ Test serialization of outer string types Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***FakeOuterStringSerializeOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a FakeOuterStringSerializeOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterString**](OuterString.md)| Input string as post body | + **body** | **optional.String**| Input string as post body | ### Return type @@ -151,12 +152,39 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **TestBodyWithQueryParams** +> TestBodyWithQueryParams(ctx, query, user) + + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **query** | **string**| | + **user** | [**User**](User.md)| | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestClientModel** -> Client TestClientModel(ctx, body) +> Client TestClientModel(ctx, client) To test \"client\" model To test \"client\" model @@ -165,8 +193,8 @@ To test \"client\" model Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type @@ -184,7 +212,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestEndpointParameters** -> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte_, optional) +> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte, optional) Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -193,32 +221,32 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **number** | **float32**| None | **double** | **float64**| None | **patternWithoutDelimiter** | **string**| None | - **byte_** | **string**| None | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **byte** | **string**| None | + **optional** | ***TestEndpointParametersOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a TestEndpointParametersOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **float32**| None | - **double** | **float64**| None | - **patternWithoutDelimiter** | **string**| None | - **byte_** | **string**| None | - **integer** | **int32**| None | - **int32_** | **int32**| None | - **int64_** | **int64**| None | - **float** | **float32**| None | - **string_** | **string**| None | - **binary** | **string**| None | - **date** | **string**| None | - **dateTime** | **time.Time**| None | - **password** | **string**| None | - **callback** | **string**| None | + + + + + **integer** | **optional.Int32**| None | + **int32** | **optional.Int32**| None | + **int64** | **optional.Int64**| None | + **float** | **optional.Float32**| None | + **string** | **optional.String**| None | + **binary** | **optional.Interface of *os.File****optional.*os.File**| None | + **date** | **optional.String**| None | + **dateTime** | **optional.Time**| None | + **password** | **optional.String**| None | + **callback** | **optional.String**| None | ### Return type @@ -230,8 +258,8 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8 - - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8 + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -245,22 +273,22 @@ To test enum parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **optional** | ***TestEnumParametersOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a TestEnumParametersOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **enumFormStringArray** | [**[]string**](string.md)| Form parameter enum test (string array) | - **enumFormString** | **string**| Form parameter enum test (string) | [default to -efg] - **enumHeaderStringArray** | [**[]string**](string.md)| Header parameter enum test (string array) | - **enumHeaderString** | **string**| Header parameter enum test (string) | [default to -efg] - **enumQueryStringArray** | [**[]string**](string.md)| Query parameter enum test (string array) | - **enumQueryString** | **string**| Query parameter enum test (string) | [default to -efg] - **enumQueryInteger** | **int32**| Query parameter enum test (double) | - **enumQueryDouble** | **float64**| Query parameter enum test (double) | + **enumHeaderStringArray** | [**optional.Interface of []string**](string.md)| Header parameter enum test (string array) | + **enumHeaderString** | **optional.String**| Header parameter enum test (string) | [default to -efg] + **enumQueryStringArray** | [**optional.Interface of []string**](string.md)| Query parameter enum test (string array) | + **enumQueryString** | **optional.String**| Query parameter enum test (string) | [default to -efg] + **enumQueryInteger** | **optional.Int32**| Query parameter enum test (double) | + **enumQueryDouble** | **optional.Float64**| Query parameter enum test (double) | + **enumFormStringArray** | [**optional.Interface of []string**](array.md)| Form parameter enum test (string array) | + **enumFormString** | **optional.String**| Form parameter enum test (string) | ### Return type @@ -272,23 +300,21 @@ No authorization required ### HTTP request headers - - **Content-Type**: */* - - **Accept**: */* + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **TestInlineAdditionalProperties** -> TestInlineAdditionalProperties(ctx, param) +> TestInlineAdditionalProperties(ctx, requestBody) test inline additionalProperties - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **param** | [**interface{}**](interface{}.md)| request body | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **requestBody** | [**string**](string.md)| request body | ### Return type @@ -309,13 +335,11 @@ No authorization required > TestJsonFormData(ctx, param, param2) test json serialization of form data - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **param** | **string**| field1 | **param2** | **string**| field2 | @@ -329,7 +353,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123Api.md b/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123Api.md index 5690bc3e1e70..db334ab5689b 100644 --- a/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/go/go-petstore/docs/FakeClassnameTags123Api.md @@ -8,15 +8,17 @@ Method | HTTP request | Description # **TestClassname** -> Client TestClassname(ctx, body) +> Client TestClassname(ctx, client) +To test class name in snake case + To test class name in snake case ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Client**](Client.md)| client model | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **client** | [**Client**](Client.md)| client model | ### Return type diff --git a/samples/client/petstore/go/go-petstore/docs/FormatTest.md b/samples/client/petstore/go/go-petstore/docs/FormatTest.md index 10e6c2ee5da7..025da8e72b75 100644 --- a/samples/client/petstore/go/go-petstore/docs/FormatTest.md +++ b/samples/client/petstore/go/go-petstore/docs/FormatTest.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes **Double** | **float64** | | [optional] [default to null] **String_** | **string** | | [optional] [default to null] **Byte_** | **string** | | [default to null] -**Binary** | **string** | | [optional] [default to null] +**Binary** | [****os.File**](*os.File.md) | | [optional] [default to null] **Date** | **string** | | [default to null] **DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null] **Uuid** | **string** | | [optional] [default to null] diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 61271c1a2114..fa20c7e699c4 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -15,17 +15,15 @@ Method | HTTP request | Description # **AddPet** -> AddPet(ctx, body) +> AddPet(ctx, pet) Add a new pet to the store - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -38,7 +36,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -46,23 +44,21 @@ Name | Type | Description | Notes > DeletePet(ctx, petId, optional) Deletes a pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| Pet id to delete | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***DeletePetOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a DeletePetOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| Pet id to delete | - **apiKey** | **string**| | + + **apiKey** | **optional.String**| | ### Return type @@ -75,7 +71,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -89,7 +85,7 @@ Multiple status values can be provided with comma separated strings Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **status** | [**[]string**](string.md)| Status values that need to be considered for filter | ### Return type @@ -117,7 +113,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **tags** | [**[]string**](string.md)| Tags to filter by | ### Return type @@ -145,7 +141,7 @@ Returns a single pet Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet to return | ### Return type @@ -164,17 +160,15 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **UpdatePet** -> UpdatePet(ctx, body) +> UpdatePet(ctx, pet) Update an existing pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -187,7 +181,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -195,24 +189,22 @@ Name | Type | Description | Notes > UpdatePetWithForm(ctx, petId, optional) Updates a pet in the store with form data - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet that needs to be updated | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***UpdatePetWithFormOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a UpdatePetWithFormOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| ID of pet that needs to be updated | - **name** | **string**| Updated name of the pet | - **status** | **string**| Updated status of the pet | + + **name** | **optional.String**| Updated name of the pet | + **status** | **optional.String**| Updated status of the pet | ### Return type @@ -225,7 +217,7 @@ Name | Type | Description | Notes ### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -233,24 +225,22 @@ Name | Type | Description | Notes > ModelApiResponse UploadFile(ctx, petId, optional) uploads an image - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **petId** | **int64**| ID of pet to update | - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***UploadFileOpts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a UploadFileOpts struct Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **petId** | **int64**| ID of pet to update | - **additionalMetadata** | **string**| Additional data to pass to server | - **file** | ***os.File**| file to upload | + + **additionalMetadata** | **optional.String**| Additional data to pass to server | + **file** | **optional.Interface of *os.File****optional.*os.File**| file to upload | ### Return type diff --git a/samples/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/client/petstore/go/go-petstore/docs/StoreApi.md index 30fc16cb974a..e424e2d966fc 100644 --- a/samples/client/petstore/go/go-petstore/docs/StoreApi.md +++ b/samples/client/petstore/go/go-petstore/docs/StoreApi.md @@ -20,7 +20,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **string**| ID of the order that needs to be deleted | ### Return type @@ -34,7 +34,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -72,7 +72,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **int64**| ID of pet that needs to be fetched | ### Return type @@ -91,17 +91,15 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **PlaceOrder** -> Order PlaceOrder(ctx, body) +> Order PlaceOrder(ctx, order) Place an order for a pet - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**Order**](Order.md)| order placed for purchasing the pet | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **order** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/go/go-petstore/docs/UserApi.md b/samples/client/petstore/go/go-petstore/docs/UserApi.md index 0634a959ea6a..82210d18310e 100644 --- a/samples/client/petstore/go/go-petstore/docs/UserApi.md +++ b/samples/client/petstore/go/go-petstore/docs/UserApi.md @@ -15,7 +15,7 @@ Method | HTTP request | Description # **CreateUser** -> CreateUser(ctx, body) +> CreateUser(ctx, user) Create user This can only be done by the logged in user. @@ -24,8 +24,8 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**User**](User.md)| Created user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**User**](User.md)| Created user object | ### Return type @@ -38,22 +38,20 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **CreateUsersWithArrayInput** -> CreateUsersWithArrayInput(ctx, body) +> CreateUsersWithArrayInput(ctx, user) Creates list of users with given input array - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**[]User**](User.md)| List of user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**[]User**](array.md)| List of user object | ### Return type @@ -66,22 +64,20 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **CreateUsersWithListInput** -> CreateUsersWithListInput(ctx, body) +> CreateUsersWithListInput(ctx, user) Creates list of users with given input array - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **body** | [**[]User**](User.md)| List of user object | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **user** | [**[]User**](array.md)| List of user object | ### Return type @@ -94,7 +90,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -108,7 +104,7 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| The name that needs to be deleted | ### Return type @@ -122,7 +118,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -130,14 +126,12 @@ No authorization required > User GetUserByName(ctx, username) Get user by user name - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. - **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | ### Return type @@ -158,13 +152,11 @@ No authorization required > string LoginUser(ctx, username, password) Logs user into the system - - ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| The user name for login | **password** | **string**| The password for login in clear text | @@ -187,8 +179,6 @@ No authorization required > LogoutUser(ctx, ) Logs out current logged in user session - - ### Required Parameters This endpoint does not need any parameter. @@ -203,12 +193,12 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **UpdateUser** -> UpdateUser(ctx, username, body) +> UpdateUser(ctx, username, user) Updated user This can only be done by the logged in user. @@ -217,9 +207,9 @@ This can only be done by the logged in user. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc. + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **username** | **string**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | + **user** | [**User**](User.md)| Updated user object | ### Return type @@ -232,7 +222,7 @@ No authorization required ### HTTP request headers - **Content-Type**: Not defined - - **Accept**: application/xml, application/json + - **Accept**: Not defined [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 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 8de1415bb858..1d18cbd41e78 100644 --- a/samples/client/petstore/go/go-petstore/model_200_response.go +++ b/samples/client/petstore/go/go-petstore/model_200_response.go @@ -13,6 +13,5 @@ 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_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go index 47449ea592d1..ccb515fecafb 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_class.go @@ -12,6 +12,5 @@ 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/model_animal.go b/samples/client/petstore/go/go-petstore/model_animal.go index 318e9fddaef8..d84f714919c7 100644 --- a/samples/client/petstore/go/go-petstore/model_animal.go +++ b/samples/client/petstore/go/go-petstore/model_animal.go @@ -12,6 +12,5 @@ package petstore type Animal struct { ClassName string `json:"className"` - Color string `json:"color,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 1852fcd25d37..bc308520b153 100644 --- a/samples/client/petstore/go/go-petstore/model_api_response.go +++ b/samples/client/petstore/go/go-petstore/model_api_response.go @@ -12,8 +12,6 @@ package petstore type ModelApiResponse struct { Code int32 `json:"code,omitempty"` - Type_ string `json:"type,omitempty"` - Message string `json:"message,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_array_test.go b/samples/client/petstore/go/go-petstore/model_array_test.go index 7a99a6e6662a..574b053f7ff2 100644 --- a/samples/client/petstore/go/go-petstore/model_array_test.go +++ b/samples/client/petstore/go/go-petstore/model_array_test.go @@ -12,8 +12,6 @@ package petstore type ArrayTest struct { ArrayOfString []string `json:"array_of_string,omitempty"` - ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty"` - ArrayArrayOfModel [][]ReadOnlyFirst `json:"array_array_of_model,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_capitalization.go b/samples/client/petstore/go/go-petstore/model_capitalization.go index 1c259e09e85b..d0763abfcfd8 100644 --- a/samples/client/petstore/go/go-petstore/model_capitalization.go +++ b/samples/client/petstore/go/go-petstore/model_capitalization.go @@ -12,15 +12,10 @@ package petstore type Capitalization struct { SmallCamel string `json:"smallCamel,omitempty"` - CapitalCamel string `json:"CapitalCamel,omitempty"` - SmallSnake string `json:"small_Snake,omitempty"` - CapitalSnake string `json:"Capital_Snake,omitempty"` - SCAETHFlowPoints string `json:"SCA_ETH_Flow_Points,omitempty"` - // Name of the pet ATT_NAME string `json:"ATT_NAME,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_cat.go b/samples/client/petstore/go/go-petstore/model_cat.go index e50446510548..e9eca0285d17 100644 --- a/samples/client/petstore/go/go-petstore/model_cat.go +++ b/samples/client/petstore/go/go-petstore/model_cat.go @@ -12,8 +12,6 @@ package petstore type Cat struct { ClassName string `json:"className"` - Color string `json:"color,omitempty"` - Declawed bool `json:"declawed,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_category.go b/samples/client/petstore/go/go-petstore/model_category.go index 048a144bdfca..813264818fc5 100644 --- a/samples/client/petstore/go/go-petstore/model_category.go +++ b/samples/client/petstore/go/go-petstore/model_category.go @@ -12,6 +12,5 @@ package petstore type Category struct { Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_dog.go b/samples/client/petstore/go/go-petstore/model_dog.go index eb94fa1278a4..a3a923e4fc54 100644 --- a/samples/client/petstore/go/go-petstore/model_dog.go +++ b/samples/client/petstore/go/go-petstore/model_dog.go @@ -12,8 +12,6 @@ package petstore type Dog struct { ClassName string `json:"className"` - Color string `json:"color,omitempty"` - Breed string `json:"breed,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_enum_arrays.go b/samples/client/petstore/go/go-petstore/model_enum_arrays.go index 0c7c4e8db90f..7442b677e868 100644 --- a/samples/client/petstore/go/go-petstore/model_enum_arrays.go +++ b/samples/client/petstore/go/go-petstore/model_enum_arrays.go @@ -12,6 +12,5 @@ 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/model_enum_class.go b/samples/client/petstore/go/go-petstore/model_enum_class.go index b0180356b4a7..4950a03e747c 100644 --- a/samples/client/petstore/go/go-petstore/model_enum_class.go +++ b/samples/client/petstore/go/go-petstore/model_enum_class.go @@ -15,8 +15,6 @@ 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/model_enum_test.go b/samples/client/petstore/go/go-petstore/model_enum_test.go index d985723c96e8..f6d32a523391 100644 --- a/samples/client/petstore/go/go-petstore/model_enum_test.go +++ b/samples/client/petstore/go/go-petstore/model_enum_test.go @@ -12,10 +12,8 @@ package petstore type EnumTest struct { EnumString string `json:"enum_string,omitempty"` - + EnumStringRequired string `json:"enum_string_required"` EnumInteger int32 `json:"enum_integer,omitempty"` - EnumNumber float64 `json:"enum_number,omitempty"` - OuterEnum *OuterEnum `json:"outerEnum,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_format_test.go b/samples/client/petstore/go/go-petstore/model_format_test.go index 2674ef255cac..bc6b8bd0689c 100644 --- a/samples/client/petstore/go/go-petstore/model_format_test.go +++ b/samples/client/petstore/go/go-petstore/model_format_test.go @@ -11,33 +11,25 @@ package petstore import ( +import ( + "os" "time" ) +) + type FormatTest struct { Integer int32 `json:"integer,omitempty"` - Int32_ int32 `json:"int32,omitempty"` - Int64_ int64 `json:"int64,omitempty"` - Number float32 `json:"number"` - Float float32 `json:"float,omitempty"` - Double float64 `json:"double,omitempty"` - String_ string `json:"string,omitempty"` - Byte_ string `json:"byte"` - - Binary string `json:"binary,omitempty"` - + Binary **os.File `json:"binary,omitempty"` Date string `json:"date"` - DateTime time.Time `json:"dateTime,omitempty"` - Uuid string `json:"uuid,omitempty"` - Password string `json:"password"` } diff --git a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go index c290b54c4a79..350ba612d768 100644 --- a/samples/client/petstore/go/go-petstore/model_has_only_read_only.go +++ b/samples/client/petstore/go/go-petstore/model_has_only_read_only.go @@ -12,6 +12,5 @@ package petstore type HasOnlyReadOnly struct { Bar string `json:"bar,omitempty"` - Foo string `json:"foo,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_map_test.go b/samples/client/petstore/go/go-petstore/model_map_test.go index 0b51a0103bf9..02ef102c0572 100644 --- a/samples/client/petstore/go/go-petstore/model_map_test.go +++ b/samples/client/petstore/go/go-petstore/model_map_test.go @@ -12,6 +12,5 @@ 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/model_mixed_properties_and_additional_properties_class.go b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go index b5d120dfa3d0..0d4254b7f078 100644 --- a/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go +++ b/samples/client/petstore/go/go-petstore/model_mixed_properties_and_additional_properties_class.go @@ -16,8 +16,6 @@ import ( type MixedPropertiesAndAdditionalPropertiesClass struct { Uuid string `json:"uuid,omitempty"` - DateTime time.Time `json:"dateTime,omitempty"` - Map_ map[string]Animal `json:"map,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_name.go b/samples/client/petstore/go/go-petstore/model_name.go index 42baa928740f..c2a5b7d9aa40 100644 --- a/samples/client/petstore/go/go-petstore/model_name.go +++ b/samples/client/petstore/go/go-petstore/model_name.go @@ -13,10 +13,7 @@ package petstore // Model for testing model name same as property name type Name struct { Name int32 `json:"name"` - SnakeCase int32 `json:"snake_case,omitempty"` - Property string `json:"property,omitempty"` - Var123Number int32 `json:"123Number,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_order.go b/samples/client/petstore/go/go-petstore/model_order.go index afa590475c01..a659c4eb6379 100644 --- a/samples/client/petstore/go/go-petstore/model_order.go +++ b/samples/client/petstore/go/go-petstore/model_order.go @@ -16,15 +16,10 @@ import ( type Order struct { Id int64 `json:"id,omitempty"` - PetId int64 `json:"petId,omitempty"` - Quantity int32 `json:"quantity,omitempty"` - ShipDate time.Time `json:"shipDate,omitempty"` - // Order Status Status string `json:"status,omitempty"` - Complete bool `json:"complete,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_outer_composite.go b/samples/client/petstore/go/go-petstore/model_outer_composite.go index 7108ccc25a67..2db01931558a 100644 --- a/samples/client/petstore/go/go-petstore/model_outer_composite.go +++ b/samples/client/petstore/go/go-petstore/model_outer_composite.go @@ -12,8 +12,6 @@ package petstore type OuterComposite struct { MyNumber *OuterNumber `json:"my_number,omitempty"` - MyString *OuterString `json:"my_string,omitempty"` - MyBoolean *OuterBoolean `json:"my_boolean,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_outer_enum.go b/samples/client/petstore/go/go-petstore/model_outer_enum.go index 5ad5712734cc..0e724d17c5c8 100644 --- a/samples/client/petstore/go/go-petstore/model_outer_enum.go +++ b/samples/client/petstore/go/go-petstore/model_outer_enum.go @@ -15,8 +15,6 @@ 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/model_pet.go b/samples/client/petstore/go/go-petstore/model_pet.go index fcf57074ecac..01687924d914 100644 --- a/samples/client/petstore/go/go-petstore/model_pet.go +++ b/samples/client/petstore/go/go-petstore/model_pet.go @@ -12,15 +12,10 @@ package petstore type Pet struct { Id int64 `json:"id,omitempty"` - Category *Category `json:"category,omitempty"` - Name string `json:"name"` - PhotoUrls []string `json:"photoUrls"` - Tags []Tag `json:"tags,omitempty"` - // pet status in the store Status string `json:"status,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_read_only_first.go b/samples/client/petstore/go/go-petstore/model_read_only_first.go index c2d44d32eea3..becf588c1243 100644 --- a/samples/client/petstore/go/go-petstore/model_read_only_first.go +++ b/samples/client/petstore/go/go-petstore/model_read_only_first.go @@ -12,6 +12,5 @@ package petstore type ReadOnlyFirst struct { Bar string `json:"bar,omitempty"` - Baz string `json:"baz,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_tag.go b/samples/client/petstore/go/go-petstore/model_tag.go index 9a584a09b41a..0c51bb7d881f 100644 --- a/samples/client/petstore/go/go-petstore/model_tag.go +++ b/samples/client/petstore/go/go-petstore/model_tag.go @@ -12,6 +12,5 @@ package petstore type Tag struct { Id int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/model_user.go b/samples/client/petstore/go/go-petstore/model_user.go index 99ae1c715678..3bdf7cc44648 100644 --- a/samples/client/petstore/go/go-petstore/model_user.go +++ b/samples/client/petstore/go/go-petstore/model_user.go @@ -12,19 +12,12 @@ package petstore type User struct { Id int64 `json:"id,omitempty"` - Username string `json:"username,omitempty"` - FirstName string `json:"firstName,omitempty"` - LastName string `json:"lastName,omitempty"` - Email string `json:"email,omitempty"` - Password string `json:"password,omitempty"` - Phone string `json:"phone,omitempty"` - // User Status UserStatus int32 `json:"userStatus,omitempty"` }