From 3118f932c86a8667eb73ec1fd6e552dc798e4da5 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sat, 16 Apr 2016 22:58:13 -0700 Subject: [PATCH 01/63] added CallApiAsync method in api_client --- .../src/main/resources/go/api_client.mustache | 57 +++++++++++++++++++ .../client/petstore/go/swagger/api_client.go | 57 +++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 06470ba06d6..def951e7c41 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -2,6 +2,8 @@ package {{packageName}} import ( "strings" + "github.com/go-resty/resty" + "errors" ) type ApiClient struct { @@ -38,4 +40,59 @@ func contains(source []string, containvalue string) bool { } } return false +} + +func CallApiAsync(path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileParams map[string]string) (*resty.Response, error) { + + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } + + return nil, errors.New("Invalid method " + method) +} + +func prepareRequest(postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileParams map[string]string) *resty.Request { + + request := resty.R() + + request.SetBody(postBody) + + // add header parameter, if any + request.SetHeaders(headerParams) + + // add query parameter, if any + request.SetQueryParams(queryParams) + + // add form parameter, if any + request.SetFormData(formParams) + + // add file parameter, if any + request.SetFiles(fileParams) + + return request } \ No newline at end of file diff --git a/samples/client/petstore/go/swagger/api_client.go b/samples/client/petstore/go/swagger/api_client.go index 9806ccdf38d..92114983bdd 100644 --- a/samples/client/petstore/go/swagger/api_client.go +++ b/samples/client/petstore/go/swagger/api_client.go @@ -2,6 +2,8 @@ package swagger import ( "strings" + "github.com/go-resty/resty" + "errors" ) type ApiClient struct { @@ -38,4 +40,59 @@ func contains(source []string, containvalue string) bool { } } return false +} + +func CallApiAsync(path string, method string, + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileParams map[string]string) (*resty.Response, error) { + + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } + + return nil, errors.New("Invalid method " + method) +} + +func prepareRequest(postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileParams map[string]string) *resty.Request { + + request := resty.R() + + request.SetBody(postBody) + + // add header parameter, if any + request.SetHeaders(headerParams) + + // add query parameter, if any + request.SetQueryParams(queryParams) + + // add form parameter, if any + request.SetFormData(formParams) + + // add file parameter, if any + request.SetFiles(fileParams) + + return request } \ No newline at end of file From c0292564eef73498e4faf2df1c087da488183ab1 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sun, 17 Apr 2016 20:37:19 -0700 Subject: [PATCH 02/63] updated api.mustache to use the new api client --- .../src/main/resources/go/api.mustache | 12 +++++------- .../src/main/resources/go/api_client.mustache | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index f08ba380ec0..fec404786d4 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,7 +6,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" {{#imports}} "{{import}}" {{/imports}} ) @@ -39,6 +38,11 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { + var httpMethod = {{httpMethod}} + // create path and map variables + path := c.Configuration.BasePath + "{{basePathWithoutHost}}{{path}}" +{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) +{{/pathParams}} _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) @@ -68,12 +72,6 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/isOAuth}} {{/authMethods}} - // create path and map variables - path := "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index def951e7c41..eec9853db37 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -42,7 +42,7 @@ func contains(source []string, containvalue string) bool { return false } -func CallApiAsync(path string, method string, +func CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, From 8b896a2353eb3b2dced0961bb0decec99cf579e3 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sun, 17 Apr 2016 23:45:23 -0700 Subject: [PATCH 03/63] updated api.mustache to call the api client http request --- .../src/main/resources/go/api.mustache | 49 ++-- .../resources/go/api_BACKUP_59234.mustache | 169 ------------ .../main/resources/go/api_BASE_59234.mustache | 160 ----------- .../resources/go/api_LOCAL_59234.mustache | 158 ----------- .../resources/go/api_REMOTE_59234.mustache | 167 ------------ .../client/petstore/go/go-petstore/README.md | 14 +- .../petstore/go/go-petstore/api_client.go | 2 +- .../petstore/go/go-petstore/docs/PetApi.md | 16 +- .../petstore/go/go-petstore/docs/StoreApi.md | 8 +- .../petstore/go/go-petstore/docs/UserApi.md | 16 +- .../client/petstore/go/go-petstore/pet_api.go | 251 ++++++++++-------- .../petstore/go/go-petstore/store_api.go | 107 +++++--- .../petstore/go/go-petstore/user_api.go | 214 +++++++++------ 13 files changed, 400 insertions(+), 931 deletions(-) delete mode 100644 modules/swagger-codegen/src/main/resources/go/api_BACKUP_59234.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/go/api_BASE_59234.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/go/api_LOCAL_59234.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/go/api_REMOTE_59234.mustache diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index cfd5ae0296f..56f286903ac 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -39,7 +39,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ */ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - var httpMethod = {{httpMethod}} + var httpMethod = "{{httpMethod}}" // create path and map variables path := c.Configuration.BasePath + "{{basePathWithoutHost}}{{path}}" {{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) @@ -54,30 +54,32 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/required}} {{/allParams}} - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) {{#authMethods}}// authentication ({{name}}) required {{#isApiKey}}{{#isKeyInHeader}} // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) + headerParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") {{/isKeyInHeader}}{{#isKeyInQuery}} // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) + {{#hasKeyParamName}} + queryParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") {{/hasKeyParamName}} {{/isKeyInQuery}}{{/isApiKey}} {{#isBasic}} // http basic authentication required if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) + headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() } {{/isBasic}} {{#isOAuth}} // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } {{/isOAuth}} {{/authMethods}} @@ -85,15 +87,14 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} + {{#hasQueryParams}} + {{#queryParams}} + queryParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} + {{/queryParams}} + {{/hasQueryParams}} // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -104,7 +105,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -116,16 +117,15 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } {{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) + headerParams["{{baseName}}"] = {{paramName}} {{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` +{{#hasFormParams}} +{{#formParams}} + headerParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} {{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) {{/hasFormParams}} {{#hasBodyParam}}{{#bodyParams}}// body params _sling = _sling.BodyJSON({{paramName}}) @@ -137,7 +137,8 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) diff --git a/modules/swagger-codegen/src/main/resources/go/api_BACKUP_59234.mustache b/modules/swagger-codegen/src/main/resources/go/api_BACKUP_59234.mustache deleted file mode 100644 index 0cf4d311be4..00000000000 --- a/modules/swagger-codegen/src/main/resources/go/api_BACKUP_59234.mustache +++ /dev/null @@ -1,169 +0,0 @@ -package {{packageName}} - -{{#operations}} -import ( - "strings" - "fmt" - "encoding/json" - "errors" -{{#imports}} "{{import}}" -{{/imports}} -) - -type {{classname}} struct { - Configuration Configuration -} - -func New{{classname}}() *{{classname}}{ - configuration := NewConfiguration() - return &{{classname}} { - Configuration: *configuration, - } -} - -func New{{classname}}WithBasePath(basePath string) *{{classname}}{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &{{classname}} { - Configuration: *configuration, - } -} - -{{#operation}} -/** - * {{summary}} - * {{notes}} -{{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} - */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { -<<<<<<< HEAD - var httpMethod = {{httpMethod}} - // create path and map variables - path := c.Configuration.BasePath + "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} - -======= - {{#allParams}} - {{#required}} - // verify the required parameter '{{paramName}}' is set - if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - } - {{/required}} - {{/allParams}} ->>>>>>> c375f2fed5138125228c6e881df7acf3a8ada17d - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) - - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } - {{/isOAuth}} - {{/authMethods}} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } -{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) -{{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` -{{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) -{{/bodyParams}}{{/hasBodyParam}} -{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } - } - - return {{#returnType}}*successPayload, {{/returnType}}err -} -{{/operation}} -{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_BASE_59234.mustache b/modules/swagger-codegen/src/main/resources/go/api_BASE_59234.mustache deleted file mode 100644 index f08ba380ec0..00000000000 --- a/modules/swagger-codegen/src/main/resources/go/api_BASE_59234.mustache +++ /dev/null @@ -1,160 +0,0 @@ -package {{packageName}} - -{{#operations}} -import ( - "strings" - "fmt" - "encoding/json" - "errors" - "github.com/dghubble/sling" -{{#imports}} "{{import}}" -{{/imports}} -) - -type {{classname}} struct { - Configuration Configuration -} - -func New{{classname}}() *{{classname}}{ - configuration := NewConfiguration() - return &{{classname}} { - Configuration: *configuration, - } -} - -func New{{classname}}WithBasePath(basePath string) *{{classname}}{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &{{classname}} { - Configuration: *configuration, - } -} - -{{#operation}} -/** - * {{summary}} - * {{notes}} -{{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} - */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) - - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } - {{/isOAuth}} - {{/authMethods}} - - // create path and map variables - path := "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } -{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) -{{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` -{{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) -{{/bodyParams}}{{/hasBodyParam}} -{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } - } - - return {{#returnType}}*successPayload, {{/returnType}}err -} -{{/operation}} -{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_LOCAL_59234.mustache b/modules/swagger-codegen/src/main/resources/go/api_LOCAL_59234.mustache deleted file mode 100644 index fec404786d4..00000000000 --- a/modules/swagger-codegen/src/main/resources/go/api_LOCAL_59234.mustache +++ /dev/null @@ -1,158 +0,0 @@ -package {{packageName}} - -{{#operations}} -import ( - "strings" - "fmt" - "encoding/json" - "errors" -{{#imports}} "{{import}}" -{{/imports}} -) - -type {{classname}} struct { - Configuration Configuration -} - -func New{{classname}}() *{{classname}}{ - configuration := NewConfiguration() - return &{{classname}} { - Configuration: *configuration, - } -} - -func New{{classname}}WithBasePath(basePath string) *{{classname}}{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &{{classname}} { - Configuration: *configuration, - } -} - -{{#operation}} -/** - * {{summary}} - * {{notes}} -{{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} - */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - var httpMethod = {{httpMethod}} - // create path and map variables - path := c.Configuration.BasePath + "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} - - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) - - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } - {{/isOAuth}} - {{/authMethods}} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } -{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) -{{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` -{{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) -{{/bodyParams}}{{/hasBodyParam}} -{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } - } - - return {{#returnType}}*successPayload, {{/returnType}}err -} -{{/operation}} -{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_REMOTE_59234.mustache b/modules/swagger-codegen/src/main/resources/go/api_REMOTE_59234.mustache deleted file mode 100644 index 35ed984929d..00000000000 --- a/modules/swagger-codegen/src/main/resources/go/api_REMOTE_59234.mustache +++ /dev/null @@ -1,167 +0,0 @@ -package {{packageName}} - -{{#operations}} -import ( - "strings" - "fmt" - "encoding/json" - "errors" - "github.com/dghubble/sling" -{{#imports}} "{{import}}" -{{/imports}} -) - -type {{classname}} struct { - Configuration Configuration -} - -func New{{classname}}() *{{classname}}{ - configuration := NewConfiguration() - return &{{classname}} { - Configuration: *configuration, - } -} - -func New{{classname}}WithBasePath(basePath string) *{{classname}}{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &{{classname}} { - Configuration: *configuration, - } -} - -{{#operation}} -/** - * {{summary}} - * {{notes}} -{{#allParams}} * @param {{paramName}} {{description}} -{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} - */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - {{#allParams}} - {{#required}} - // verify the required parameter '{{paramName}}' is set - if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - } - {{/required}} - {{/allParams}} - _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) - - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - _sling.Set("{{keyParamName}}", a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}")) - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} type KeyQueryParams struct { - {{keyParamName}} string `url:"{{keyParamName}},omitempty"` - } - _sling = _sling.QueryStruct(&KeyQueryParams{ {{keyParamName}}: a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") }) - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - _sling.Set("Authorization", "Basic " + a.Configuration.GetBasicAuthEncodedString()) - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) - } - {{/isOAuth}} - {{/authMethods}} - - // create path and map variables - path := "{{basePathWithoutHost}}{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} - - _sling = _sling.Path(path) - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) - } - -{{#hasQueryParams}} type QueryParams struct { - {{#queryParams}}{{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` - {{/queryParams}} -} - _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) -{{/hasQueryParams}} - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) - } - - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) - } -{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - _sling = _sling.Set("{{baseName}}", {{paramName}}) -{{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} type FormParams struct { -{{#formParams}} {{vendorExtensions.x-exportParamName}} {{dataType}} `url:"{{baseName}},omitempty"` -{{/formParams}} - } - _sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} }) -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) -{{/bodyParams}}{{/hasBodyParam}} -{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} - - httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } - } - - return {{#returnType}}*successPayload, {{/returnType}}err -} -{{/operation}} -{{/operations}} diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 5890d48282a..f8e134982d8 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 date: 2016-04-17T16:17:52.285+08:00 +- Build date: 2016-04-17T23:42:10.705-07:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation @@ -57,12 +57,6 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## petstore_auth - **Type**: OAuth @@ -72,6 +66,12 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## Author diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 92114983bdd..63d5f06ad0b 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -42,7 +42,7 @@ func contains(source []string, containvalue string) bool { return false } -func CallApiAsync(path string, method string, +func CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 5dad1949b04..9caa3df6865 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -36,7 +36,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json @@ -66,7 +66,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -95,7 +95,7 @@ Name | Type | Description | Notes [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -124,7 +124,7 @@ Name | Type | Description | Notes [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -153,7 +153,7 @@ Name | Type | Description | Notes [api_key](../README.md#api_key) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -182,7 +182,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/json, application/xml - **Accept**: application/xml, application/json @@ -213,7 +213,7 @@ void (empty response body) [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: application/x-www-form-urlencoded - **Accept**: application/xml, application/json @@ -244,7 +244,7 @@ Name | Type | Description | Notes [petstore_auth](../README.md#petstore_auth) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: multipart/form-data - **Accept**: application/json diff --git a/samples/client/petstore/go/go-petstore/docs/StoreApi.md b/samples/client/petstore/go/go-petstore/docs/StoreApi.md index 11939c1edba..1ee858d2e30 100644 --- a/samples/client/petstore/go/go-petstore/docs/StoreApi.md +++ b/samples/client/petstore/go/go-petstore/docs/StoreApi.md @@ -32,7 +32,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -58,7 +58,7 @@ This endpoint does not need any parameter. [api_key](../README.md#api_key) -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json @@ -87,7 +87,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -116,7 +116,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/go/go-petstore/docs/UserApi.md b/samples/client/petstore/go/go-petstore/docs/UserApi.md index 79ee5175bbd..4950105ca86 100644 --- a/samples/client/petstore/go/go-petstore/docs/UserApi.md +++ b/samples/client/petstore/go/go-petstore/docs/UserApi.md @@ -36,7 +36,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -65,7 +65,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -94,7 +94,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -123,7 +123,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -152,7 +152,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -182,7 +182,7 @@ Name | Type | Description | Notes No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -208,7 +208,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json @@ -238,7 +238,7 @@ void (empty response body) No authorization required -### HTTP reuqest headers +### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 461df7449f3..0b82f7d703e 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" "os" ) @@ -36,27 +35,33 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ * @return void */ func (a PetApi) AddPet (body Pet) (error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet" + // verify the required parameter 'body' is set if &body == nil { return errors.New("Missing required parameter 'body' when calling PetApi->AddPet") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -68,7 +73,7 @@ func (a PetApi) AddPet (body Pet) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -79,7 +84,7 @@ func (a PetApi) AddPet (body Pet) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -92,7 +97,8 @@ func (a PetApi) AddPet (body Pet) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -127,28 +133,34 @@ func (a PetApi) AddPet (body Pet) (error) { * @return void */ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { + + var httpMethod = "Delete" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + // verify the required parameter 'petId' is set if &petId == nil { return errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") } - _sling := sling.New().Delete(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -158,7 +170,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -169,10 +181,10 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // header params "api_key" - _sling = _sling.Set("api_key", apiKey) + headerParams["api_key"] = apiKey @@ -182,7 +194,8 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -216,33 +229,36 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { * @return []Pet */ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/findByStatus" + // verify the required parameter 'status' is set if &status == nil { return *new([]Pet), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet/findByStatus" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } - type QueryParams struct { - Status []string `url:"status,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Status: status }) + queryParams["Status"] = status // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -250,7 +266,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -261,7 +277,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -272,7 +288,8 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -306,33 +323,36 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { * @return []Pet */ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/findByTags" + // verify the required parameter 'tags' is set if &tags == nil { return *new([]Pet), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet/findByTags" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } - type QueryParams struct { - Tags []string `url:"tags,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Tags: tags }) + queryParams["Tags"] = tags // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -340,7 +360,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -351,7 +371,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -362,7 +382,8 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -396,27 +417,33 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { * @return Pet */ func (a PetApi) GetPetById (petId int64) (Pet, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + // verify the required parameter 'petId' is set if &petId == nil { return *new(Pet), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (api_key) required // set key with prefix in header - _sling.Set("api_key", a.Configuration.GetApiKeyWithPrefix("api_key")) + headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -426,7 +453,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -437,7 +464,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -448,7 +475,8 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -482,27 +510,33 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { * @return void */ func (a PetApi) UpdatePet (body Pet) (error) { + + var httpMethod = "Put" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet" + // verify the required parameter 'body' is set if &body == nil { return errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") } - _sling := sling.New().Put(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -514,7 +548,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -525,7 +559,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -538,7 +572,8 @@ func (a PetApi) UpdatePet (body Pet) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -574,28 +609,34 @@ func (a PetApi) UpdatePet (body Pet) (error) { * @return void */ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/{petId}" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + // verify the required parameter 'petId' is set if &petId == nil { return errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -606,7 +647,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -617,14 +658,11 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } - type FormParams struct { - Name string `url:"name,omitempty"` - Status string `url:"status,omitempty"` - } - _sling = _sling.BodyForm(&FormParams{ Name: name,Status: status }) + headerParams["Name"] = name + headerParams["Status"] = status @@ -633,7 +671,8 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -669,28 +708,34 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err * @return ApiResponse */ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/pet/{petId}/uploadImage" + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + // verify the required parameter 'petId' is set if &petId == nil { return *new(ApiResponse), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (petstore_auth) required // oauth required if a.Configuration.AccessToken != ""{ - _sling.Set("Authorization", "Bearer " + a.Configuration.AccessToken) + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // create path and map variables - path := "/v2/pet/{petId}/uploadImage" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -701,7 +746,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -711,14 +756,11 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } - type FormParams struct { - AdditionalMetadata string `url:"additionalMetadata,omitempty"` - File *os.File `url:"file,omitempty"` - } - _sling = _sling.BodyForm(&FormParams{ AdditionalMetadata: additionalMetadata,File: file }) + headerParams["AdditionalMetadata"] = additionalMetadata + headerParams["File"] = file var successPayload = new(ApiResponse) @@ -727,7 +769,8 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 2fa59c1efd1..5672babce9b 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" ) type StoreApi struct { @@ -35,22 +34,28 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ * @return void */ func (a StoreApi) DeleteOrder (orderId string) (error) { + + var httpMethod = "Delete" + // create path and map variables + path := c.Configuration.BasePath + "/v2/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + // verify the required parameter 'orderId' is set if &orderId == nil { return errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") } - _sling := sling.New().Delete(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -60,7 +65,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -71,7 +76,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -82,7 +87,8 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -115,22 +121,28 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { * @return map[string]int32 */ func (a StoreApi) GetInventory () (map[string]int32, error) { - _sling := sling.New().Get(a.Configuration.BasePath) + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/store/inventory" + + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) // authentication (api_key) required // set key with prefix in header - _sling.Set("api_key", a.Configuration.GetApiKeyWithPrefix("api_key")) + headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - // create path and map variables - path := "/v2/store/inventory" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -140,7 +152,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -150,7 +162,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -161,7 +173,8 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -195,22 +208,28 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { * @return Order */ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/store/order/{orderId}" + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + // verify the required parameter 'orderId' is set if &orderId == nil { return *new(Order), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -220,7 +239,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -231,7 +250,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -242,7 +261,8 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -276,21 +296,27 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { * @return Order */ func (a StoreApi) PlaceOrder (body Order) (Order, error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/store/order" + // verify the required parameter 'body' is set if &body == nil { return *new(Order), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/store/order" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -300,7 +326,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -311,7 +337,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -324,7 +350,8 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index b6639d9e65f..e406e4f87e6 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "github.com/dghubble/sling" ) type UserApi struct { @@ -35,21 +34,27 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ * @return void */ func (a UserApi) CreateUser (body User) (error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user" + // verify the required parameter 'body' is set if &body == nil { return errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -59,7 +64,7 @@ func (a UserApi) CreateUser (body User) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -70,7 +75,7 @@ func (a UserApi) CreateUser (body User) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -83,7 +88,8 @@ func (a UserApi) CreateUser (body User) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -117,21 +123,27 @@ func (a UserApi) CreateUser (body User) (error) { * @return void */ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/createWithArray" + // verify the required parameter 'body' is set if &body == nil { return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/createWithArray" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -141,7 +153,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -152,7 +164,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -165,7 +177,8 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -199,21 +212,27 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { * @return void */ func (a UserApi) CreateUsersWithListInput (body []User) (error) { + + var httpMethod = "Post" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/createWithList" + // verify the required parameter 'body' is set if &body == nil { return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") } - _sling := sling.New().Post(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/createWithList" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -223,7 +242,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -234,7 +253,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -247,7 +266,8 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -281,22 +301,28 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { * @return void */ func (a UserApi) DeleteUser (username string) (error) { + + var httpMethod = "Delete" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + // verify the required parameter 'username' is set if &username == nil { return errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") } - _sling := sling.New().Delete(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -306,7 +332,7 @@ func (a UserApi) DeleteUser (username string) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -317,7 +343,7 @@ func (a UserApi) DeleteUser (username string) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -328,7 +354,8 @@ func (a UserApi) DeleteUser (username string) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -362,22 +389,28 @@ func (a UserApi) DeleteUser (username string) (error) { * @return User */ func (a UserApi) GetUserByName (username string) (User, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + // verify the required parameter 'username' is set if &username == nil { return *new(User), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -387,7 +420,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -398,7 +431,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -409,7 +442,8 @@ func (a UserApi) GetUserByName (username string) (User, error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -444,6 +478,11 @@ func (a UserApi) GetUserByName (username string) (User, error) { * @return string */ func (a UserApi) LoginUser (username string, password string) (string, error) { + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/login" + // verify the required parameter 'username' is set if &username == nil { return *new(string), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") @@ -452,24 +491,22 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { if &password == nil { return *new(string), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") } - _sling := sling.New().Get(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/login" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } - type QueryParams struct { - Username string `url:"username,omitempty"` -Password string `url:"password,omitempty"` -} - _sling = _sling.QueryStruct(&QueryParams{ Username: username,Password: password }) + queryParams["Username"] = username + queryParams["Password"] = password // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -477,7 +514,7 @@ Password string `url:"password,omitempty"` //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -488,7 +525,7 @@ Password string `url:"password,omitempty"` //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -499,7 +536,8 @@ Password string `url:"password,omitempty"` // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(successPayload, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(successPayload, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -532,17 +570,23 @@ Password string `url:"password,omitempty"` * @return void */ func (a UserApi) LogoutUser () (error) { - _sling := sling.New().Get(a.Configuration.BasePath) + + var httpMethod = "Get" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/logout" + + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/logout" - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -552,7 +596,7 @@ func (a UserApi) LogoutUser () (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -563,7 +607,7 @@ func (a UserApi) LogoutUser () (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } @@ -574,7 +618,8 @@ func (a UserApi) LogoutUser () (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) @@ -609,6 +654,12 @@ func (a UserApi) LogoutUser () (error) { * @return void */ func (a UserApi) UpdateUser (username string, body User) (error) { + + var httpMethod = "Put" + // create path and map variables + path := c.Configuration.BasePath + "/v2/user/{username}" + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + // verify the required parameter 'username' is set if &username == nil { return errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") @@ -617,18 +668,18 @@ func (a UserApi) UpdateUser (username string, body User) (error) { if &body == nil { return errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") } - _sling := sling.New().Put(a.Configuration.BasePath) + + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + fileParams := make(map[string]string) + formBody := make(interface{}) - // create path and map variables - path := "/v2/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - - _sling = _sling.Path(path) // add default headers if any for key := range a.Configuration.DefaultHeader { - _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) + headerParams[key] = a.Configuration.DefaultHeader[key] } @@ -638,7 +689,7 @@ func (a UserApi) UpdateUser (username string, body User) (error) { //set Content-Type header localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { - _sling = _sling.Set("Content-Type", localVarHttpContentType) + headerParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header @@ -649,7 +700,7 @@ func (a UserApi) UpdateUser (username string, body User) (error) { //set Accept header localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { - _sling = _sling.Set("Accept", localVarHttpHeaderAccept) + headerParams["Accept"] = localVarHttpHeaderAccept } // body params @@ -662,7 +713,8 @@ func (a UserApi) UpdateUser (username string, body User) (error) { // response (error) models, which needs to be implemented at some point. var failurePayload map[string]interface{} - httpResponse, err := _sling.Receive(nil, &failurePayload) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) + //httpResponse, err := _sling.Receive(nil, &failurePayload) if err == nil { // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) From 36219a00e9a6c0ea0232901a4624b618a98da604 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Mon, 18 Apr 2016 14:38:11 -0700 Subject: [PATCH 04/63] fix go build errors after upgrading to the new api client --- .../src/main/resources/go/api.mustache | 52 +-- .../src/main/resources/go/api_client.mustache | 16 +- .../petstore/go/go-petstore/api_client.go | 16 +- .../client/petstore/go/go-petstore/pet_api.go | 327 ++++-------------- .../petstore/go/go-petstore/store_api.go | 160 ++------- .../petstore/go/go-petstore/user_api.go | 325 ++++------------- 6 files changed, 204 insertions(+), 692 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 56f286903ac..0edb1a7d5c9 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,6 +6,7 @@ import ( "fmt" "encoding/json" "errors" + "bytes" {{#imports}} "{{import}}" {{/imports}} ) @@ -41,7 +42,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ var httpMethod = "{{httpMethod}}" // create path and map variables - path := c.Configuration.BasePath + "{{basePathWithoutHost}}{{path}}" + path := a.Configuration.BasePath + "{{path}}" {{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) {{/pathParams}} @@ -58,7 +59,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} {{#authMethods}}// authentication ({{name}}) required {{#isApiKey}}{{#isKeyInHeader}} @@ -84,7 +85,6 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/isOAuth}} {{/authMethods}} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -92,7 +92,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#hasQueryParams}} {{#queryParams}} - queryParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} + queryParams["{{vendorExtensions.x-exportParamName}}"] = strings.Join({{paramName}}, ",") {{/queryParams}} {{/hasQueryParams}} @@ -107,7 +107,6 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { {{#produces}} @@ -124,45 +123,26 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/headerParams}}{{/hasHeaderParams}} {{#hasFormParams}} {{#formParams}} - headerParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} + formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} {{/formParams}} {{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}}// body params - _sling = _sling.BodyJSON({{paramName}}) +{{#hasBodyParam}}{{#bodyParams}} + // body params + postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive({{#returnType}}successPayload{{/returnType}}{{^returnType}}nil{{/returnType}}, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return {{#returnType}}*successPayload, {{/returnType}}err } +{{#returnType}} + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) +{{/returnType}} + return {{#returnType}}*successPayload, {{/returnType}}err } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index eec9853db37..5ff56a31cfc 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -42,16 +42,16 @@ func contains(source []string, containvalue string) bool { return false } -func CallApi(path string, method string, +func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, fileParams map[string]string) (*resty.Response, error) { + verb := strings.ToUpper(method) + request := prepareRequest(verb, postBody, headerParams, queryParams, formParams, fileParams) - request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) - - switch strings.ToUpper(method) { + switch verb { case "GET": response, err := request.Get(path) return response, err @@ -72,7 +72,7 @@ func CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func prepareRequest(postBody interface{}, +func prepareRequest(verb string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, @@ -92,7 +92,9 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) // add file parameter, if any - request.SetFiles(fileParams) - + if verb != "GET"{ + request.SetFiles(fileParams) + } + return request } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 63d5f06ad0b..f178cbddcff 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -42,16 +42,16 @@ func contains(source []string, containvalue string) bool { return false } -func CallApi(path string, method string, +func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, fileParams map[string]string) (*resty.Response, error) { + verb := strings.ToUpper(method) + request := prepareRequest(verb, postBody, headerParams, queryParams, formParams, fileParams) - request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) - - switch strings.ToUpper(method) { + switch verb { case "GET": response, err := request.Get(path) return response, err @@ -72,7 +72,7 @@ func CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func prepareRequest(postBody interface{}, +func prepareRequest(verb string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, @@ -92,7 +92,9 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) // add file parameter, if any - request.SetFiles(fileParams) - + if verb != "GET"{ + request.SetFiles(fileParams) + } + return request } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 0b82f7d703e..af0c05e45b7 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,6 +5,7 @@ import ( "fmt" "encoding/json" "errors" + "bytes" "os" ) @@ -38,7 +39,7 @@ func (a PetApi) AddPet (body Pet) (error) { var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet" + path := a.Configuration.BasePath + "/pet" // verify the required parameter 'body' is set if &body == nil { @@ -49,7 +50,7 @@ func (a PetApi) AddPet (body Pet) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -58,7 +59,6 @@ func (a PetApi) AddPet (body Pet) (error) { headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -87,42 +87,19 @@ func (a PetApi) AddPet (body Pet) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 0{ + return err } + return err } /** @@ -136,7 +113,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { var httpMethod = "Delete" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/{petId}" + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set @@ -148,7 +125,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -157,7 +134,6 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -189,37 +165,13 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -232,7 +184,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/findByStatus" + path := a.Configuration.BasePath + "/pet/findByStatus" // verify the required parameter 'status' is set if &status == nil { @@ -243,7 +195,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -252,13 +204,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Status"] = status + queryParams["Status"] = strings.Join(status, ",") // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -283,37 +234,15 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { var successPayload = new([]Pet) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -326,7 +255,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/findByTags" + path := a.Configuration.BasePath + "/pet/findByTags" // verify the required parameter 'tags' is set if &tags == nil { @@ -337,7 +266,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -346,13 +275,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Tags"] = tags + queryParams["Tags"] = strings.Join(tags, ",") // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -377,37 +305,15 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { var successPayload = new([]Pet) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -420,7 +326,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/{petId}" + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set @@ -432,7 +338,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (api_key) required @@ -440,7 +346,6 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -470,37 +375,15 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { var successPayload = new(Pet) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -513,7 +396,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { var httpMethod = "Put" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet" + path := a.Configuration.BasePath + "/pet" // verify the required parameter 'body' is set if &body == nil { @@ -524,7 +407,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -533,7 +416,6 @@ func (a PetApi) UpdatePet (body Pet) (error) { headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -562,42 +444,19 @@ func (a PetApi) UpdatePet (body Pet) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -612,7 +471,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/{petId}" + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set @@ -624,7 +483,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -633,7 +492,6 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -661,42 +519,18 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams["Accept"] = localVarHttpHeaderAccept } - headerParams["Name"] = name - headerParams["Status"] = status + formParams["Name"] = name + formParams["Status"] = status - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -711,7 +545,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/pet/{petId}/uploadImage" + path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set @@ -723,7 +557,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (petstore_auth) required @@ -732,7 +566,6 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken } - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -759,41 +592,19 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams["Accept"] = localVarHttpHeaderAccept } - headerParams["AdditionalMetadata"] = additionalMetadata - headerParams["File"] = file + formParams["AdditionalMetadata"] = additionalMetadata + formParams["File"] = file var successPayload = new(ApiResponse) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 5672babce9b..0166b084f79 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -5,6 +5,7 @@ import ( "fmt" "encoding/json" "errors" + "bytes" ) type StoreApi struct { @@ -37,7 +38,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { var httpMethod = "Delete" // create path and map variables - path := c.Configuration.BasePath + "/v2/store/order/{orderId}" + path := a.Configuration.BasePath + "/store/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) // verify the required parameter 'orderId' is set @@ -49,10 +50,9 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -82,37 +82,13 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -124,14 +100,14 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/store/inventory" + path := a.Configuration.BasePath + "/store/inventory" headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} // authentication (api_key) required @@ -139,7 +115,6 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -168,37 +143,15 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { var successPayload = new(map[string]int32) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -211,7 +164,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/store/order/{orderId}" + path := a.Configuration.BasePath + "/store/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) // verify the required parameter 'orderId' is set @@ -223,10 +176,9 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -256,37 +208,15 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { var successPayload = new(Order) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -299,7 +229,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/store/order" + path := a.Configuration.BasePath + "/store/order" // verify the required parameter 'body' is set if &body == nil { @@ -310,10 +240,9 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -340,41 +269,20 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body var successPayload = new(Order) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index e406e4f87e6..6729a5cd265 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -5,6 +5,7 @@ import ( "fmt" "encoding/json" "errors" + "bytes" ) type UserApi struct { @@ -37,7 +38,7 @@ func (a UserApi) CreateUser (body User) (error) { var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/user" + path := a.Configuration.BasePath + "/user" // verify the required parameter 'body' is set if &body == nil { @@ -48,10 +49,9 @@ func (a UserApi) CreateUser (body User) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -78,42 +78,19 @@ func (a UserApi) CreateUser (body User) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -126,7 +103,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/createWithArray" + path := a.Configuration.BasePath + "/user/createWithArray" // verify the required parameter 'body' is set if &body == nil { @@ -137,10 +114,9 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -167,42 +143,19 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -215,7 +168,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { var httpMethod = "Post" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/createWithList" + path := a.Configuration.BasePath + "/user/createWithList" // verify the required parameter 'body' is set if &body == nil { @@ -226,10 +179,9 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -256,42 +208,19 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -304,7 +233,7 @@ func (a UserApi) DeleteUser (username string) (error) { var httpMethod = "Delete" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/{username}" + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set @@ -316,10 +245,9 @@ func (a UserApi) DeleteUser (username string) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -349,37 +277,13 @@ func (a UserApi) DeleteUser (username string) (error) { - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -392,7 +296,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/{username}" + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set @@ -404,10 +308,9 @@ func (a UserApi) GetUserByName (username string) (User, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -437,37 +340,15 @@ func (a UserApi) GetUserByName (username string) (User, error) { var successPayload = new(User) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -481,7 +362,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/login" + path := a.Configuration.BasePath + "/user/login" // verify the required parameter 'username' is set if &username == nil { @@ -496,17 +377,16 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Username"] = username - queryParams["Password"] = password + queryParams["Username"] = strings.Join(username, ",") + queryParams["Password"] = strings.Join(password, ",") // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -531,37 +411,15 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { var successPayload = new(string) - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(successPayload, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return *successPayload, err } + decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) + err = decoder.Decode(&successPayload) + return *successPayload, err } /** @@ -573,17 +431,16 @@ func (a UserApi) LogoutUser () (error) { var httpMethod = "Get" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/logout" + path := a.Configuration.BasePath + "/user/logout" headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -613,37 +470,13 @@ func (a UserApi) LogoutUser () (error) { - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } /** @@ -657,7 +490,7 @@ func (a UserApi) UpdateUser (username string, body User) (error) { var httpMethod = "Put" // create path and map variables - path := c.Configuration.BasePath + "/v2/user/{username}" + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set @@ -673,10 +506,9 @@ func (a UserApi) UpdateUser (username string, body User) (error) { queryParams := make(map[string]string) formParams := make(map[string]string) fileParams := make(map[string]string) - formBody := make(interface{}) + var postBody interface{} - // add default headers if any for key := range a.Configuration.DefaultHeader { headerParams[key] = a.Configuration.DefaultHeader[key] @@ -703,41 +535,18 @@ func (a UserApi) UpdateUser (username string, body User) (error) { headerParams["Accept"] = localVarHttpHeaderAccept } -// body params - _sling = _sling.BodyJSON(body) + + // body params + postBody = &body - // We use this map (below) so that any arbitrary error JSON can be handled. - // FIXME: This is in the absence of this Go generator honoring the non-2xx - // response (error) models, which needs to be implemented at some point. - var failurePayload map[string]interface{} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, method, postBody, headerParams, queryParams, formParams, fileParams) - //httpResponse, err := _sling.Receive(nil, &failurePayload) - - if err == nil { - // err == nil only means that there wasn't a sub-application-layer error (e.g. no network error) - if failurePayload != nil { - // If the failurePayload is present, there likely was some kind of non-2xx status - // returned (and a JSON payload error present) - var str []byte - str, err = json.Marshal(failurePayload) - if err == nil { // For safety, check for an error marshalling... probably superfluous - // This will return the JSON error body as a string - err = errors.New(string(str)) - } - } else { - // So, there was no network-type error, and nothing in the failure payload, - // but we should still check the status code - if httpResponse == nil { - // This should never happen... - err = errors.New("No HTTP Response received.") - } else if code := httpResponse.StatusCode; 200 > code || code > 299 { - err = errors.New("HTTP Error: " + string(httpResponse.StatusCode)) - } - } + if err != nil && httpResponse.StatusCode() != 200{ + return err } + return err } From af19a70f723a551778e86e6ab5d1697f45698f54 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Mon, 18 Apr 2016 17:09:47 -0700 Subject: [PATCH 05/63] updated api_client.go to ensure there is value before setting the request --- .../src/main/resources/go/api_client.mustache | 25 ++++++++++++------- .../petstore/go/go-petstore/api_client.go | 25 ++++++++++++------- .../client/petstore/go/go-petstore/pet_api.go | 10 +------- .../petstore/go/go-petstore/store_api.go | 4 --- .../petstore/go/go-petstore/user_api.go | 8 ------ 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 5ff56a31cfc..a4f06b30828 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -42,16 +42,17 @@ func contains(source []string, containvalue string) bool { return false } + func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, fileParams map[string]string) (*resty.Response, error) { - verb := strings.ToUpper(method) - request := prepareRequest(verb, postBody, headerParams, queryParams, formParams, fileParams) - switch verb { + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + + switch strings.ToUpper(method) { case "GET": response, err := request.Get(path) return response, err @@ -72,7 +73,7 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func prepareRequest(verb string, postBody interface{}, +func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, @@ -83,16 +84,22 @@ func prepareRequest(verb string, postBody interface{}, request.SetBody(postBody) // add header parameter, if any - request.SetHeaders(headerParams) - + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } + // add query parameter, if any - request.SetQueryParams(queryParams) + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } // add form parameter, if any - request.SetFormData(formParams) + if len(fileParams) > 0 { + request.SetFormData(formParams) + } // add file parameter, if any - if verb != "GET"{ + if len(fileParams) > 0 { request.SetFiles(fileParams) } diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index f178cbddcff..e8bc409811d 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -42,16 +42,17 @@ func contains(source []string, containvalue string) bool { return false } + func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, fileParams map[string]string) (*resty.Response, error) { - verb := strings.ToUpper(method) - request := prepareRequest(verb, postBody, headerParams, queryParams, formParams, fileParams) - switch verb { + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + + switch strings.ToUpper(method) { case "GET": response, err := request.Get(path) return response, err @@ -72,7 +73,7 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func prepareRequest(verb string, postBody interface{}, +func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, @@ -83,16 +84,22 @@ func prepareRequest(verb string, postBody interface{}, request.SetBody(postBody) // add header parameter, if any - request.SetHeaders(headerParams) - + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } + // add query parameter, if any - request.SetQueryParams(queryParams) + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } // add form parameter, if any - request.SetFormData(formParams) + if len(fileParams) > 0 { + request.SetFormData(formParams) + } // add file parameter, if any - if verb != "GET"{ + if len(fileParams) > 0 { request.SetFiles(fileParams) } diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index af0c05e45b7..9b0debc95ac 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -75,7 +75,6 @@ func (a PetApi) AddPet (body Pet) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -95,7 +94,7 @@ func (a PetApi) AddPet (body Pet) (error) { httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - if err != nil && httpResponse.StatusCode() != 0{ + if err != nil && httpResponse.StatusCode() != 200{ return err } @@ -148,7 +147,6 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -219,7 +217,6 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -290,7 +287,6 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -360,7 +356,6 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -432,7 +427,6 @@ func (a PetApi) UpdatePet (body Pet) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -507,7 +501,6 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -581,7 +574,6 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/json", diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 0166b084f79..5f4694cd9db 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -67,7 +67,6 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -129,7 +128,6 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/json", @@ -193,7 +191,6 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -257,7 +254,6 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 6729a5cd265..a53788439f1 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -66,7 +66,6 @@ func (a UserApi) CreateUser (body User) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -131,7 +130,6 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -196,7 +194,6 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -262,7 +259,6 @@ func (a UserApi) DeleteUser (username string) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -325,7 +321,6 @@ func (a UserApi) GetUserByName (username string) (User, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -396,7 +391,6 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -455,7 +449,6 @@ func (a UserApi) LogoutUser () (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", @@ -523,7 +516,6 @@ func (a UserApi) UpdateUser (username string, body User) (error) { if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } - // to determine the Accept header localVarHttpHeaderAccepts := []string { "application/xml", From 2fcda964adc0b5b1ce526dc9e75ae2f70525983a Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Mon, 18 Apr 2016 23:06:18 -0700 Subject: [PATCH 06/63] added ParameterToString method to handle string array issue --- .../swagger-codegen/src/main/resources/go/api.mustache | 2 +- .../src/main/resources/go/api_client.mustache | 9 +++++++++ samples/client/petstore/go/go-petstore/api_client.go | 9 +++++++++ samples/client/petstore/go/go-petstore/pet_api.go | 6 +++--- samples/client/petstore/go/go-petstore/user_api.go | 4 ++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 0edb1a7d5c9..14106c25ddf 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -92,7 +92,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#hasQueryParams}} {{#queryParams}} - queryParams["{{vendorExtensions.x-exportParamName}}"] = strings.Join({{paramName}}, ",") + queryParams["{{vendorExtensions.x-exportParamName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) {{/queryParams}} {{/hasQueryParams}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index a4f06b30828..ad2d148e052 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -4,6 +4,7 @@ import ( "strings" "github.com/go-resty/resty" "errors" + "reflect" ) type ApiClient struct { @@ -73,6 +74,14 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } +func (c *ApiClient) ParameterToString (obj interface{}) string { + if reflect.TypeOf(obj).Len() > 0 { + return strings.Join(obj.([]string), ",") + } else{ + return obj.(string) + } +} + func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index e8bc409811d..3440a83a9fd 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/go-resty/resty" "errors" + "reflect" ) type ApiClient struct { @@ -73,6 +74,14 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } +func (c *ApiClient) ParameterToString (obj interface{}) string { + if reflect.TypeOf(obj).Len() > 0 { + return strings.Join(obj.([]string), ",") + } else{ + return obj.(string) + } +} + func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 9b0debc95ac..63a2c6a3627 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -207,7 +207,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Status"] = strings.Join(status, ",") + queryParams["Status"] = a.Configuration.ApiClient.ParameterToString(status) // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -277,7 +277,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Tags"] = strings.Join(tags, ",") + queryParams["Tags"] = a.Configuration.ApiClient.ParameterToString(tags) // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -585,7 +585,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil } formParams["AdditionalMetadata"] = additionalMetadata - formParams["File"] = file + formParams["File"] = file.Name() var successPayload = new(ApiResponse) diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index a53788439f1..2d5dc5fb8d5 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -380,8 +380,8 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Username"] = strings.Join(username, ",") - queryParams["Password"] = strings.Join(password, ",") + queryParams["Username"] = a.Configuration.ApiClient.ParameterToString(username) + queryParams["Password"] = a.Configuration.ApiClient.ParameterToString(password) // to determine the Content-Type header localVarHttpContentTypes := []string { From b57d27d3fc74abf54dbad1e51b291a5ba0a1d379 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Mon, 18 Apr 2016 23:15:26 -0700 Subject: [PATCH 07/63] added isFile logic to generate file parameters --- modules/swagger-codegen/src/main/resources/go/api.mustache | 5 +++++ samples/client/petstore/go/go-petstore/pet_api.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 14106c25ddf..f1657ab3bd1 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -123,7 +123,12 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/headerParams}}{{/hasHeaderParams}} {{#hasFormParams}} {{#formParams}} + {{#isFile}} + fileParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}}.Name() + {{/isFile}} + {{^isFile}} formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} + {{/isFile}} {{/formParams}} {{/hasFormParams}} {{#hasBodyParam}}{{#bodyParams}} diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 63a2c6a3627..b69816a72ba 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -585,7 +585,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil } formParams["AdditionalMetadata"] = additionalMetadata - formParams["File"] = file.Name() + fileParams["File"] = file.Name() var successPayload = new(ApiResponse) From d0123f40b75e1fea17604652e336af84a9c5c2cf Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Mon, 18 Apr 2016 23:30:30 -0700 Subject: [PATCH 08/63] fixed go reflection type checking issue --- .../swagger-codegen/src/main/resources/go/api_client.mustache | 2 +- samples/client/petstore/go/go-petstore/api_client.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index ad2d148e052..b5656eaabf2 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -75,7 +75,7 @@ func (c *ApiClient) CallApi(path string, method string, } func (c *ApiClient) ParameterToString (obj interface{}) string { - if reflect.TypeOf(obj).Len() > 0 { + if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else{ return obj.(string) diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 3440a83a9fd..e530c1d1777 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -75,7 +75,7 @@ func (c *ApiClient) CallApi(path string, method string, } func (c *ApiClient) ParameterToString (obj interface{}) string { - if reflect.TypeOf(obj).Len() > 0 { + if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else{ return obj.(string) From fe1afc35e6f5516f2d7e64fc40beed7095b3a88d Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Tue, 19 Apr 2016 11:46:57 -0700 Subject: [PATCH 09/63] Removed fileParams as the file content will be posted via postBody, fixed file upload issue --- .../codegen/languages/GoClientCodegen.java | 1 + .../src/main/resources/go/api.mustache | 16 ++--- .../src/main/resources/go/api_client.mustache | 20 ++---- .../petstore/go/go-petstore/api_client.go | 20 ++---- .../client/petstore/go/go-petstore/pet_api.go | 66 +++++++------------ .../petstore/go/go-petstore/store_api.go | 28 +++----- .../petstore/go/go-petstore/user_api.go | 56 +++++----------- 7 files changed, 63 insertions(+), 144 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 93144cf7afc..b23ab32163e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -104,6 +104,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { importMapping = new HashMap(); importMapping.put("time.Time", "time"); importMapping.put("*os.File", "os"); + importMapping.put("ioutil", "io/ioutil"); cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).") diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index f1657ab3bd1..cf548d7950c 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -58,7 +58,6 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} {{#authMethods}}// authentication ({{name}}) required @@ -123,23 +122,24 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/headerParams}}{{/hasHeaderParams}} {{#hasFormParams}} {{#formParams}} - {{#isFile}} - fileParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}}.Name() + {{#isFile}}fileBytes, _ := ioutil.ReadAll(file) + postBody = fileBytes {{/isFile}} {{^isFile}} formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} {{/isFile}} {{/formParams}} -{{/hasFormParams}} -{{#hasBodyParam}}{{#bodyParams}} +{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} +{{#returnType}} httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) +{{/returnType}} +{{^returnType}} _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) +{{/returnType}} - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + if err != nil { return {{#returnType}}*successPayload, {{/returnType}}err } diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index b5656eaabf2..60281c98249 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -48,10 +48,9 @@ func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - fileParams map[string]string) (*resty.Response, error) { + formParams map[string]string) (*resty.Response, error) { - request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + request := prepareRequest(postBody, headerParams, queryParams, formParams) switch strings.ToUpper(method) { case "GET": @@ -77,7 +76,7 @@ func (c *ApiClient) CallApi(path string, method string, func (c *ApiClient) ParameterToString (obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") - } else{ + } else { return obj.(string) } } @@ -85,8 +84,7 @@ func (c *ApiClient) ParameterToString (obj interface{}) string { func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - fileParams map[string]string) *resty.Request { + formParams map[string]string) *resty.Request { request := resty.R() @@ -102,15 +100,5 @@ func prepareRequest(postBody interface{}, request.SetQueryParams(queryParams) } - // add form parameter, if any - if len(fileParams) > 0 { - request.SetFormData(formParams) - } - - // add file parameter, if any - if len(fileParams) > 0 { - request.SetFiles(fileParams) - } - return request } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index e530c1d1777..9c8eb12b2be 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -48,10 +48,9 @@ func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - fileParams map[string]string) (*resty.Response, error) { + formParams map[string]string) (*resty.Response, error) { - request := prepareRequest(postBody, headerParams, queryParams, formParams, fileParams) + request := prepareRequest(postBody, headerParams, queryParams, formParams) switch strings.ToUpper(method) { case "GET": @@ -77,7 +76,7 @@ func (c *ApiClient) CallApi(path string, method string, func (c *ApiClient) ParameterToString (obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") - } else{ + } else { return obj.(string) } } @@ -85,8 +84,7 @@ func (c *ApiClient) ParameterToString (obj interface{}) string { func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - fileParams map[string]string) *resty.Request { + formParams map[string]string) *resty.Request { request := resty.R() @@ -102,15 +100,5 @@ func prepareRequest(postBody interface{}, request.SetQueryParams(queryParams) } - // add form parameter, if any - if len(fileParams) > 0 { - request.SetFormData(formParams) - } - - // add file parameter, if any - if len(fileParams) > 0 { - request.SetFiles(fileParams) - } - return request } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index b69816a72ba..9ea228d6624 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -7,6 +7,7 @@ import ( "errors" "bytes" "os" + "io/ioutil" ) type PetApi struct { @@ -49,7 +50,6 @@ func (a PetApi) AddPet (body Pet) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -91,10 +91,8 @@ func (a PetApi) AddPet (body Pet) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -123,7 +121,6 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -162,10 +159,8 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -192,7 +187,6 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -230,10 +224,8 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { var successPayload = new([]Pet) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -262,7 +254,6 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -300,10 +291,8 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { var successPayload = new([]Pet) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -333,7 +322,6 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (api_key) required @@ -369,10 +357,8 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { var successPayload = new(Pet) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -401,7 +387,6 @@ func (a PetApi) UpdatePet (body Pet) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -443,10 +428,8 @@ func (a PetApi) UpdatePet (body Pet) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -476,7 +459,6 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -512,14 +494,12 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["Name"] = name - formParams["Status"] = status + formParams["Name"] = name + formParams["Status"] = status - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -549,7 +529,6 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (petstore_auth) required @@ -584,14 +563,13 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["AdditionalMetadata"] = additionalMetadata - fileParams["File"] = file.Name() + formParams["AdditionalMetadata"] = additionalMetadata + fileBytes, _ := ioutil.ReadAll(file) + postBody = fileBytes var successPayload = new(ApiResponse) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 5f4694cd9db..cf96d4a80ce 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -49,7 +49,6 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -80,10 +79,8 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -105,7 +102,6 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} // authentication (api_key) required @@ -140,10 +136,8 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { var successPayload = new(map[string]int32) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -173,7 +167,6 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -204,10 +197,8 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { var successPayload = new(Order) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -236,7 +227,6 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -270,10 +260,8 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { postBody = &body var successPayload = new(Order) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 2d5dc5fb8d5..c3f28579f6a 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -48,7 +48,6 @@ func (a UserApi) CreateUser (body User) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -82,10 +81,8 @@ func (a UserApi) CreateUser (body User) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -112,7 +109,6 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -146,10 +142,8 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -176,7 +170,6 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -210,10 +203,8 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -241,7 +232,6 @@ func (a UserApi) DeleteUser (username string) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -272,10 +262,8 @@ func (a UserApi) DeleteUser (username string) (error) { - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -303,7 +291,6 @@ func (a UserApi) GetUserByName (username string) (User, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -334,10 +321,8 @@ func (a UserApi) GetUserByName (username string) (User, error) { var successPayload = new(User) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -371,7 +356,6 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -404,10 +388,8 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { var successPayload = new(string) - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -431,7 +413,6 @@ func (a UserApi) LogoutUser () (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -462,10 +443,8 @@ func (a UserApi) LogoutUser () (error) { - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -498,7 +477,6 @@ func (a UserApi) UpdateUser (username string, body User) (error) { headerParams := make(map[string]string) queryParams := make(map[string]string) formParams := make(map[string]string) - fileParams := make(map[string]string) var postBody interface{} @@ -532,10 +510,8 @@ func (a UserApi) UpdateUser (username string, body User) (error) { postBody = &body - - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileParams) - - if err != nil && httpResponse.StatusCode() != 200{ +_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } From 611b711a7ebc8575090e111ef3b902601d7df8a4 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Tue, 19 Apr 2016 12:52:51 -0700 Subject: [PATCH 10/63] clean up generated code, added delete pet test --- .../client/petstore/go/go-petstore/pet_api.go | 16 +++++++++++---- .../petstore/go/go-petstore/store_api.go | 6 +++++- .../petstore/go/go-petstore/user_api.go | 20 +++++++++++++------ samples/client/petstore/go/pet_api_test.go | 10 ++++++++++ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 9ea228d6624..bb8a28c8526 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -91,7 +91,8 @@ func (a PetApi) AddPet (body Pet) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -159,7 +160,8 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -225,6 +227,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { var successPayload = new([]Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -292,6 +295,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { var successPayload = new([]Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -358,6 +362,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { var successPayload = new(Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -428,7 +433,8 @@ func (a PetApi) UpdatePet (body Pet) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -498,7 +504,8 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err formParams["Status"] = status -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -569,6 +576,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil var successPayload = new(ApiResponse) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index cf96d4a80ce..5d65a70781b 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -79,7 +79,8 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -137,6 +138,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { var successPayload = new(map[string]int32) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -198,6 +200,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { var successPayload = new(Order) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -261,6 +264,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { var successPayload = new(Order) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index c3f28579f6a..9af3197d755 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -81,7 +81,8 @@ func (a UserApi) CreateUser (body User) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -142,7 +143,8 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -203,7 +205,8 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -262,7 +265,8 @@ func (a UserApi) DeleteUser (username string) (error) { -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -322,6 +326,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { var successPayload = new(User) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -389,6 +394,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { var successPayload = new(string) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return *successPayload, err } @@ -443,7 +449,8 @@ func (a UserApi) LogoutUser () (error) { -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } @@ -510,7 +517,8 @@ func (a UserApi) UpdateUser (username string, body User) (error) { postBody = &body -_, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { return err } diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 8ac7dc1a77a..8b86bf880be 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -45,3 +45,13 @@ func TestUpdatePetWithForm(t *testing.T) { t.Log(err) } } + +func TestDeletePet(t *testing.T) { + s := sw.NewPetApi() + err := s.DeletePet(12830, "") + + if err != nil { + t.Errorf("Error while deleting pet by id") + t.Log(err) + } +} From 9cf6eb4d8be50e3eb3fc965831a1654bd76f898d Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Tue, 19 Apr 2016 15:18:13 -0700 Subject: [PATCH 11/63] added ApiResponse to all api calls --- .../src/main/resources/go/api.mustache | 176 ++-- .../src/main/resources/go/api_client.mustache | 23 + .../petstore/go/go-petstore/api_client.go | 23 + .../client/petstore/go/go-petstore/pet_api.go | 803 +++++++++--------- .../petstore/go/go-petstore/store_api.go | 332 ++++---- .../petstore/go/go-petstore/user_api.go | 745 ++++++++-------- samples/client/petstore/go/pet_api_test.go | 41 +- samples/client/petstore/go/test.go | 4 +- 8 files changed, 1105 insertions(+), 1042 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index cf548d7950c..48b504134fc 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,7 +6,6 @@ import ( "fmt" "encoding/json" "errors" - "bytes" {{#imports}} "{{import}}" {{/imports}} ) @@ -38,117 +37,112 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ {{#allParams}} * @param {{paramName}} {{description}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { +func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error, ApiResponse) { - var httpMethod = "{{httpMethod}}" - // create path and map variables - path := a.Configuration.BasePath + "{{path}}" + var httpMethod = "{{httpMethod}}" + // create path and map variables + path := a.Configuration.BasePath + "{{path}}" {{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) {{/pathParams}} - {{#allParams}} - {{#required}} - // verify the required parameter '{{paramName}}' is set - if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - } - {{/required}} - {{/allParams}} + {{#allParams}} + {{#required}} + // verify the required parameter '{{paramName}}' is set + if &{{paramName}} == nil { + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } + {{/required}} + {{/allParams}} - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - headerParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} - queryParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } - {{/isOAuth}} - {{/authMethods}} + {{#authMethods}}// authentication ({{name}}) required + {{#isApiKey}}{{#isKeyInHeader}} + // set key with prefix in header + headerParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") + {{/isKeyInHeader}}{{#isKeyInQuery}} + // set key with prefix in querystring + {{#hasKeyParamName}} + queryParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") + {{/hasKeyParamName}} + {{/isKeyInQuery}}{{/isApiKey}} + {{#isBasic}} + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + } + {{/isBasic}} + {{#isOAuth}} + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + {{/isOAuth}} + {{/authMethods}} - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - {{#hasQueryParams}} - {{#queryParams}} - queryParams["{{vendorExtensions.x-exportParamName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) - {{/queryParams}} - {{/hasQueryParams}} + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + {{#hasQueryParams}} + {{#queryParams}} + queryParams["{{vendorExtensions.x-exportParamName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) + {{/queryParams}} + {{/hasQueryParams}} - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + {{#consumes}} + "{{mediaType}}", + {{/consumes}} + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + {{#produces}} + "{{mediaType}}", + {{/produces}} + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } {{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" headerParams["{{baseName}}"] = {{paramName}} {{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} +{{#hasFormParams}} {{#formParams}} - {{#isFile}}fileBytes, _ := ioutil.ReadAll(file) - postBody = fileBytes - {{/isFile}} - {{^isFile}} - formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} - {{/isFile}} + {{#isFile}} fileBytes, _ := ioutil.ReadAll(file) + postBody = fileBytes + {{/isFile}} + {{^isFile}} formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} + {{/isFile}} {{/formParams}} -{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} - // body params - postBody = &{{paramName}} +{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params + postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} -{{#returnType}} httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) -{{/returnType}} -{{^returnType}} _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) -{{/returnType}} + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return {{#returnType}}*successPayload, {{/returnType}}err + return {{#returnType}}*successPayload, {{/returnType}}err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - {{#returnType}} - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + + err = json.Unmarshal(httpResponse.Body(), &successPayload) {{/returnType}} - return {{#returnType}}*successPayload, {{/returnType}}err + return {{#returnType}}*successPayload, {{/returnType}}err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 60281c98249..f06dc87d20d 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -100,5 +100,28 @@ func prepareRequest(postBody interface{}, request.SetQueryParams(queryParams) } + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + return request +} + +func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ + httpResponse := httpResp.(*resty.Response) + apiResponse := new(ApiResponse) + apiResponse.Code = int32(httpResponse.StatusCode()) + apiResponse.Message = httpResponse.Status() + + return apiResponse +} + +func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ + + apiResponse := new(ApiResponse) + apiResponse.Code = int32(400) + apiResponse.Message = errorMessage + + return apiResponse } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 9c8eb12b2be..245e046556f 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -100,5 +100,28 @@ func prepareRequest(postBody interface{}, request.SetQueryParams(queryParams) } + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + return request +} + +func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ + httpResponse := httpResp.(*resty.Response) + apiResponse := new(ApiResponse) + apiResponse.Code = int32(httpResponse.StatusCode()) + apiResponse.Message = httpResponse.Status() + + return apiResponse +} + +func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ + + apiResponse := new(ApiResponse) + apiResponse.Code = int32(400) + apiResponse.Message = errorMessage + + return apiResponse } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index bb8a28c8526..683c2061591 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "bytes" "os" "io/ioutil" ) @@ -36,69 +35,68 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) AddPet (body Pet) (error) { +func (a PetApi) AddPet (body Pet) (error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->AddPet") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling PetApi->AddPet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Deletes a pet @@ -107,67 +105,67 @@ func (a PetApi) AddPet (body Pet) (error) { * @param apiKey * @return void */ -func (a PetApi) DeletePet (petId int64, apiKey string) (error) { +func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } // header params "api_key" headerParams["api_key"] = apiKey - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return err + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - - return err + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Finds Pets by status @@ -175,67 +173,67 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { +func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/findByStatus" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByStatus" - // verify the required parameter 'status' is set - if &status == nil { - return *new([]Pet), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") - } + // verify the required parameter 'status' is set + if &status == nil { + return *new([]Pet), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["Status"] = a.Configuration.ApiClient.ParameterToString(status) + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["Status"] = a.Configuration.ApiClient.ParameterToString(status) - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new([]Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Finds Pets by tags @@ -243,67 +241,67 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { +func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/findByTags" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByTags" - // verify the required parameter 'tags' is set - if &tags == nil { - return *new([]Pet), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") - } + // verify the required parameter 'tags' is set + if &tags == nil { + return *new([]Pet), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["Tags"] = a.Configuration.ApiClient.ParameterToString(tags) + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["Tags"] = a.Configuration.ApiClient.ParameterToString(tags) - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new([]Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Find pet by ID @@ -311,66 +309,66 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { * @param petId ID of pet to return * @return Pet */ -func (a PetApi) GetPetById (petId int64) (Pet, error) { +func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(Pet), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(Pet), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (api_key) required - - // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - + // authentication (api_key) required + + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") + - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(Pet) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Update an existing pet @@ -378,69 +376,68 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) UpdatePet (body Pet) (error) { +func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { - var httpMethod = "Put" - // create path and map variables - path := a.Configuration.BasePath + "/pet" + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Updates a pet in the store with form data @@ -450,68 +447,68 @@ func (a PetApi) UpdatePet (body Pet) (error) { * @param status Updated status of the pet * @return void */ -func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) { +func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/x-www-form-urlencoded", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - formParams["Name"] = name - formParams["Status"] = status - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'petId' is set + if &petId == nil { + return errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/x-www-form-urlencoded", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + formParams["Name"] = name + formParams["Status"] = status + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * uploads an image @@ -521,68 +518,68 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err * @param file file to upload * @return ApiResponse */ -func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error) { +func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(ApiResponse), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(ApiResponse), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // authentication (petstore_auth) required + + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "multipart/form-data", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - formParams["AdditionalMetadata"] = additionalMetadata - fileBytes, _ := ioutil.ReadAll(file) - postBody = fileBytes + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "multipart/form-data", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + formParams["AdditionalMetadata"] = additionalMetadata + fileBytes, _ := ioutil.ReadAll(file) + postBody = fileBytes + var successPayload = new(ApiResponse) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 5d65a70781b..b16720b5efd 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "bytes" ) type StoreApi struct { @@ -34,119 +33,119 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ * @param orderId ID of the order that needs to be deleted * @return void */ -func (a StoreApi) DeleteOrder (orderId string) (error) { +func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/store/order/{orderId}" + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - // verify the required parameter 'orderId' is set - if &orderId == nil { - return errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") - } + // verify the required parameter 'orderId' is set + if &orderId == nil { + return errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept } - return err + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Returns pet inventories by status * Returns a map of status codes to quantities * @return map[string]int32 */ -func (a StoreApi) GetInventory () (map[string]int32, error) { +func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/store/inventory" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/inventory" - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - // authentication (api_key) required - - // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") - + // authentication (api_key) required + + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") + - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(map[string]int32) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Find purchase order by ID @@ -154,61 +153,61 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { * @param orderId ID of pet that needs to be fetched * @return Order */ -func (a StoreApi) GetOrderById (orderId int64) (Order, error) { +func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/store/order/{orderId}" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) - // verify the required parameter 'orderId' is set - if &orderId == nil { - return *new(Order), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") - } + // verify the required parameter 'orderId' is set + if &orderId == nil { + return *new(Order), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(Order) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Place an order for a pet @@ -216,61 +215,60 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { * @param body order placed for purchasing the pet * @return Order */ -func (a StoreApi) PlaceOrder (body Order) (Order, error) { +func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/store/order" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/store/order" - // verify the required parameter 'body' is set - if &body == nil { - return *new(Order), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") - } + // verify the required parameter 'body' is set + if &body == nil { + return *new(Order), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } - - // body params - postBody = &body + // body params + postBody = &body var successPayload = new(Order) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 9af3197d755..f4aceb58ac8 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -5,7 +5,6 @@ import ( "fmt" "encoding/json" "errors" - "bytes" ) type UserApi struct { @@ -34,61 +33,60 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ * @param body Created user object * @return void */ -func (a UserApi) CreateUser (body User) (error) { +func (a UserApi) CreateUser (body User) (error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user" - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling UserApi->CreateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Creates list of users with given input array @@ -96,61 +94,60 @@ func (a UserApi) CreateUser (body User) (error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { +func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user/createWithArray" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithArray" - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Creates list of users with given input array @@ -158,61 +155,60 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithListInput (body []User) (error) { +func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user/createWithList" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithList" - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Delete user @@ -220,59 +216,59 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { * @param username The name that needs to be deleted * @return void */ -func (a UserApi) DeleteUser (username string) (error) { +func (a UserApi) DeleteUser (username string) (error, ApiResponse) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") - } + // verify the required parameter 'username' is set + if &username == nil { + return errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept } - return err + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Get user by user name @@ -280,61 +276,61 @@ func (a UserApi) DeleteUser (username string) (error) { * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ -func (a UserApi) GetUserByName (username string) (User, error) { +func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return *new(User), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") - } + // verify the required parameter 'username' is set + if &username == nil { + return *new(User), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(User) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Logs user into the system @@ -343,120 +339,120 @@ func (a UserApi) GetUserByName (username string) (User, error) { * @param password The password for login in clear text * @return string */ -func (a UserApi) LoginUser (username string, password string) (string, error) { +func (a UserApi) LoginUser (username string, password string) (string, error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/login" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/login" - // verify the required parameter 'username' is set - if &username == nil { - return *new(string), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") - } - // verify the required parameter 'password' is set - if &password == nil { - return *new(string), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") - } + // verify the required parameter 'username' is set + if &username == nil { + return *new(string), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } + // verify the required parameter 'password' is set + if &password == nil { + return *new(string), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["Username"] = a.Configuration.ApiClient.ParameterToString(username) - queryParams["Password"] = a.Configuration.ApiClient.ParameterToString(password) + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + queryParams["Username"] = a.Configuration.ApiClient.ParameterToString(username) + queryParams["Password"] = a.Configuration.ApiClient.ParameterToString(password) - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } var successPayload = new(string) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + if err != nil { - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } - decoder := json.NewDecoder(bytes.NewReader(httpResponse.Body())) - err = decoder.Decode(&successPayload) + err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err + return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Logs out current logged in user session * * @return void */ -func (a UserApi) LogoutUser () (error) { +func (a UserApi) LogoutUser () (error, ApiResponse) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/logout" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/logout" - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept } - return err + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } /** * Updated user @@ -465,64 +461,63 @@ func (a UserApi) LogoutUser () (error) { * @param body Updated user object * @return void */ -func (a UserApi) UpdateUser (username string, body User) (error) { +func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { - var httpMethod = "Put" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") - } - // verify the required parameter 'body' is set - if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") - } - - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/xml", - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - - - // body params - postBody = &body - - - _, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) - - if err != nil { - return err + // verify the required parameter 'username' is set + if &username == nil { + return errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + } + // verify the required parameter 'body' is set + if &body == nil { + return errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") } + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} - return err + + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } + + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // body params + postBody = &body + + + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + + + if err != nil { + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + } + + return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) } diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 8b86bf880be..9978092725b 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -11,11 +11,12 @@ func TestAddPet(t *testing.T) { newPet := (sw.Pet{Id: 12830, Name: "gopher", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"}) - err := s.AddPet(newPet) + err, apiResponse := s.AddPet(newPet) if err != nil { t.Errorf("Error while adding pet") t.Log(err) + t.Log(apiResponse) } } @@ -23,10 +24,11 @@ func TestGetPetById(t *testing.T) { assert := assert.New(t) s := sw.NewPetApi() - resp, err := s.GetPetById(12830) + resp, err, apiResponse := s.GetPetById(12830) if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) + t.Log(apiResponse) } else { assert.Equal(resp.Id, int64(12830), "Pet id should be equal") assert.Equal(resp.Name, "gopher", "Pet name should be gopher") @@ -36,22 +38,53 @@ func TestGetPetById(t *testing.T) { } } +func TestGetPetByIdWithInvalidID(t *testing.T) { + s := sw.NewPetApi() + resp, err, apiResponse := s.GetPetById(999999999) + if err != nil { + t.Errorf("Error while getting pet by invalid id") + t.Log(err) + t.Log(apiResponse) + } else { + + t.Log(resp) + } +} + func TestUpdatePetWithForm(t *testing.T) { s := sw.NewPetApi() - err := s.UpdatePetWithForm(12830, "golang", "available") + err, apiResponse := s.UpdatePetWithForm(12830, "golang", "available") if err != nil { t.Errorf("Error while updating pet by id") t.Log(err) + t.Log(apiResponse) + } +} + +func TestFindPetsByStatus(t *testing.T) { + s := sw.NewPetApi() + resp, err, apiResponse := s.FindPetsByStatus([]string {"pending"}) + if err != nil { + t.Errorf("Error while getting pet by id") + t.Log(err) + t.Log(apiResponse) + } else { + t.Log(apiResponse) + if len(resp) == 0 { + t.Errorf("Error no pets returned") + } + t.Log(resp) } } func TestDeletePet(t *testing.T) { s := sw.NewPetApi() - err := s.DeletePet(12830, "") + err, apiResponse := s.DeletePet(12830, "") if err != nil { t.Errorf("Error while deleting pet by id") t.Log(err) + t.Log(apiResponse) } } diff --git a/samples/client/petstore/go/test.go b/samples/client/petstore/go/test.go index f73d4e338ca..2dcd385212e 100644 --- a/samples/client/petstore/go/test.go +++ b/samples/client/petstore/go/test.go @@ -22,7 +22,7 @@ func main() { s.UpdatePetWithForm(12830, "golang", "available") // test GET - resp, err := s.GetPetById(12830) - fmt.Println("GetPetById: ", resp, err) + resp, err, apiResponse := s.GetPetById(12830) + fmt.Println("GetPetById: ", resp, err, apiResponse) } From 0e3bb2c23e4bc14e1078223fe055a0972716b453 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Tue, 19 Apr 2016 15:48:34 -0700 Subject: [PATCH 12/63] added more tests functions, clean up generated code --- .../src/main/resources/go/api.mustache | 4 +- .../client/petstore/go/go-petstore/pet_api.go | 10 ++--- samples/client/petstore/go/pet_api_test.go | 37 +++++++++++++++++-- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 48b504134fc..b56ccee2aab 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -121,10 +121,10 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/headerParams}}{{/hasHeaderParams}} {{#hasFormParams}} {{#formParams}} - {{#isFile}} fileBytes, _ := ioutil.ReadAll(file) + {{#isFile}}fileBytes, _ := ioutil.ReadAll(file) postBody = fileBytes {{/isFile}} - {{^isFile}} formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} +{{^isFile}}formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} {{/isFile}} {{/formParams}} {{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 683c2061591..ce7fcf1cf2f 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -497,8 +497,8 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["Name"] = name - formParams["Status"] = status + formParams["Name"] = name + formParams["Status"] = status httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) @@ -567,10 +567,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["AdditionalMetadata"] = additionalMetadata - fileBytes, _ := ioutil.ReadAll(file) + formParams["AdditionalMetadata"] = additionalMetadata + fileBytes, _ := ioutil.ReadAll(file) postBody = fileBytes - + var successPayload = new(ApiResponse) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 9978092725b..2b831f58588 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -4,6 +4,7 @@ import ( sw "./go-petstore" "github.com/stretchr/testify/assert" "testing" + "os" ) func TestAddPet(t *testing.T) { @@ -16,8 +17,10 @@ func TestAddPet(t *testing.T) { if err != nil { t.Errorf("Error while adding pet") t.Log(err) - t.Log(apiResponse) } + if apiResponse.Code != 200 { + t.Log(apiResponse) + } } func TestGetPetById(t *testing.T) { @@ -28,7 +31,6 @@ func TestGetPetById(t *testing.T) { if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) - t.Log(apiResponse) } else { assert.Equal(resp.Id, int64(12830), "Pet id should be equal") assert.Equal(resp.Name, "gopher", "Pet name should be gopher") @@ -36,6 +38,9 @@ func TestGetPetById(t *testing.T) { //t.Log(resp) } + if apiResponse.Code != 200 { + t.Log(apiResponse) + } } func TestGetPetByIdWithInvalidID(t *testing.T) { @@ -49,6 +54,9 @@ func TestGetPetByIdWithInvalidID(t *testing.T) { t.Log(resp) } + if apiResponse.Code != 200 { + t.Log(apiResponse) + } } func TestUpdatePetWithForm(t *testing.T) { @@ -60,6 +68,9 @@ func TestUpdatePetWithForm(t *testing.T) { t.Log(err) t.Log(apiResponse) } + if apiResponse.Code != 200 { + t.Log(apiResponse) + } } func TestFindPetsByStatus(t *testing.T) { @@ -74,7 +85,25 @@ func TestFindPetsByStatus(t *testing.T) { if len(resp) == 0 { t.Errorf("Error no pets returned") } - t.Log(resp) + + if apiResponse.Code != 200 { + t.Log(apiResponse) + } + } +} + +func TestUploadFile(t *testing.T) { + s := sw.NewPetApi() + file, _ := os.Open("../python/testfiles/foo.png") + + _, err, apiResponse := s.UploadFile(12830, "golang", file) + + if err != nil { + t.Errorf("Error while uploading file") + t.Log(err) + } + if apiResponse.Code != 200 { + t.Log(apiResponse) } } @@ -85,6 +114,8 @@ func TestDeletePet(t *testing.T) { if err != nil { t.Errorf("Error while deleting pet by id") t.Log(err) + } + if apiResponse.Code != 200 { t.Log(apiResponse) } } From edfc4f88e184b50a07232414e235b168cedd82f9 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Tue, 19 Apr 2016 21:02:22 -0700 Subject: [PATCH 13/63] formatted api_client code, grouped public function --- .../src/main/resources/go/api_client.mustache | 38 +++++++++---------- .../petstore/go/go-petstore/api_client.go | 38 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index f06dc87d20d..2b8f6f57aed 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -73,7 +73,7 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func (c *ApiClient) ParameterToString (obj interface{}) string { +func (c *ApiClient) ParameterToString(obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else { @@ -81,6 +81,24 @@ func (c *ApiClient) ParameterToString (obj interface{}) string { } } +func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ + httpResponse := httpResp.(*resty.Response) + apiResponse := new(ApiResponse) + apiResponse.Code = int32(httpResponse.StatusCode()) + apiResponse.Message = httpResponse.Status() + + return apiResponse +} + +func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ + + apiResponse := new(ApiResponse) + apiResponse.Code = int32(400) + apiResponse.Message = errorMessage + + return apiResponse +} + func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, @@ -107,21 +125,3 @@ func prepareRequest(postBody interface{}, return request } - -func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ - httpResponse := httpResp.(*resty.Response) - apiResponse := new(ApiResponse) - apiResponse.Code = int32(httpResponse.StatusCode()) - apiResponse.Message = httpResponse.Status() - - return apiResponse -} - -func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ - - apiResponse := new(ApiResponse) - apiResponse.Code = int32(400) - apiResponse.Message = errorMessage - - return apiResponse -} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 245e046556f..d5cec88a330 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -73,7 +73,7 @@ func (c *ApiClient) CallApi(path string, method string, return nil, errors.New("Invalid method " + method) } -func (c *ApiClient) ParameterToString (obj interface{}) string { +func (c *ApiClient) ParameterToString(obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else { @@ -81,6 +81,24 @@ func (c *ApiClient) ParameterToString (obj interface{}) string { } } +func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ + httpResponse := httpResp.(*resty.Response) + apiResponse := new(ApiResponse) + apiResponse.Code = int32(httpResponse.StatusCode()) + apiResponse.Message = httpResponse.Status() + + return apiResponse +} + +func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ + + apiResponse := new(ApiResponse) + apiResponse.Code = int32(400) + apiResponse.Message = errorMessage + + return apiResponse +} + func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, @@ -107,21 +125,3 @@ func prepareRequest(postBody interface{}, return request } - -func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ - httpResponse := httpResp.(*resty.Response) - apiResponse := new(ApiResponse) - apiResponse.Code = int32(httpResponse.StatusCode()) - apiResponse.Message = httpResponse.Status() - - return apiResponse -} - -func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ - - apiResponse := new(ApiResponse) - apiResponse.Code = int32(400) - apiResponse.Message = errorMessage - - return apiResponse -} \ No newline at end of file From fe704eee1f61b8dd5b12640a8adb79d94abcf024 Mon Sep 17 00:00:00 2001 From: kolyjjj Date: Wed, 20 Apr 2016 18:32:14 +0800 Subject: [PATCH 14/63] include underscore when generating nodejs controller and service method --- .../java/io/swagger/codegen/DefaultCodegen.java | 13 ++++++++----- .../codegen/languages/NodeJSServerCodegen.java | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 92041101afc..2b1681f5f79 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2319,18 +2319,21 @@ public class DefaultCodegen { */ @SuppressWarnings("static-method") public String removeNonNameElementToCamelCase(String name) { - String nonNameElementPattern = "[-_:;#]"; - name = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function() { // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. + return removeNonNameElementToCamelCase(name, "[-_:;#]"); + } + + protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) { + String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function() { @Nullable @Override public String apply(String input) { return StringUtils.capitalize(input); } }), ""); - if (name.length() > 0) { - name = name.substring(0, 1).toLowerCase() + name.substring(1); + if (result.length() > 0) { + result = result.substring(0, 1).toLowerCase() + result.substring(1); } - return name; + return result; } /** diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java index bf1cdcbb900..002496005e1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java @@ -314,4 +314,10 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig } return super.postProcessSupportingFileData(objs); } + + @Override + public String removeNonNameElementToCamelCase(String name) { + return removeNonNameElementToCamelCase(name, "[-:;#]"); + } + } From 8b9c8d64d9990f7c430cd1e2a2906f2b5d49134c Mon Sep 17 00:00:00 2001 From: kolyjjj Date: Wed, 20 Apr 2016 22:07:59 +0800 Subject: [PATCH 15/63] add method doc --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 2b1681f5f79..25e95250762 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2322,6 +2322,13 @@ public class DefaultCodegen { return removeNonNameElementToCamelCase(name, "[-_:;#]"); } + /** + * Remove characters that is not good to be included in method name from the input and camelize it + * + * @param name string to be camelize + * @param nonNameElementPattern a regex pattern of the characters that is not good to be included in name + * @return camelized string + */ protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) { String result = StringUtils.join(Lists.transform(Lists.newArrayList(name.split(nonNameElementPattern)), new Function() { @Nullable From 287f3ff20b3c26348cbf027a1d5406128146b346 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 12:27:22 -0700 Subject: [PATCH 16/63] fixed io/ioutil import issue, fixed param casing issue --- .../src/main/resources/go/api.mustache | 13 +++++++++++-- samples/client/petstore/go/go-petstore/pet_api.go | 12 ++++++------ samples/client/petstore/go/go-petstore/user_api.go | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index b56ccee2aab..558e54a0653 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,6 +6,15 @@ import ( "fmt" "encoding/json" "errors" + {{#operation}} + {{#hasFormParams}} + {{#formParams}} + {{#isFile}} + "io/ioutil" + {{/isFile}} + {{/formParams}} + {{/hasFormParams}} + {{/operation}} {{#imports}} "{{import}}" {{/imports}} ) @@ -90,7 +99,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#hasQueryParams}} {{#queryParams}} - queryParams["{{vendorExtensions.x-exportParamName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) + queryParams["{{paramName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) {{/queryParams}} {{/hasQueryParams}} @@ -124,7 +133,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#isFile}}fileBytes, _ := ioutil.ReadAll(file) postBody = fileBytes {{/isFile}} -{{^isFile}}formParams["{{vendorExtensions.x-exportParamName}}"] = {{paramName}} +{{^isFile}}formParams["{{paramName}}"] = {{paramName}} {{/isFile}} {{/formParams}} {{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index ce7fcf1cf2f..65d9416ecd3 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,8 +5,8 @@ import ( "fmt" "encoding/json" "errors" - "os" "io/ioutil" + "os" ) type PetApi struct { @@ -201,7 +201,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Status"] = a.Configuration.ApiClient.ParameterToString(status) + queryParams["status"] = a.Configuration.ApiClient.ParameterToString(status) // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -269,7 +269,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Tags"] = a.Configuration.ApiClient.ParameterToString(tags) + queryParams["tags"] = a.Configuration.ApiClient.ParameterToString(tags) // to determine the Content-Type header localVarHttpContentTypes := []string { @@ -497,8 +497,8 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["Name"] = name - formParams["Status"] = status + formParams["name"] = name + formParams["status"] = status httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) @@ -567,7 +567,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil headerParams["Accept"] = localVarHttpHeaderAccept } - formParams["AdditionalMetadata"] = additionalMetadata + formParams["additionalMetadata"] = additionalMetadata fileBytes, _ := ioutil.ReadAll(file) postBody = fileBytes diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index f4aceb58ac8..877dad2cb0f 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -365,8 +365,8 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["Username"] = a.Configuration.ApiClient.ParameterToString(username) - queryParams["Password"] = a.Configuration.ApiClient.ParameterToString(password) + queryParams["username"] = a.Configuration.ApiClient.ParameterToString(username) + queryParams["password"] = a.Configuration.ApiClient.ParameterToString(password) // to determine the Content-Type header localVarHttpContentTypes := []string { From 10c7c41e82e90a868720d5375b7e20da1f34a6ef Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 12:54:05 -0700 Subject: [PATCH 17/63] added config to allow client to see debug log --- .../swagger-codegen/src/main/resources/go/api_client.mustache | 4 ++++ samples/client/petstore/go/go-petstore/api_client.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 2b8f6f57aed..c6fb8867158 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -50,6 +50,10 @@ func (c *ApiClient) CallApi(path string, method string, queryParams map[string]string, formParams map[string]string) (*resty.Response, error) { + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.Debug) + request := prepareRequest(postBody, headerParams, queryParams, formParams) switch strings.ToUpper(method) { diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index d5cec88a330..97a6c9a8f02 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -50,6 +50,10 @@ func (c *ApiClient) CallApi(path string, method string, queryParams map[string]string, formParams map[string]string) (*resty.Response, error) { + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.Debug) + request := prepareRequest(postBody, headerParams, queryParams, formParams) switch strings.ToUpper(method) { From 7636a772c61ac307c0ff47e8dfc0d4b2cd2f78d8 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 13:49:02 -0700 Subject: [PATCH 18/63] fixed file upload issue --- .../src/main/resources/go/api.mustache | 7 +++-- .../src/main/resources/go/api_client.mustache | 14 +++++++--- .../petstore/go/go-petstore/api_client.go | 14 +++++++--- .../client/petstore/go/go-petstore/pet_api.go | 28 ++++++++++++------- .../petstore/go/go-petstore/store_api.go | 12 +++++--- .../petstore/go/go-petstore/user_api.go | 24 ++++++++++------ 6 files changed, 66 insertions(+), 33 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 558e54a0653..bd727a02910 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -67,6 +67,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte {{#authMethods}}// authentication ({{name}}) required {{#isApiKey}}{{#isKeyInHeader}} @@ -130,8 +131,8 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/headerParams}}{{/hasHeaderParams}} {{#hasFormParams}} {{#formParams}} - {{#isFile}}fileBytes, _ := ioutil.ReadAll(file) - postBody = fileBytes + {{#isFile}}fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs {{/isFile}} {{^isFile}}formParams["{{paramName}}"] = {{paramName}} {{/isFile}} @@ -140,7 +141,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index c6fb8867158..04f082a466c 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -5,6 +5,7 @@ import ( "github.com/go-resty/resty" "errors" "reflect" + "bytes" ) type ApiClient struct { @@ -48,13 +49,14 @@ func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string) (*resty.Response, error) { + formParams map[string]string, + file []byte) (*resty.Response, error) { //set debug flag configuration := NewConfiguration() resty.SetDebug(configuration.Debug) - - request := prepareRequest(postBody, headerParams, queryParams, formParams) + + request := prepareRequest(postBody, headerParams, queryParams, formParams,file) switch strings.ToUpper(method) { case "GET": @@ -106,7 +108,8 @@ func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string) *resty.Request { + formParams map[string]string, + file []byte) *resty.Request { request := resty.R() @@ -127,5 +130,8 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) } + if len(file) > 0 { + request.SetFileReader("file", "test-img.png", bytes.NewReader(file)) + } return request } diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 97a6c9a8f02..3bec2e26bf8 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -5,6 +5,7 @@ import ( "github.com/go-resty/resty" "errors" "reflect" + "bytes" ) type ApiClient struct { @@ -48,13 +49,14 @@ func (c *ApiClient) CallApi(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string) (*resty.Response, error) { + formParams map[string]string, + file []byte) (*resty.Response, error) { //set debug flag configuration := NewConfiguration() resty.SetDebug(configuration.Debug) - - request := prepareRequest(postBody, headerParams, queryParams, formParams) + + request := prepareRequest(postBody, headerParams, queryParams, formParams,file) switch strings.ToUpper(method) { case "GET": @@ -106,7 +108,8 @@ func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string) *resty.Request { + formParams map[string]string, + file []byte) *resty.Request { request := resty.R() @@ -127,5 +130,8 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) } + if len(file) > 0 { + request.SetFileReader("file", "test-img.png", bytes.NewReader(file)) + } return request } diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 65d9416ecd3..f089d87c677 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -50,6 +50,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -89,7 +90,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -121,6 +122,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -158,7 +160,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -188,6 +190,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -224,7 +227,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -256,6 +259,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -292,7 +296,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -325,6 +329,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (api_key) required @@ -359,7 +364,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { var successPayload = new(Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -391,6 +396,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -430,7 +436,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -463,6 +469,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -501,7 +508,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err formParams["status"] = status - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -534,6 +541,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (petstore_auth) required @@ -568,11 +576,11 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil } formParams["additionalMetadata"] = additionalMetadata - fileBytes, _ := ioutil.ReadAll(file) - postBody = fileBytes + fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs var successPayload = new(ApiResponse) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index b16720b5efd..59f9d2bd083 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -49,6 +49,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -78,7 +79,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -103,6 +104,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // authentication (api_key) required @@ -136,7 +138,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { var successPayload = new(map[string]int32) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -169,6 +171,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -198,7 +201,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -230,6 +233,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -261,7 +265,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { postBody = &body var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 877dad2cb0f..3a845817216 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -48,6 +48,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -79,7 +80,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -109,6 +110,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -140,7 +142,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -170,6 +172,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -201,7 +204,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -232,6 +235,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -261,7 +265,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -292,6 +296,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -321,7 +326,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { var successPayload = new(User) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -358,6 +363,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -389,7 +395,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap var successPayload = new(string) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -416,6 +422,7 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -445,7 +452,7 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { @@ -481,6 +488,7 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileBytes []byte // add default headers if any @@ -512,7 +520,7 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) if err != nil { From a2002d9148fcb2d226e6176a96a471146aca975b Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 21:30:05 -0700 Subject: [PATCH 19/63] added fileName parameter for upload method --- .../src/main/resources/go/api.mustache | 8 +-- .../src/main/resources/go/api_client.mustache | 16 +++--- .../petstore/go/go-petstore/api_client.go | 16 +++--- .../client/petstore/go/go-petstore/pet_api.go | 49 +++++++++++-------- .../petstore/go/go-petstore/store_api.go | 24 +++++---- .../petstore/go/go-petstore/user_api.go | 46 ++++++++++------- 6 files changed, 95 insertions(+), 64 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index bd727a02910..5b6b9d30ab6 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -49,9 +49,9 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error, ApiResponse) { var httpMethod = "{{httpMethod}}" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) +{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) {{/pathParams}} {{#allParams}} @@ -67,6 +67,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte {{#authMethods}}// authentication ({{name}}) required @@ -133,6 +134,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#formParams}} {{#isFile}}fbs, _ := ioutil.ReadAll(file) fileBytes = fbs + fileName = file.Name() {{/isFile}} {{^isFile}}formParams["{{paramName}}"] = {{paramName}} {{/isFile}} @@ -141,7 +143,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 04f082a466c..ce6de7017e0 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -6,6 +6,7 @@ import ( "errors" "reflect" "bytes" + "path/filepath" ) type ApiClient struct { @@ -50,13 +51,14 @@ func (c *ApiClient) CallApi(path string, method string, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, - file []byte) (*resty.Response, error) { + fileName string, + fileBytes []byte) (*resty.Response, error) { //set debug flag configuration := NewConfiguration() resty.SetDebug(configuration.Debug) - request := prepareRequest(postBody, headerParams, queryParams, formParams,file) + request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) switch strings.ToUpper(method) { case "GET": @@ -108,8 +110,9 @@ func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - file []byte) *resty.Request { + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { request := resty.R() @@ -130,8 +133,9 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) } - if len(file) > 0 { - request.SetFileReader("file", "test-img.png", bytes.NewReader(file)) + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) } return request } diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 3bec2e26bf8..77ec4ef3994 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -6,6 +6,7 @@ import ( "errors" "reflect" "bytes" + "path/filepath" ) type ApiClient struct { @@ -50,13 +51,14 @@ func (c *ApiClient) CallApi(path string, method string, headerParams map[string]string, queryParams map[string]string, formParams map[string]string, - file []byte) (*resty.Response, error) { + fileName string, + fileBytes []byte) (*resty.Response, error) { //set debug flag configuration := NewConfiguration() resty.SetDebug(configuration.Debug) - request := prepareRequest(postBody, headerParams, queryParams, formParams,file) + request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) switch strings.ToUpper(method) { case "GET": @@ -108,8 +110,9 @@ func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, - formParams map[string]string, - file []byte) *resty.Request { + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { request := resty.R() @@ -130,8 +133,9 @@ func prepareRequest(postBody interface{}, request.SetFormData(formParams) } - if len(file) > 0 { - request.SetFileReader("file", "test-img.png", bytes.NewReader(file)) + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) } return request } diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index f089d87c677..22df273324c 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -38,7 +38,7 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet" // verify the required parameter 'body' is set @@ -50,6 +50,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -90,7 +91,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -109,9 +110,9 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { var httpMethod = "Delete" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set if &petId == nil { @@ -122,6 +123,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -160,7 +162,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -178,7 +180,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/findByStatus" // verify the required parameter 'status' is set @@ -190,6 +192,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -227,7 +230,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -247,7 +250,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/findByTags" // verify the required parameter 'tags' is set @@ -259,6 +262,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -296,7 +300,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -316,9 +320,9 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set if &petId == nil { @@ -329,6 +333,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (api_key) required @@ -364,7 +369,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { var successPayload = new(Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -384,7 +389,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { var httpMethod = "Put" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet" // verify the required parameter 'body' is set @@ -396,6 +401,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -436,7 +442,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -456,9 +462,9 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set if &petId == nil { @@ -469,6 +475,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -508,7 +515,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err formParams["status"] = status - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -528,9 +535,9 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) // verify the required parameter 'petId' is set if &petId == nil { @@ -541,6 +548,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (petstore_auth) required @@ -578,9 +586,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil formParams["additionalMetadata"] = additionalMetadata fbs, _ := ioutil.ReadAll(file) fileBytes = fbs + fileName = file.Name() var successPayload = new(ApiResponse) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 59f9d2bd083..c1904d3dc6b 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -36,9 +36,9 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { var httpMethod = "Delete" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) // verify the required parameter 'orderId' is set if &orderId == nil { @@ -49,6 +49,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -79,7 +80,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -96,7 +97,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/store/inventory" @@ -104,6 +105,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte // authentication (api_key) required @@ -138,7 +140,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { var successPayload = new(map[string]int32) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -158,9 +160,9 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) // verify the required parameter 'orderId' is set if &orderId == nil { @@ -171,6 +173,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -201,7 +204,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -221,7 +224,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/store/order" // verify the required parameter 'body' is set @@ -233,6 +236,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -265,7 +269,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { postBody = &body var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 3a845817216..4e3cf387bc0 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -36,7 +36,7 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ func (a UserApi) CreateUser (body User) (error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user" // verify the required parameter 'body' is set @@ -48,6 +48,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -80,7 +81,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -98,7 +99,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/createWithArray" // verify the required parameter 'body' is set @@ -110,6 +111,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -142,7 +144,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -160,7 +162,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { var httpMethod = "Post" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/createWithList" // verify the required parameter 'body' is set @@ -172,6 +174,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -204,7 +207,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -222,9 +225,9 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { func (a UserApi) DeleteUser (username string) (error, ApiResponse) { var httpMethod = "Delete" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set if &username == nil { @@ -235,6 +238,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -265,7 +269,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -283,9 +287,9 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set if &username == nil { @@ -296,6 +300,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -326,7 +331,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { var successPayload = new(User) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -347,7 +352,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { func (a UserApi) LoginUser (username string, password string) (string, error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/login" // verify the required parameter 'username' is set @@ -363,6 +368,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -395,7 +401,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap var successPayload = new(string) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -414,7 +420,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap func (a UserApi) LogoutUser () (error, ApiResponse) { var httpMethod = "Get" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/logout" @@ -422,6 +428,7 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -452,7 +459,7 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { @@ -471,9 +478,9 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { var httpMethod = "Put" - // create path and map variables + // create path and map variables path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) // verify the required parameter 'username' is set if &username == nil { @@ -488,6 +495,7 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { queryParams := make(map[string]string) formParams := make(map[string]string) var postBody interface{} + var fileName string var fileBytes []byte @@ -520,7 +528,7 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileBytes) + httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { From e555b3ad34cc8e285c1c4713604e8255dd0eec2b Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 22:36:32 -0700 Subject: [PATCH 20/63] added debug setter and getter in Go configuration --- .../src/main/resources/go/api_client.mustache | 2 +- .../src/main/resources/go/configuration.mustache | 12 ++++++++++-- samples/client/petstore/go/go-petstore/api_client.go | 4 ++-- .../client/petstore/go/go-petstore/configuration.go | 12 ++++++++++-- samples/client/petstore/go/test.go | 2 ++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index ce6de7017e0..9143f33b504 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string, //set debug flag configuration := NewConfiguration() - resty.SetDebug(configuration.Debug) + resty.SetDebug(configuration.GetDebug()) request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index 154ceb9ffc6..e5f05a63c12 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -9,7 +9,7 @@ type Configuration struct { Password string `json:"password,omitempty"` ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -26,7 +26,7 @@ func NewConfiguration() *Configuration { return &Configuration{ BasePath: "{{basePath}}", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), ApiKey: make(map[string]string), ApiKeyPrefix: make(map[string]string), @@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { } return c.ApiKey[apiKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 77ec4ef3994..33451139a97 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string, //set debug flag configuration := NewConfiguration() - resty.SetDebug(configuration.Debug) + resty.SetDebug(configuration.GetDebug()) request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) @@ -134,7 +134,7 @@ func prepareRequest(postBody interface{}, } if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) + _, fileNm := filepath.Split(fileName) request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) } return request diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index e8a00bccaf5..3fe94d36c26 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -9,7 +9,7 @@ type Configuration struct { Password string `json:"password,omitempty"` ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -26,7 +26,7 @@ func NewConfiguration() *Configuration { return &Configuration{ BasePath: "http://petstore.swagger.io/v2", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), ApiKey: make(map[string]string), ApiKeyPrefix: make(map[string]string), @@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { } return c.ApiKey[apiKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/samples/client/petstore/go/test.go b/samples/client/petstore/go/test.go index 2dcd385212e..6a50c9bbc8e 100644 --- a/samples/client/petstore/go/test.go +++ b/samples/client/petstore/go/test.go @@ -25,4 +25,6 @@ func main() { resp, err, apiResponse := s.GetPetById(12830) fmt.Println("GetPetById: ", resp, err, apiResponse) + err2, apiResponse2 := s.DeletePet(12830, "") + fmt.Println("DeletePet: ", err2, apiResponse2) } From 762d4d6c787f28fa5771c6ecfcdd5dd9a71eee5a Mon Sep 17 00:00:00 2001 From: Christophe Jolif Date: Thu, 21 Apr 2016 13:06:56 +0200 Subject: [PATCH 21/63] Make sure to convert Int32/Int64 to NSNumber. fixes #2669. --- modules/swagger-codegen/src/main/resources/swift/api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache index 195fb88aeed..9801182e082 100644 --- a/modules/swagger-codegen/src/main/resources/swift/api.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache @@ -76,9 +76,9 @@ public class {{classname}}: APIBase { {{#bodyParam}} let parameters = {{paramName}}{{^required}}?{{/required}}.encodeToJSON() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}} let nillableParameters: [String:AnyObject?] = {{^queryParams}}{{^formParams}}[:]{{/formParams}}{{#formParams}}{{^secondaryParam}}[{{/secondaryParam}} - "{{baseName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}} + "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}} ]{{/hasMore}}{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}} - "{{baseName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}} + "{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#hasMore}},{{/hasMore}}{{^hasMore}} ]{{/hasMore}}{{/queryParams}} let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}} From c171356d246061f1785b05d7b115a399d5afba21 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 00:21:04 +0800 Subject: [PATCH 22/63] Revert "[Java] Add auto-generated documentation in Markdown to Java clients" --- bin/java-petstore-all.sh | 1 - bin/java-petstore-feign.sh | 2 +- bin/java-petstore-jersey2.sh | 2 +- bin/java-petstore-okhttp-gson.sh | 2 +- bin/java-petstore-retrofit.sh | 2 +- bin/java-petstore-retrofit2.sh | 2 +- bin/java-petstore-retrofit2rx.sh | 2 +- bin/java-petstore.sh | 2 +- .../XhhGitIgnore/sdk_unit_testing_binary.json | 67 --- .../sdk_unit_testing_file_downloading.json | 30 -- .../codegen/languages/JavaClientCodegen.java | 104 +--- .../languages/JavascriptClientCodegen.java | 20 + .../src/main/resources/Java/README.mustache | 119 +---- .../src/main/resources/Java/api_doc.mustache | 82 ---- .../resources/Java/enum_outer_doc.mustache | 7 - .../Java/libraries/feign/README.mustache | 43 -- .../okhttp-gson/enum_outer_doc.mustache | 7 - .../libraries/okhttp-gson/model_doc.mustache | 3 - .../Java/libraries/retrofit/README.mustache | 43 -- .../Java/libraries/retrofit2/README.mustache | 43 -- .../main/resources/Java/model_doc.mustache | 3 - .../src/main/resources/Java/pojo_doc.mustache | 15 - .../resources/Javascript/api_doc.mustache | 20 +- .../client/petstore/java/default/README.md | 162 +------ .../petstore/java/default/docs/Animal.md | 10 - .../petstore/java/default/docs/ApiResponse.md | 12 - .../client/petstore/java/default/docs/Cat.md | 11 - .../petstore/java/default/docs/Category.md | 11 - .../client/petstore/java/default/docs/Dog.md | 11 - .../petstore/java/default/docs/FormatTest.md | 21 - .../java/default/docs/InlineResponse200.md | 24 - .../java/default/docs/Model200Response.md | 10 - .../java/default/docs/ModelApiResponse.md | 12 - .../petstore/java/default/docs/ModelReturn.md | 10 - .../client/petstore/java/default/docs/Name.md | 11 - .../petstore/java/default/docs/Order.md | 24 - .../client/petstore/java/default/docs/Pet.md | 24 - .../petstore/java/default/docs/PetApi.md | 448 ------------------ .../java/default/docs/SpecialModelName.md | 10 - .../petstore/java/default/docs/StoreApi.md | 197 -------- .../client/petstore/java/default/docs/Tag.md | 11 - .../client/petstore/java/default/docs/User.md | 17 - .../petstore/java/default/docs/UserApi.md | 370 --------------- .../java/io/swagger/client/api/PetApi.java | 188 ++++++-- .../java/io/swagger/client/api/StoreApi.java | 93 +++- .../java/io/swagger/client/api/UserApi.java | 60 +-- .../client/model/InlineResponse200.java | 198 ++++++++ .../client/model/ModelApiResponse.java | 113 ----- .../java/io/swagger/client/model/Order.java | 12 +- .../java/io/swagger/PetstoreProfiling.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 4 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- samples/client/petstore/java/feign/README.md | 2 +- .../io/swagger/client/FormAwareEncoder.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 63 ++- .../java/io/swagger/client/api/StoreApi.java | 31 +- .../java/io/swagger/client/api/UserApi.java | 14 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 113 ----- .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 2 +- .../java/io/swagger/client/model/Order.java | 14 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 2 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../client/petstore/java/jersey2/README.md | 159 +------ .../petstore/java/jersey2/docs/Animal.md | 10 - .../petstore/java/jersey2/docs/ApiResponse.md | 12 - .../client/petstore/java/jersey2/docs/Cat.md | 11 - .../petstore/java/jersey2/docs/Category.md | 11 - .../client/petstore/java/jersey2/docs/Dog.md | 11 - .../petstore/java/jersey2/docs/FormatTest.md | 21 - .../java/jersey2/docs/InlineResponse200.md | 13 - .../java/jersey2/docs/Model200Response.md | 10 - .../java/jersey2/docs/ModelApiResponse.md | 12 - .../petstore/java/jersey2/docs/ModelReturn.md | 10 - .../client/petstore/java/jersey2/docs/Name.md | 11 - .../petstore/java/jersey2/docs/Order.md | 24 - .../client/petstore/java/jersey2/docs/Pet.md | 24 - .../petstore/java/jersey2/docs/PetApi.md | 448 ------------------ .../java/jersey2/docs/SpecialModelName.md | 10 - .../petstore/java/jersey2/docs/StoreApi.md | 197 -------- .../client/petstore/java/jersey2/docs/Tag.md | 11 - .../client/petstore/java/jersey2/docs/User.md | 17 - .../petstore/java/jersey2/docs/UserApi.md | 370 --------------- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/JSON.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 190 ++++++-- .../java/io/swagger/client/api/StoreApi.java | 95 +++- .../java/io/swagger/client/api/UserApi.java | 62 +-- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/InlineResponse200.java | 198 ++++++++ .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 113 ----- .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 2 +- .../java/io/swagger/client/model/Order.java | 14 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 4 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- .../petstore/java/okhttp-gson/README.md | 162 +------ .../petstore/java/okhttp-gson/docs/Animal.md | 10 - .../java/okhttp-gson/docs/ApiResponse.md | 12 - .../petstore/java/okhttp-gson/docs/Cat.md | 11 - .../java/okhttp-gson/docs/Category.md | 11 - .../petstore/java/okhttp-gson/docs/Dog.md | 11 - .../java/okhttp-gson/docs/FormatTest.md | 21 - .../okhttp-gson/docs/InlineResponse200.md | 24 - .../java/okhttp-gson/docs/Model200Response.md | 10 - .../java/okhttp-gson/docs/ModelApiResponse.md | 12 - .../java/okhttp-gson/docs/ModelReturn.md | 10 - .../petstore/java/okhttp-gson/docs/Name.md | 11 - .../petstore/java/okhttp-gson/docs/Order.md | 24 - .../petstore/java/okhttp-gson/docs/Pet.md | 24 - .../petstore/java/okhttp-gson/docs/PetApi.md | 448 ------------------ .../java/okhttp-gson/docs/SpecialModelName.md | 10 - .../java/okhttp-gson/docs/StoreApi.md | 197 -------- .../petstore/java/okhttp-gson/docs/Tag.md | 11 - .../petstore/java/okhttp-gson/docs/User.md | 17 - .../petstore/java/okhttp-gson/docs/UserApi.md | 370 --------------- .../java/io/swagger/client/ApiClient.java | 5 + .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 423 ++++++++++++++--- .../java/io/swagger/client/api/StoreApi.java | 248 +++++++++- .../java/io/swagger/client/api/UserApi.java | 84 ++-- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../client/model/InlineResponse200.java | 168 +++++++ .../client/model/ModelApiResponse.java | 96 ---- .../java/io/swagger/client/model/Order.java | 5 +- .../java/io/swagger/client/ApiClientTest.java | 2 - .../io/swagger/petstore/test/PetApiTest.java | 6 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- .../client/petstore/java/retrofit/README.md | 2 +- .../java/io/swagger/client/ApiClient.java | 6 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 119 ++++- .../java/io/swagger/client/api/StoreApi.java | 55 ++- .../java/io/swagger/client/api/UserApi.java | 24 +- .../client/model/InlineResponse200.java | 168 +++++++ .../client/model/ModelApiResponse.java | 96 ---- .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 9 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../java/io/swagger/client/ApiClient.java | 8 + .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 62 ++- .../java/io/swagger/client/api/StoreApi.java | 26 +- .../java/io/swagger/client/api/UserApi.java | 12 +- .../client/model/InlineResponse200.java | 168 +++++++ .../client/model/ModelApiResponse.java | 96 ---- .../io/swagger/client/model/ObjectReturn.java | 69 +++ .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 7 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../java/io/swagger/client/ApiClient.java | 8 + .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 62 ++- .../java/io/swagger/client/api/StoreApi.java | 26 +- .../java/io/swagger/client/api/UserApi.java | 12 +- .../client/model/InlineResponse200.java | 168 +++++++ .../client/model/ModelApiResponse.java | 96 ---- .../io/swagger/client/model/ObjectReturn.java | 69 +++ .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 11 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- 191 files changed, 2864 insertions(+), 6111 deletions(-) delete mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json delete mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json delete mode 100644 modules/swagger-codegen/src/main/resources/Java/api_doc.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/model_doc.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache delete mode 100644 samples/client/petstore/java/default/docs/Animal.md delete mode 100644 samples/client/petstore/java/default/docs/ApiResponse.md delete mode 100644 samples/client/petstore/java/default/docs/Cat.md delete mode 100644 samples/client/petstore/java/default/docs/Category.md delete mode 100644 samples/client/petstore/java/default/docs/Dog.md delete mode 100644 samples/client/petstore/java/default/docs/FormatTest.md delete mode 100644 samples/client/petstore/java/default/docs/InlineResponse200.md delete mode 100644 samples/client/petstore/java/default/docs/Model200Response.md delete mode 100644 samples/client/petstore/java/default/docs/ModelApiResponse.md delete mode 100644 samples/client/petstore/java/default/docs/ModelReturn.md delete mode 100644 samples/client/petstore/java/default/docs/Name.md delete mode 100644 samples/client/petstore/java/default/docs/Order.md delete mode 100644 samples/client/petstore/java/default/docs/Pet.md delete mode 100644 samples/client/petstore/java/default/docs/PetApi.md delete mode 100644 samples/client/petstore/java/default/docs/SpecialModelName.md delete mode 100644 samples/client/petstore/java/default/docs/StoreApi.md delete mode 100644 samples/client/petstore/java/default/docs/Tag.md delete mode 100644 samples/client/petstore/java/default/docs/User.md delete mode 100644 samples/client/petstore/java/default/docs/UserApi.md create mode 100644 samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/jersey2/docs/Animal.md delete mode 100644 samples/client/petstore/java/jersey2/docs/ApiResponse.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Cat.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Category.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Dog.md delete mode 100644 samples/client/petstore/java/jersey2/docs/FormatTest.md delete mode 100644 samples/client/petstore/java/jersey2/docs/InlineResponse200.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Model200Response.md delete mode 100644 samples/client/petstore/java/jersey2/docs/ModelApiResponse.md delete mode 100644 samples/client/petstore/java/jersey2/docs/ModelReturn.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Name.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Order.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Pet.md delete mode 100644 samples/client/petstore/java/jersey2/docs/PetApi.md delete mode 100644 samples/client/petstore/java/jersey2/docs/SpecialModelName.md delete mode 100644 samples/client/petstore/java/jersey2/docs/StoreApi.md delete mode 100644 samples/client/petstore/java/jersey2/docs/Tag.md delete mode 100644 samples/client/petstore/java/jersey2/docs/User.md delete mode 100644 samples/client/petstore/java/jersey2/docs/UserApi.md create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Animal.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Cat.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Category.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Dog.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/FormatTest.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Model200Response.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Name.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Order.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Pet.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/PetApi.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/StoreApi.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/Tag.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/User.md delete mode 100644 samples/client/petstore/java/okhttp-gson/docs/UserApi.md create mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java diff --git a/bin/java-petstore-all.sh b/bin/java-petstore-all.sh index 143ebc819c5..635e8523edb 100755 --- a/bin/java-petstore-all.sh +++ b/bin/java-petstore-all.sh @@ -7,4 +7,3 @@ ./bin/java-petstore-okhttp-gson.sh ./bin/java-petstore-retrofit.sh ./bin/java-petstore-retrofit2.sh -./bin/java-petstore-retrofit2rx.sh diff --git a/bin/java-petstore-feign.sh b/bin/java-petstore-feign.sh index 063b85f70a1..6f0a5fdf8ff 100755 --- a/bin/java-petstore-feign.sh +++ b/bin/java-petstore-feign.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-jersey2.sh b/bin/java-petstore-jersey2.sh index a715e7ff545..cb51c1e1a8d 100755 --- a/bin/java-petstore-jersey2.sh +++ b/bin/java-petstore-jersey2.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-okhttp-gson.sh b/bin/java-petstore-okhttp-gson.sh index f656624a6c6..17a48ddee53 100755 --- a/bin/java-petstore-okhttp-gson.sh +++ b/bin/java-petstore-okhttp-gson.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit.sh b/bin/java-petstore-retrofit.sh index db4001e4c9e..d9228fb2eca 100755 --- a/bin/java-petstore-retrofit.sh +++ b/bin/java-petstore-retrofit.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit2.sh b/bin/java-petstore-retrofit2.sh index 3fda4df3166..fbd1f9779e4 100755 --- a/bin/java-petstore-retrofit2.sh +++ b/bin/java-petstore-retrofit2.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit2rx.sh b/bin/java-petstore-retrofit2rx.sh index d714cc33455..b0320644142 100755 --- a/bin/java-petstore-retrofit2rx.sh +++ b/bin/java-petstore-retrofit2rx.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore.sh b/bin/java-petstore.sh index ed80c841df6..17a1b0d6b98 100755 --- a/bin/java-petstore.sh +++ b/bin/java-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json deleted file mode 100644 index 2d87e3bcb7f..00000000000 --- a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "SDK Unit Testing - File Downloading" - }, - "schemes": [ - "http" - ], - "host": "localhost:3000", - "basePath": "/unittesting", - "paths": { - "/request/file_uploading": { - "get": { - "operationId": "file_uploading", - "tags": [ - "Request" - ], - "parameters": [ - {"name": "f1", - "in": "formData", - "type": "string", - "format": "binary", - "required": true - }, - {"name": "f2", - "in": "formData", - "type": "string", - "format": "binary", - "required": false - } - ], - "consumes": [ - "multipart/form-data" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - } - } - } - }, - "/response/file_downloading": { - "get": { - "operationId": "file_downloading", - "tags": [ - "Response" - ], - "produces": [ - "multipart/form-data" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string", - "format": "binary" - } - } - } - } - } - } -} diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json deleted file mode 100644 index 6169272c05d..00000000000 --- a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "SDK Unit Testing - File Downloading" - }, - "schemes": [ - "http" - ], - "host": "localhost:3000", - "basePath": "/unittesting", - "paths": { - "/response/file_downloading": { - "get": { - "operationId": "file_downloading", - "tags": [ - "Response" - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "file" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 9fe2b6fc370..380a1eee2a1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -43,8 +43,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { protected boolean serializeBigDecimalAsString = false; protected boolean useRxJava = false; protected boolean hideGenerationTimestamp = false; - protected String apiDocPath = "docs/"; - protected String modelDocPath = "docs/"; + public JavaClientCodegen() { super(); @@ -61,7 +60,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams", "localVarPostBody", "localVarAccepts", "localVarAccept", "localVarContentTypes", "localVarContentType", "localVarAuthNames", "localReturnType", - "ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil", // language reserved words "abstract", "continue", "for", "new", "switch", "assert", @@ -210,10 +208,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put(FULL_JAVA_UTIL, fullJavaUtil); additionalProperties.put("javaUtilPrefix", javaUtilPrefix); - // make api and model doc path available in mustache template - additionalProperties.put("apiDocPath", apiDocPath); - additionalProperties.put("modelDocPath", modelDocPath); - importMapping.put("List", "java.util.List"); if (fullJavaUtil) { @@ -275,14 +269,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } // library-specific files - if (StringUtils.isEmpty(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); - } else if ("okhttp-gson".equals(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); + if ("okhttp-gson".equals(getLibrary())) { // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java")); @@ -295,9 +282,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java")); supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java")); } else if("jersey2".equals(getLibrary())) { - // generate markdown docs - modelDocTemplateFiles.put("model_doc.mustache", ".md"); - apiDocTemplateFiles.put("api_doc.mustache", ".md"); supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); } @@ -369,26 +353,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/'); } - @Override - public String apiDocFileFolder() { - return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); - } - - @Override - public String modelDocFileFolder() { - return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); - } - - @Override - public String toApiDocFilename(String name) { - return toApiName(name); - } - - @Override - public String toModelDocFilename(String name) { - return toModelName(name); - } - @Override public String toVarName(String name) { // sanitize name @@ -533,70 +497,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return super.toDefaultValue(p); } - @Override - public void setParameterExampleValue(CodegenParameter p) { - String example; - - if (p.defaultValue == null) { - example = p.example; - } else { - example = p.defaultValue; - } - - String type = p.baseType; - if (type == null) { - type = p.dataType; - } - - if ("String".equals(type)) { - if (example == null) { - example = p.paramName + "_example"; - } - example = "\"" + escapeText(example) + "\""; - } else if ("Integer".equals(type) || "Short".equals(type)) { - if (example == null) { - example = "56"; - } - } else if ("Long".equals(type)) { - if (example == null) { - example = "56"; - } - example = example + "L"; - } else if ("Float".equals(type)) { - if (example == null) { - example = "3.4"; - } - example = example + "F"; - } else if ("Double".equals(type)) { - example = "3.4"; - example = example + "D"; - } else if ("Boolean".equals(type)) { - if (example == null) { - example = "true"; - } - } else if ("File".equals(type)) { - if (example == null) { - example = "/path/to/file"; - } - example = "new File(\"" + escapeText(example) + "\")"; - } else if ("Date".equals(type)) { - example = "new Date()"; - } else if (!languageSpecificPrimitives.contains(type)) { - // type is a model class, e.g. User - example = "new " + type + "()"; - } - - if (example == null) { - example = "null"; - } else if (Boolean.TRUE.equals(p.isListContainer)) { - example = "Arrays.asList(" + example + ")"; - } else if (Boolean.TRUE.equals(p.isMapContainer)) { - example = "new HashMap()"; - } - - p.example = example; - } - @Override public String getSwaggerType(Property p) { String swaggerType = super.getSwaggerType(p); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index 846796e3b8f..d2d3808f8eb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -524,6 +524,26 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo type = p.dataType; } + typeMapping.put("array", "Array"); + typeMapping.put("List", "Array"); + typeMapping.put("map", "Object"); + typeMapping.put("object", "Object"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("char", "String"); + typeMapping.put("string", "String"); + typeMapping.put("short", "Integer"); + typeMapping.put("int", "Integer"); + typeMapping.put("integer", "Integer"); + typeMapping.put("long", "Integer"); + typeMapping.put("float", "Number"); + typeMapping.put("double", "Number"); + typeMapping.put("number", "Number"); + typeMapping.put("DateTime", "Date"); + typeMapping.put("Date", "Date"); + typeMapping.put("file", "File"); + // binary not supported in JavaScript client right now, using String as a workaround + typeMapping.put("binary", "String"); + if ("String".equals(type)) { if (example == null) { example = p.paramName + "_example"; diff --git a/modules/swagger-codegen/src/main/resources/Java/README.mustache b/modules/swagger-codegen/src/main/resources/Java/README.mustache index f3b766a67d8..50e2cf3fbe9 100644 --- a/modules/swagger-codegen/src/main/resources/Java/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/README.mustache @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation +## Installation & Usage To install the API client library to your local Maven repository, simply execute: @@ -20,124 +20,18 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -### Maven users - -Add this dependency to your project's POM: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml - {{{groupId}}} - {{{artifactId}}} - {{{artifactVersion}}} + {{groupId}} + {{artifactId}} + {{artifactVersion}} compile + ``` -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}" -``` - -### Others - -At first generate the JAR by executing: - - mvn package - -Then manually install the following JARs: - -* target/{{{artifactId}}}-{{{artifactVersion}}}.jar -* target/lib/*.jar - -## Getting Started - -Please follow the [installation](#installation) instruction and execute the following Java code: - -```java -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} -import {{{invokerPackage}}}.*; -import {{{invokerPackage}}}.auth.*; -import {{{invokerPackage}}}.model.*; -import {{{package}}}.{{{classname}}}; - -import java.io.File; -import java.util.*; - -public class {{{classname}}}Example { - - public static void main(String[] args) { - {{#hasAuthMethods}}ApiClient defaultClient = Configuration.getDefaultApiClient(); - {{#authMethods}}{{#isBasic}} - // Configure HTTP basic authorization: {{{name}}} - HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setUsername("YOUR USERNAME"); - {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} - // Configure API key authorization: {{{name}}} - ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setApiKey("YOUR API KEY"); - // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) - //{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} - // Configure OAuth2 access token for authorization: {{{name}}} - OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - - {{{classname}}} apiInstance = new {{{classname}}}(); - {{#allParams}} - {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} - {{/allParams}} - try { - {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} - System.out.println(result);{{/returnType}} - } catch (ApiException e) { - System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); - e.printStackTrace(); - } - } -} -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} -``` - -## Documentation for API Endpoints - -All URIs are relative to *{{basePath}}* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} -{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} - -## Documentation for Models - -{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md) -{{/model}}{{/models}} - -## Documentation for Authorization - -{{^authMethods}}All endpoints do not require authorization. -{{/authMethods}}Authentication schemes defined for the API: -{{#authMethods}}### {{name}} - -{{#isApiKey}}- **Type**: API key -- **API key parameter name**: {{keyParamName}} -- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} -{{/isApiKey}} -{{#isBasic}}- **Type**: HTTP basic authentication -{{/isBasic}} -{{#isOAuth}}- **Type**: OAuth -- **Flow**: {{flow}} -- **Authorizatoin URL**: {{authorizationUrl}} -- **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - {{scope}}: {{description}} -{{/scopes}} -{{/isOAuth}} - -{{/authMethods}} - ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -146,3 +40,4 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} {{/hasMore}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache deleted file mode 100644 index 93c5bc5b13a..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache +++ /dev/null @@ -1,82 +0,0 @@ -# {{classname}}{{#description}} -{{description}}{{/description}} - -All URIs are relative to *{{basePath}}* - -Method | HTTP request | Description -------------- | ------------- | ------------- -{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} -{{/operation}}{{/operations}} - -{{#operations}} -{{#operation}} - -# **{{operationId}}** -> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) - -{{summary}}{{#notes}} - -{{notes}}{{/notes}} - -### Example -```java -// Import classes:{{#hasAuthMethods}} -//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} -//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} -//import {{{invokerPackage}}}.Configuration; -//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} -//import {{{package}}}.{{{classname}}}; - -{{#hasAuthMethods}} -ApiClient defaultClient = Configuration.getDefaultApiClient(); -{{#authMethods}}{{#isBasic}} -// Configure HTTP basic authorization: {{{name}}} -HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); -{{{name}}}.setUsername("YOUR USERNAME"); -{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} -// Configure API key authorization: {{{name}}} -ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); -{{{name}}}.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} -// Configure OAuth2 access token for authorization: {{{name}}} -OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); -{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} -{{/authMethods}} -{{/hasAuthMethods}} - -{{{classname}}} apiInstance = new {{{classname}}}(); -{{#allParams}} -{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} -{{/allParams}} -try { - {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} - System.out.println(result);{{/returnType}} -} catch (ApiException e) { - System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); - e.printStackTrace(); -} -``` - -### Parameters -{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} -Name | Type | Description | Notes -------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} -{{/allParams}} - -### Return type - -{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} - -### Authorization - -{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} - -### HTTP request headers - - - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} - - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} - -{{/operation}} -{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache deleted file mode 100644 index 14b5d524c4a..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache +++ /dev/null @@ -1,7 +0,0 @@ -# {{classname}} - -## Enum - -{{#allowableValues}} -* `{{.}}` -{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache deleted file mode 100644 index 50e2cf3fbe9..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache +++ /dev/null @@ -1,43 +0,0 @@ -# {{artifactId}} - -## Requirements - -Building the API client library requires [Maven](https://maven.apache.org/) to be installed. - -## Installation & Usage - -To install the API client library to your local Maven repository, simply execute: - -```shell -mvn install -``` - -To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: - -```shell -mvn deploy -``` - -Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. - -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: - -```xml - - {{groupId}} - {{artifactId}} - {{artifactVersion}} - compile - - -``` - -## Recommendation - -It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. - -## Author - -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache deleted file mode 100644 index a7e706eba4e..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache +++ /dev/null @@ -1,7 +0,0 @@ -# {{classname}} - -## Enum - -{{#allowableValues}}{{#enumVars}} -* `{{name}}` (value: `{{value}}`) -{{#enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache deleted file mode 100644 index a3703db3bf9..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{#models}}{{#model}} -{{#isEnum}}{{>libraries/okhttp-gson/enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} -{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache deleted file mode 100644 index 50e2cf3fbe9..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache +++ /dev/null @@ -1,43 +0,0 @@ -# {{artifactId}} - -## Requirements - -Building the API client library requires [Maven](https://maven.apache.org/) to be installed. - -## Installation & Usage - -To install the API client library to your local Maven repository, simply execute: - -```shell -mvn install -``` - -To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: - -```shell -mvn deploy -``` - -Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. - -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: - -```xml - - {{groupId}} - {{artifactId}} - {{artifactVersion}} - compile - - -``` - -## Recommendation - -It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. - -## Author - -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache deleted file mode 100644 index 50e2cf3fbe9..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache +++ /dev/null @@ -1,43 +0,0 @@ -# {{artifactId}} - -## Requirements - -Building the API client library requires [Maven](https://maven.apache.org/) to be installed. - -## Installation & Usage - -To install the API client library to your local Maven repository, simply execute: - -```shell -mvn install -``` - -To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: - -```shell -mvn deploy -``` - -Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. - -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: - -```xml - - {{groupId}} - {{artifactId}} - {{artifactVersion}} - compile - - -``` - -## Recommendation - -It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. - -## Author - -{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} -{{/hasMore}}{{/apis}}{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache deleted file mode 100644 index 658df8d5322..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{#models}}{{#model}} -{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} -{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache deleted file mode 100644 index 0e4c0749866..00000000000 --- a/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache +++ /dev/null @@ -1,15 +0,0 @@ -# {{classname}} - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} -{{/vars}} -{{#vars}}{{#isEnum}} - - -## Enum: {{datatypeWithEnum}} -Name | Value ----- | -----{{#allowableValues}}{{#enumVars}} -{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} -{{/isEnum}}{{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache index f5aad995da5..714350a2170 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache @@ -12,7 +12,7 @@ Method | HTTP request | Description {{#operation}} # **{{operationId}}** -> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}) +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} {{summary}}{{#notes}} @@ -26,25 +26,25 @@ var defaultClient = {{{moduleName}}}.ApiClient.default; {{#authMethods}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.username = 'YOUR USERNAME'; -{{{name}}}.password = 'YOUR PASSWORD';{{/isBasic}}{{#isApiKey}} +{{{name}}}.username = 'YOUR USERNAME' +{{{name}}}.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} // Configure API key authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.apiKey = 'YOUR API KEY'; +{{{name}}}.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//{{{name}}}.apiKeyPrefix = 'Token';{{/isApiKey}}{{#isOAuth}} +//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.accessToken = 'YOUR ACCESS TOKEN';{{/isOAuth}} +{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} -var apiInstance = new {{{moduleName}}}.{{{classname}}}();{{#hasParams}} +var apiInstance = new {{{moduleName}}}.{{{classname}}}(){{#hasParams}} {{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} -var {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +var {{{paramName}}} = {{{example}}}; // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}} {{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} var opts = { {{#allParams}}{{^required}} - '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{{dataType}}} | {{{description}}}{{/required}}{{/allParams}} + '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}}{{/required}}{{/allParams}} };{{/hasOptionalParams}}{{/hasParams}} {{#usePromises}} apiInstance.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}).then(function({{#returnType}}data{{/returnType}}) { @@ -61,7 +61,7 @@ var callback = function(error, data, response) { {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} } }; -apiInstance.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback); +api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback); {{/usePromises}} ``` diff --git a/samples/client/petstore/java/default/README.md b/samples/client/petstore/java/default/README.md index 562d76a8db4..cc9672eab41 100644 --- a/samples/client/petstore/java/default/README.md +++ b/samples/client/petstore/java/default/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation +## Installation & Usage To install the API client library to your local Maven repository, simply execute: @@ -20,9 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -### Maven users - -Add this dependency to your project's POM: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml @@ -31,164 +29,9 @@ Add this dependency to your project's POM: 1.0.0 compile -``` - -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "io.swagger:swagger-java-client:1.0.0" -``` - -### Others - -At first generate the JAR by executing: - - mvn package - -Then manually install the following JARs: - -* target/swagger-java-client-1.0.0.jar -* target/lib/*.jar - -## Getting Started - -Please follow the [installation](#installation) instruction and execute the following Java code: - -```java - -import io.swagger.client.*; -import io.swagger.client.auth.*; -import io.swagger.client.model.*; -import io.swagger.client.api.PetApi; - -import java.io.File; -import java.util.*; - -public class PetApiExample { - - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - - // Configure OAuth2 access token for authorization: petstore_auth - OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); - petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - - - - PetApi apiInstance = new PetApi(); - - Pet body = new Pet(); // Pet | Pet object that needs to be added to the store - - try { - apiInstance.addPet(body); - } catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); - } - } -} ``` -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status -*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - -## Documentation for Models - - - [Animal](docs/Animal.md) - - [Cat](docs/Cat.md) - - [Category](docs/Category.md) - - [Dog](docs/Dog.md) - - [InlineResponse200](docs/InlineResponse200.md) - - [Model200Response](docs/Model200Response.md) - - [ModelReturn](docs/ModelReturn.md) - - [Name](docs/Name.md) - - [Order](docs/Order.md) - - [Pet](docs/Pet.md) - - [SpecialModelName](docs/SpecialModelName.md) - - [Tag](docs/Tag.md) - - [User](docs/User.md) - - -## Documentation for Authorization - -Authentication schemes defined for the API: -### petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - write:pets: modify pets in your account - - read:pets: read your pets - -### test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -### test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - -### test_http_basic - -- **Type**: HTTP basic authentication - -### test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -### test_api_key_header - -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header - - ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -197,3 +40,4 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io + diff --git a/samples/client/petstore/java/default/docs/Animal.md b/samples/client/petstore/java/default/docs/Animal.md deleted file mode 100644 index 3ecb7f991f3..00000000000 --- a/samples/client/petstore/java/default/docs/Animal.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Animal - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | - - - diff --git a/samples/client/petstore/java/default/docs/ApiResponse.md b/samples/client/petstore/java/default/docs/ApiResponse.md deleted file mode 100644 index 1c17767c2b7..00000000000 --- a/samples/client/petstore/java/default/docs/ApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/Cat.md b/samples/client/petstore/java/default/docs/Cat.md deleted file mode 100644 index 373af540c41..00000000000 --- a/samples/client/petstore/java/default/docs/Cat.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Cat - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**declawed** | **Boolean** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/Category.md b/samples/client/petstore/java/default/docs/Category.md deleted file mode 100644 index e2df0803278..00000000000 --- a/samples/client/petstore/java/default/docs/Category.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Category - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/Dog.md b/samples/client/petstore/java/default/docs/Dog.md deleted file mode 100644 index a1d638d3bad..00000000000 --- a/samples/client/petstore/java/default/docs/Dog.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Dog - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**breed** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/FormatTest.md b/samples/client/petstore/java/default/docs/FormatTest.md deleted file mode 100644 index 8e400e7bcd7..00000000000 --- a/samples/client/petstore/java/default/docs/FormatTest.md +++ /dev/null @@ -1,21 +0,0 @@ - -# FormatTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **Integer** | | [optional] -**int32** | **Integer** | | [optional] -**int64** | **Long** | | [optional] -**number** | [**BigDecimal**](BigDecimal.md) | | -**_float** | **Float** | | [optional] -**_double** | **Double** | | [optional] -**string** | **String** | | [optional] -**_byte** | **byte[]** | | [optional] -**binary** | **byte[]** | | [optional] -**date** | [**Date**](Date.md) | | [optional] -**dateTime** | [**Date**](Date.md) | | [optional] -**password** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/InlineResponse200.md b/samples/client/petstore/java/default/docs/InlineResponse200.md deleted file mode 100644 index 487ebe429e4..00000000000 --- a/samples/client/petstore/java/default/docs/InlineResponse200.md +++ /dev/null @@ -1,24 +0,0 @@ - -# InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**photoUrls** | **List<String>** | | [optional] -**name** | **String** | | [optional] -**id** | **Long** | | -**category** | **Object** | | [optional] -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold - - - diff --git a/samples/client/petstore/java/default/docs/Model200Response.md b/samples/client/petstore/java/default/docs/Model200Response.md deleted file mode 100644 index 0819b88c4f4..00000000000 --- a/samples/client/petstore/java/default/docs/Model200Response.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Model200Response - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/ModelApiResponse.md b/samples/client/petstore/java/default/docs/ModelApiResponse.md deleted file mode 100644 index 3eec8686cc9..00000000000 --- a/samples/client/petstore/java/default/docs/ModelApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ModelApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/ModelReturn.md b/samples/client/petstore/java/default/docs/ModelReturn.md deleted file mode 100644 index a679b04953e..00000000000 --- a/samples/client/petstore/java/default/docs/ModelReturn.md +++ /dev/null @@ -1,10 +0,0 @@ - -# ModelReturn - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/Name.md b/samples/client/petstore/java/default/docs/Name.md deleted file mode 100644 index a1adac1dd39..00000000000 --- a/samples/client/petstore/java/default/docs/Name.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Name - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | -**snakeCase** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/Order.md b/samples/client/petstore/java/default/docs/Order.md deleted file mode 100644 index b1709c14eee..00000000000 --- a/samples/client/petstore/java/default/docs/Order.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Order - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**petId** | **Long** | | [optional] -**quantity** | **Integer** | | [optional] -**shipDate** | [**Date**](Date.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] -**complete** | **Boolean** | | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -PLACED | placed -APPROVED | approved -DELIVERED | delivered - - - diff --git a/samples/client/petstore/java/default/docs/Pet.md b/samples/client/petstore/java/default/docs/Pet.md deleted file mode 100644 index 20a1c298dd6..00000000000 --- a/samples/client/petstore/java/default/docs/Pet.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Pet - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**category** | [**Category**](Category.md) | | [optional] -**name** | **String** | | -**photoUrls** | **List<String>** | | -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold - - - diff --git a/samples/client/petstore/java/default/docs/PetApi.md b/samples/client/petstore/java/default/docs/PetApi.md deleted file mode 100644 index e0314e20e51..00000000000 --- a/samples/client/petstore/java/default/docs/PetApi.md +++ /dev/null @@ -1,448 +0,0 @@ -# PetApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image - - - -# **addPet** -> addPet(body) - -Add a new pet to the store - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.addPet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **deletePet** -> deletePet(petId, apiKey) - -Deletes a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | Pet id to delete -String apiKey = "apiKey_example"; // String | -try { - apiInstance.deletePet(petId, apiKey); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#deletePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| Pet id to delete | - **apiKey** | **String**| | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByStatus** -> List<Pet> findPetsByStatus(status) - -Finds Pets by status - -Multiple status values can be provided with comma separated strings - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter -try { - List result = apiInstance.findPetsByStatus(status); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByStatus"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByTags** -> List<Pet> findPetsByTags(tags) - -Finds Pets by tags - -Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List tags = Arrays.asList("tags_example"); // List | Tags to filter by -try { - List result = apiInstance.findPetsByTags(tags); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByTags"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **tags** | [**List<String>**](String.md)| Tags to filter by | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getPetById** -> Pet getPetById(petId) - -Find pet by ID - -Returns a single pet - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to return -try { - Pet result = apiInstance.getPetById(petId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#getPetById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to return | - -### Return type - -[**Pet**](Pet.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updatePet** -> updatePet(body) - -Update an existing pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.updatePet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **updatePetWithForm** -> updatePetWithForm(petId, name, status) - -Updates a pet in the store with form data - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet that needs to be updated -String name = "name_example"; // String | Updated name of the pet -String status = "status_example"; // String | Updated status of the pet -try { - apiInstance.updatePetWithForm(petId, name, status); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePetWithForm"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet that needs to be updated | - **name** | **String**| Updated name of the pet | [optional] - **status** | **String**| Updated status of the pet | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/xml, application/json - - -# **uploadFile** -> ModelApiResponse uploadFile(petId, additionalMetadata, file) - -uploads an image - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to update -String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server -File file = new File("/path/to/file.txt"); // File | file to upload -try { - ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#uploadFile"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to update | - **additionalMetadata** | **String**| Additional data to pass to server | [optional] - **file** | **File**| file to upload | [optional] - -### Return type - -[**ModelApiResponse**](ModelApiResponse.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: multipart/form-data - - **Accept**: application/json - diff --git a/samples/client/petstore/java/default/docs/SpecialModelName.md b/samples/client/petstore/java/default/docs/SpecialModelName.md deleted file mode 100644 index c2c6117c552..00000000000 --- a/samples/client/petstore/java/default/docs/SpecialModelName.md +++ /dev/null @@ -1,10 +0,0 @@ - -# SpecialModelName - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**specialPropertyName** | **Long** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/StoreApi.md b/samples/client/petstore/java/default/docs/StoreApi.md deleted file mode 100644 index 0b30791725a..00000000000 --- a/samples/client/petstore/java/default/docs/StoreApi.md +++ /dev/null @@ -1,197 +0,0 @@ -# StoreApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet - - - -# **deleteOrder** -> deleteOrder(orderId) - -Delete purchase order by ID - -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -String orderId = "orderId_example"; // String | ID of the order that needs to be deleted -try { - apiInstance.deleteOrder(orderId); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#deleteOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **String**| ID of the order that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getInventory** -> Map<String, Integer> getInventory() - -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.StoreApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -StoreApi apiInstance = new StoreApi(); -try { - Map result = apiInstance.getInventory(); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getInventory"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**Map<String, Integer>**](Map.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - - -# **getOrderById** -> Order getOrderById(orderId) - -Find purchase order by ID - -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Long orderId = 789L; // Long | ID of pet that needs to be fetched -try { - Order result = apiInstance.getOrderById(orderId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getOrderById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **Long**| ID of pet that needs to be fetched | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **placeOrder** -> Order placeOrder(body) - -Place an order for a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Order body = new Order(); // Order | order placed for purchasing the pet -try { - Order result = apiInstance.placeOrder(body); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#placeOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/default/docs/Tag.md b/samples/client/petstore/java/default/docs/Tag.md deleted file mode 100644 index de6814b55d5..00000000000 --- a/samples/client/petstore/java/default/docs/Tag.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Tag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/User.md b/samples/client/petstore/java/default/docs/User.md deleted file mode 100644 index 8b6753dd284..00000000000 --- a/samples/client/petstore/java/default/docs/User.md +++ /dev/null @@ -1,17 +0,0 @@ - -# User - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**username** | **String** | | [optional] -**firstName** | **String** | | [optional] -**lastName** | **String** | | [optional] -**email** | **String** | | [optional] -**password** | **String** | | [optional] -**phone** | **String** | | [optional] -**userStatus** | **Integer** | User Status | [optional] - - - diff --git a/samples/client/petstore/java/default/docs/UserApi.md b/samples/client/petstore/java/default/docs/UserApi.md deleted file mode 100644 index 8cdc15992ee..00000000000 --- a/samples/client/petstore/java/default/docs/UserApi.md +++ /dev/null @@ -1,370 +0,0 @@ -# UserApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**createUser**](UserApi.md#createUser) | **POST** /user | Create user -[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - - -# **createUser** -> createUser(body) - -Create user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -User body = new User(); // User | Created user object -try { - apiInstance.createUser(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithArrayInput** -> createUsersWithArrayInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithArrayInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithListInput** -> createUsersWithListInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithListInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithListInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **deleteUser** -> deleteUser(username) - -Delete user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be deleted -try { - apiInstance.deleteUser(username); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#deleteUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getUserByName** -> User getUserByName(username) - -Get user by user name - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. -try { - User result = apiInstance.getUserByName(username); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#getUserByName"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**User**](User.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **loginUser** -> String loginUser(username, password) - -Logs user into the system - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The user name for login -String password = "password_example"; // String | The password for login in clear text -try { - String result = apiInstance.loginUser(username, password); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#loginUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | - **password** | **String**| The password for login in clear text | - -### Return type - -**String** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **logoutUser** -> logoutUser() - -Logs out current logged in user session - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -try { - apiInstance.logoutUser(); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#logoutUser"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updateUser** -> updateUser(username, body) - -Updated user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | name that need to be deleted -User body = new User(); // User | Updated user object -try { - apiInstance.updateUser(username, body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#updateUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index 584c85aaae4..fdc5110304f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -39,17 +39,12 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException if fails to make API call */ public void addPet(Pet body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -62,7 +57,42 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json", "application/xml" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @throws ApiException if fails to make API call + */ + public void addPetUsingByteArray(byte[] body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -106,7 +136,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -123,18 +153,13 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return List * @throws ApiException if fails to make API call */ public List findPetsByStatus(List status) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'status' is set - if (status == null) { - throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); - } - // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -143,12 +168,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -164,19 +189,14 @@ public class PetApi { } /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return List * @throws ApiException if fails to make API call */ public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'tags' is set - if (tags == null) { - throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); - } - // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -185,12 +205,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -206,8 +226,8 @@ public class PetApi { } /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Pet * @throws ApiException if fails to make API call */ @@ -232,7 +252,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -241,25 +261,104 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return InlineResponse200 + * @throws ApiException if fails to make API call + */ + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return byte[] + * @throws ApiException if fails to make API call + */ + public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException if fails to make API call */ public void updatePet(Pet body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -272,7 +371,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -294,7 +393,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException if fails to make API call */ - public void updatePetWithForm(Long petId, String name, String status) throws ApiException { + public void updatePetWithForm(String petId, String name, String status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -319,7 +418,7 @@ if (status != null) localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -339,10 +438,9 @@ if (status != null) * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ModelApiResponse * @throws ApiException if fails to make API call */ - public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -367,7 +465,7 @@ if (file != null) localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -378,7 +476,7 @@ if (file != null) String[] localVarAuthNames = new String[] { "petstore_auth" }; - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 59a1a58266e..3f2e38c0e3a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -61,7 +61,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -75,6 +75,43 @@ public class StoreApi { apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return List + * @throws ApiException if fails to make API call + */ + public List findOrdersByStatus(String status) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + + GenericType> localVarReturnType = new GenericType>() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -96,7 +133,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -110,6 +147,41 @@ public class StoreApi { GenericType> localVarReturnType = new GenericType>() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getInventoryInObject() throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -117,7 +189,7 @@ public class StoreApi { * @return Order * @throws ApiException if fails to make API call */ - public Order getOrderById(Long orderId) throws ApiException { + public Order getOrderById(String orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -138,7 +210,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -147,7 +219,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); @@ -155,18 +227,13 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Order * @throws ApiException if fails to make API call */ public Order placeOrder(Order body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); - } - // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -179,7 +246,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -188,7 +255,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index 7ab75eabd34..600ad0b678a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -37,17 +37,12 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @throws ApiException if fails to make API call */ public void createUser(User body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); - } - // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -60,7 +55,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -77,17 +72,12 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(List body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); - } - // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -100,7 +90,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -117,17 +107,12 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException if fails to make API call */ public void createUsersWithListInput(List body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); - } - // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -140,7 +125,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -181,7 +166,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -190,7 +175,7 @@ public class UserApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_http_basic" }; apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); @@ -223,7 +208,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -240,24 +225,14 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return String * @throws ApiException if fails to make API call */ public String loginUser(String username, String password) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); - } - - // verify the required parameter 'password' is set - if (password == null) { - throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); - } - // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -272,7 +247,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -306,7 +281,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -324,7 +299,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @throws ApiException if fails to make API call */ public void updateUser(String username, User body) throws ApiException { @@ -335,11 +310,6 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); - } - // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -353,7 +323,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..ee6afefe265 --- /dev/null +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,198 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + + + + + + +public class InlineResponse200 { + + private List tags = new ArrayList(); + private Long id = null; + private Object category = null; + + + public enum StatusEnum { + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + private String name = null; + private List photoUrls = new ArrayList(); + + + /** + **/ + public InlineResponse200 tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + **/ + public InlineResponse200 id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public InlineResponse200 category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + * pet status in the store + **/ + public InlineResponse200 status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(example = "null", value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.tags, inlineResponse200.tags) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category) && + Objects.equals(this.status, inlineResponse200.status) && + Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index 62300f1a0eb..00000000000 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - - -public class ModelApiResponse { - - private Integer code = null; - private String type = null; - private String message = null; - - - /** - **/ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("code") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - - /** - **/ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - - /** - **/ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(this.code, _apiResponse.code) && - Objects.equals(this.type, _apiResponse.type) && - Objects.equals(this.message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 94be5295f5d..43ddec1ff6a 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -39,24 +39,14 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = false; + private Boolean complete = null; - /** - **/ - public Order id(Long id) { - this.id = id; - return this; - } - @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java b/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java index d0be1523e45..0c5ef6f1eda 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java @@ -48,7 +48,7 @@ public class PetstoreProfiling { /* UPDATE PET WITH FORM */ start = System.nanoTime(); - petApi.updatePetWithForm(newPetId, "new profiler", "sold"); + petApi.updatePetWithForm(String.valueOf(newPetId), "new profiler", "sold"); results.add(buildResult(index, "UPDATE PET", System.nanoTime() - start)); /* DELETE PET */ diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java index 9e927a69ba2..ad971ea6669 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -73,7 +73,6 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } - /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -120,7 +119,6 @@ public class PetApiTest { assertEquals(category.getId(), Long.valueOf(categoryIdInt)); assertEquals(category.getName(), categoryMap.get("name")); } - */ @Test public void testUpdatePet() throws Exception { @@ -193,7 +191,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId(), "furt", null); + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 4b33d380f14..403f9b64ec9 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -35,7 +35,6 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } - /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -48,14 +47,13 @@ public class StoreApiTest { assertTrue(firstEntry.getKey() instanceof String); assertTrue(firstEntry.getValue() instanceof Integer); } - */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -66,13 +64,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(order.getId()); + api.getOrderById(String.valueOf(order.getId())); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/feign/README.md b/samples/client/petstore/java/feign/README.md index d5d447e2865..3ca7abfb557 100644 --- a/samples/client/petstore/java/feign/README.md +++ b/samples/client/petstore/java/feign/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java index 043861f4e53..bf9378fc9c1 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java @@ -14,7 +14,7 @@ import feign.codec.EncodeException; import feign.codec.Encoder; import feign.RequestTemplate; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class FormAwareEncoder implements Encoder { public static final String UTF_8 = "utf-8"; private static final String LINE_FEED = "\r\n"; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java index 6439885ed11..b8a4d2924f6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index e2e1ad0bee6..2d5ac8be9ee 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -3,7 +3,7 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -12,14 +12,14 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public interface PetApi extends ApiClient.Api { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return void */ @RequestLine("POST /pet") @@ -29,6 +29,19 @@ public interface PetApi extends ApiClient.Api { }) void addPet(Pet body); + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @return void + */ + @RequestLine("POST /pet?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + void addPetUsingByteArray(byte[] body); + /** * Deletes a pet * @@ -47,7 +60,7 @@ public interface PetApi extends ApiClient.Api { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return List */ @RequestLine("GET /pet/findByStatus?status={status}") @@ -59,8 +72,8 @@ public interface PetApi extends ApiClient.Api { /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return List */ @RequestLine("GET /pet/findByTags?tags={tags}") @@ -72,8 +85,8 @@ public interface PetApi extends ApiClient.Api { /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Pet */ @RequestLine("GET /pet/{petId}") @@ -83,10 +96,36 @@ public interface PetApi extends ApiClient.Api { }) Pet getPetById(@Param("petId") Long petId); + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return InlineResponse200 + */ + @RequestLine("GET /pet/{petId}?response=inline_arbitrary_object") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + InlineResponse200 getPetByIdInObject(@Param("petId") Long petId); + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return byte[] + */ + @RequestLine("GET /pet/{petId}?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + byte[] petPetIdtestingByteArraytrueGet(@Param("petId") Long petId); + /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return void */ @RequestLine("PUT /pet") @@ -109,7 +148,7 @@ public interface PetApi extends ApiClient.Api { "Content-type: application/x-www-form-urlencoded", "Accepts: application/json", }) - void updatePetWithForm(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); + void updatePetWithForm(@Param("petId") String petId, @Param("name") String name, @Param("status") String status); /** * uploads an image @@ -117,12 +156,12 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ModelApiResponse + * @return void */ @RequestLine("POST /pet/{petId}/uploadImage") @Headers({ "Content-type: multipart/form-data", "Accepts: application/json", }) - ModelApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 45c9610c5c0..0c358eae7df 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public interface StoreApi extends ApiClient.Api { @@ -27,6 +27,19 @@ public interface StoreApi extends ApiClient.Api { }) void deleteOrder(@Param("orderId") String orderId); + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return List + */ + @RequestLine("GET /store/findByStatus?status={status}") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + List findOrdersByStatus(@Param("status") String status); + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -39,6 +52,18 @@ public interface StoreApi extends ApiClient.Api { }) Map getInventory(); + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + */ + @RequestLine("GET /store/inventory?response=arbitrary_object") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + Object getInventoryInObject(); + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -50,12 +75,12 @@ public interface StoreApi extends ApiClient.Api { "Content-type: application/json", "Accepts: application/json", }) - Order getOrderById(@Param("orderId") Long orderId); + Order getOrderById(@Param("orderId") String orderId); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Order */ @RequestLine("POST /store/order") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index ae731977c6b..ff46fb078b5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -10,14 +10,14 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public interface UserApi extends ApiClient.Api { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @return void */ @RequestLine("POST /user") @@ -30,7 +30,7 @@ public interface UserApi extends ApiClient.Api { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return void */ @RequestLine("POST /user/createWithArray") @@ -43,7 +43,7 @@ public interface UserApi extends ApiClient.Api { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return void */ @RequestLine("POST /user/createWithList") @@ -82,8 +82,8 @@ public interface UserApi extends ApiClient.Api { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return String */ @RequestLine("GET /user/login?username={username}&password={password}") @@ -109,7 +109,7 @@ public interface UserApi extends ApiClient.Api { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @return void */ @RequestLine("PUT /user/{username}") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 8e3eb2af935..20987177b52 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index 3d79c411824..5312e49f241 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 66f4830bce0..7d472b3e71b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index 96d35603bf5..920c9a7ac6c 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 9c6b5e35de6..9917e21724a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index 41b7842d606..bcc40ca5b24 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index 91fb6b5b939..00000000000 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") -public class ModelApiResponse { - - private Integer code = null; - private String type = null; - private String message = null; - - - /** - **/ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("code") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - - /** - **/ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - - /** - **/ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(this.code, _apiResponse.code) && - Objects.equals(this.type, _apiResponse.type) && - Objects.equals(this.message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index 2994e48adaf..539032cec41 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index e51b32ff5a2..c29314eb091 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 3c0ea427c41..e713b75a845 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Order { private Long id = null; @@ -39,24 +39,14 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = false; + private Boolean complete = null; - /** - **/ - public Order id(Long id) { - this.id = id; - return this; - } - @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index ee4ce28371b..2d7a49dd47f 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index 786d75c976c..51f88ff4306 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 4e323812065..981302df547 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 23e363a518e..5502f018489 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java index a2e8c34d95e..bf068652905 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -120,7 +120,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId(), "furt", null); + api.updatePetWithForm(fetched.getId().toString(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java index ca14be28a80..32dcd6d0c0e 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -35,7 +35,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(order.getId().toString()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -46,13 +46,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(order.getId().toString()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(order.getId().toString()); try { - api.getOrderById(order.getId()); + api.getOrderById(order.getId().toString()); fail("expected an error"); } catch (FeignException e) { assertTrue(e.getMessage().startsWith("status 404 ")); diff --git a/samples/client/petstore/java/jersey2/README.md b/samples/client/petstore/java/jersey2/README.md index 6b6db099581..930a4f28c55 100644 --- a/samples/client/petstore/java/jersey2/README.md +++ b/samples/client/petstore/java/jersey2/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation +## Installation & Usage To install the API client library to your local Maven repository, simply execute: @@ -20,9 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -### Maven users - -Add this dependency to your project's POM: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml @@ -31,161 +29,9 @@ Add this dependency to your project's POM: 1.0.0 compile -``` - -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "io.swagger:swagger-petstore-jersey2:1.0.0" -``` - -### Others - -At first generate the JAR by executing: - - mvn package - -Then manually install the following JARs: - -* target/swagger-petstore-jersey2-1.0.0.jar -* target/lib/*.jar - -## Getting Started - -Please follow the [installation](#installation) instruction and execute the following Java code: - -```java - -import io.swagger.client.*; -import io.swagger.client.auth.*; -import io.swagger.client.model.*; -import io.swagger.client.api.PetApi; - -import java.io.File; -import java.util.*; - -public class PetApiExample { - - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - - // Configure OAuth2 access token for authorization: petstore_auth - OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); - petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - - - - PetApi apiInstance = new PetApi(); - - Pet body = new Pet(); // Pet | Pet object that needs to be added to the store - - try { - apiInstance.addPet(body); - } catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); - } - } -} ``` -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status -*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - -## Documentation for Models - - - [Category](docs/Category.md) - - [InlineResponse200](docs/InlineResponse200.md) - - [Model200Response](docs/Model200Response.md) - - [ModelReturn](docs/ModelReturn.md) - - [Name](docs/Name.md) - - [Order](docs/Order.md) - - [Pet](docs/Pet.md) - - [SpecialModelName](docs/SpecialModelName.md) - - [Tag](docs/Tag.md) - - [User](docs/User.md) - - -## Documentation for Authorization - -Authentication schemes defined for the API: -### petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - write:pets: modify pets in your account - - read:pets: read your pets - -### test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -### test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - -### test_http_basic - -- **Type**: HTTP basic authentication - -### test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -### test_api_key_header - -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header - - ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -194,3 +40,4 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io + diff --git a/samples/client/petstore/java/jersey2/docs/Animal.md b/samples/client/petstore/java/jersey2/docs/Animal.md deleted file mode 100644 index 3ecb7f991f3..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Animal.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Animal - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | - - - diff --git a/samples/client/petstore/java/jersey2/docs/ApiResponse.md b/samples/client/petstore/java/jersey2/docs/ApiResponse.md deleted file mode 100644 index 1c17767c2b7..00000000000 --- a/samples/client/petstore/java/jersey2/docs/ApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/Cat.md b/samples/client/petstore/java/jersey2/docs/Cat.md deleted file mode 100644 index 373af540c41..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Cat.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Cat - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**declawed** | **Boolean** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/Category.md b/samples/client/petstore/java/jersey2/docs/Category.md deleted file mode 100644 index e2df0803278..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Category.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Category - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/Dog.md b/samples/client/petstore/java/jersey2/docs/Dog.md deleted file mode 100644 index a1d638d3bad..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Dog.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Dog - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**breed** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/FormatTest.md b/samples/client/petstore/java/jersey2/docs/FormatTest.md deleted file mode 100644 index 8e400e7bcd7..00000000000 --- a/samples/client/petstore/java/jersey2/docs/FormatTest.md +++ /dev/null @@ -1,21 +0,0 @@ - -# FormatTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **Integer** | | [optional] -**int32** | **Integer** | | [optional] -**int64** | **Long** | | [optional] -**number** | [**BigDecimal**](BigDecimal.md) | | -**_float** | **Float** | | [optional] -**_double** | **Double** | | [optional] -**string** | **String** | | [optional] -**_byte** | **byte[]** | | [optional] -**binary** | **byte[]** | | [optional] -**date** | [**Date**](Date.md) | | [optional] -**dateTime** | [**Date**](Date.md) | | [optional] -**password** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/InlineResponse200.md b/samples/client/petstore/java/jersey2/docs/InlineResponse200.md deleted file mode 100644 index 232cb0ed5c1..00000000000 --- a/samples/client/petstore/java/jersey2/docs/InlineResponse200.md +++ /dev/null @@ -1,13 +0,0 @@ -# InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**photoUrls** | **List<String>** | | [optional] -**name** | **String** | | [optional] -**id** | **Long** | | -**category** | **Object** | | [optional] -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | **String** | pet status in the store | [optional] - - diff --git a/samples/client/petstore/java/jersey2/docs/Model200Response.md b/samples/client/petstore/java/jersey2/docs/Model200Response.md deleted file mode 100644 index 0819b88c4f4..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Model200Response.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Model200Response - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md b/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md deleted file mode 100644 index 3eec8686cc9..00000000000 --- a/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ModelApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/ModelReturn.md b/samples/client/petstore/java/jersey2/docs/ModelReturn.md deleted file mode 100644 index a679b04953e..00000000000 --- a/samples/client/petstore/java/jersey2/docs/ModelReturn.md +++ /dev/null @@ -1,10 +0,0 @@ - -# ModelReturn - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/Name.md b/samples/client/petstore/java/jersey2/docs/Name.md deleted file mode 100644 index a1adac1dd39..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Name.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Name - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | -**snakeCase** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/Order.md b/samples/client/petstore/java/jersey2/docs/Order.md deleted file mode 100644 index b1709c14eee..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Order.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Order - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**petId** | **Long** | | [optional] -**quantity** | **Integer** | | [optional] -**shipDate** | [**Date**](Date.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] -**complete** | **Boolean** | | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -PLACED | placed -APPROVED | approved -DELIVERED | delivered - - - diff --git a/samples/client/petstore/java/jersey2/docs/Pet.md b/samples/client/petstore/java/jersey2/docs/Pet.md deleted file mode 100644 index 20a1c298dd6..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Pet.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Pet - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**category** | [**Category**](Category.md) | | [optional] -**name** | **String** | | -**photoUrls** | **List<String>** | | -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold - - - diff --git a/samples/client/petstore/java/jersey2/docs/PetApi.md b/samples/client/petstore/java/jersey2/docs/PetApi.md deleted file mode 100644 index e0314e20e51..00000000000 --- a/samples/client/petstore/java/jersey2/docs/PetApi.md +++ /dev/null @@ -1,448 +0,0 @@ -# PetApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image - - - -# **addPet** -> addPet(body) - -Add a new pet to the store - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.addPet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **deletePet** -> deletePet(petId, apiKey) - -Deletes a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | Pet id to delete -String apiKey = "apiKey_example"; // String | -try { - apiInstance.deletePet(petId, apiKey); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#deletePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| Pet id to delete | - **apiKey** | **String**| | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByStatus** -> List<Pet> findPetsByStatus(status) - -Finds Pets by status - -Multiple status values can be provided with comma separated strings - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter -try { - List result = apiInstance.findPetsByStatus(status); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByStatus"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByTags** -> List<Pet> findPetsByTags(tags) - -Finds Pets by tags - -Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List tags = Arrays.asList("tags_example"); // List | Tags to filter by -try { - List result = apiInstance.findPetsByTags(tags); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByTags"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **tags** | [**List<String>**](String.md)| Tags to filter by | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getPetById** -> Pet getPetById(petId) - -Find pet by ID - -Returns a single pet - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to return -try { - Pet result = apiInstance.getPetById(petId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#getPetById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to return | - -### Return type - -[**Pet**](Pet.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updatePet** -> updatePet(body) - -Update an existing pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.updatePet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **updatePetWithForm** -> updatePetWithForm(petId, name, status) - -Updates a pet in the store with form data - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet that needs to be updated -String name = "name_example"; // String | Updated name of the pet -String status = "status_example"; // String | Updated status of the pet -try { - apiInstance.updatePetWithForm(petId, name, status); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePetWithForm"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet that needs to be updated | - **name** | **String**| Updated name of the pet | [optional] - **status** | **String**| Updated status of the pet | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/xml, application/json - - -# **uploadFile** -> ModelApiResponse uploadFile(petId, additionalMetadata, file) - -uploads an image - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to update -String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server -File file = new File("/path/to/file.txt"); // File | file to upload -try { - ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#uploadFile"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to update | - **additionalMetadata** | **String**| Additional data to pass to server | [optional] - **file** | **File**| file to upload | [optional] - -### Return type - -[**ModelApiResponse**](ModelApiResponse.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: multipart/form-data - - **Accept**: application/json - diff --git a/samples/client/petstore/java/jersey2/docs/SpecialModelName.md b/samples/client/petstore/java/jersey2/docs/SpecialModelName.md deleted file mode 100644 index c2c6117c552..00000000000 --- a/samples/client/petstore/java/jersey2/docs/SpecialModelName.md +++ /dev/null @@ -1,10 +0,0 @@ - -# SpecialModelName - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**specialPropertyName** | **Long** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/StoreApi.md b/samples/client/petstore/java/jersey2/docs/StoreApi.md deleted file mode 100644 index 0b30791725a..00000000000 --- a/samples/client/petstore/java/jersey2/docs/StoreApi.md +++ /dev/null @@ -1,197 +0,0 @@ -# StoreApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet - - - -# **deleteOrder** -> deleteOrder(orderId) - -Delete purchase order by ID - -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -String orderId = "orderId_example"; // String | ID of the order that needs to be deleted -try { - apiInstance.deleteOrder(orderId); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#deleteOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **String**| ID of the order that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getInventory** -> Map<String, Integer> getInventory() - -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.StoreApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -StoreApi apiInstance = new StoreApi(); -try { - Map result = apiInstance.getInventory(); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getInventory"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**Map<String, Integer>**](Map.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - - -# **getOrderById** -> Order getOrderById(orderId) - -Find purchase order by ID - -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Long orderId = 789L; // Long | ID of pet that needs to be fetched -try { - Order result = apiInstance.getOrderById(orderId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getOrderById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **Long**| ID of pet that needs to be fetched | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **placeOrder** -> Order placeOrder(body) - -Place an order for a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Order body = new Order(); // Order | order placed for purchasing the pet -try { - Order result = apiInstance.placeOrder(body); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#placeOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/jersey2/docs/Tag.md b/samples/client/petstore/java/jersey2/docs/Tag.md deleted file mode 100644 index de6814b55d5..00000000000 --- a/samples/client/petstore/java/jersey2/docs/Tag.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Tag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/User.md b/samples/client/petstore/java/jersey2/docs/User.md deleted file mode 100644 index 8b6753dd284..00000000000 --- a/samples/client/petstore/java/jersey2/docs/User.md +++ /dev/null @@ -1,17 +0,0 @@ - -# User - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**username** | **String** | | [optional] -**firstName** | **String** | | [optional] -**lastName** | **String** | | [optional] -**email** | **String** | | [optional] -**password** | **String** | | [optional] -**phone** | **String** | | [optional] -**userStatus** | **Integer** | User Status | [optional] - - - diff --git a/samples/client/petstore/java/jersey2/docs/UserApi.md b/samples/client/petstore/java/jersey2/docs/UserApi.md deleted file mode 100644 index 8cdc15992ee..00000000000 --- a/samples/client/petstore/java/jersey2/docs/UserApi.md +++ /dev/null @@ -1,370 +0,0 @@ -# UserApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**createUser**](UserApi.md#createUser) | **POST** /user | Create user -[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - - -# **createUser** -> createUser(body) - -Create user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -User body = new User(); // User | Created user object -try { - apiInstance.createUser(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithArrayInput** -> createUsersWithArrayInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithArrayInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithListInput** -> createUsersWithListInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithListInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithListInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **deleteUser** -> deleteUser(username) - -Delete user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be deleted -try { - apiInstance.deleteUser(username); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#deleteUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getUserByName** -> User getUserByName(username) - -Get user by user name - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. -try { - User result = apiInstance.getUserByName(username); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#getUserByName"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**User**](User.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **loginUser** -> String loginUser(username, password) - -Logs user into the system - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The user name for login -String password = "password_example"; // String | The password for login in clear text -try { - String result = apiInstance.loginUser(username, password); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#loginUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | - **password** | **String**| The password for login in clear text | - -### Return type - -**String** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **logoutUser** -> logoutUser() - -Logs out current logged in user session - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -try { - apiInstance.logoutUser(); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#logoutUser"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updateUser** -> updateUser(username, body) - -Updated user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | name that need to be deleted -User body = new User(); // User | Updated user object -try { - apiInstance.updateUser(username, body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#updateUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index f513e2165c7..0b0368d214f 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index c6c4f0b1cd6..256cd5ff087 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 8d447238daf..51b30d45655 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import javax.ws.rs.ext.ContextResolver; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class JSON implements ContextResolver { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index 6fb0888876f..d09ea6040bf 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index cd18a247928..b42e4d241ae 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index d96bf5dcc0b..61ba97f3fea 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import io.swagger.client.Pair; import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class PetApi { private ApiClient apiClient; @@ -39,17 +39,12 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException if fails to make API call */ public void addPet(Pet body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -62,7 +57,42 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json", "application/xml" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @throws ApiException if fails to make API call + */ + public void addPetUsingByteArray(byte[] body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -106,7 +136,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -123,18 +153,13 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return List * @throws ApiException if fails to make API call */ public List findPetsByStatus(List status) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'status' is set - if (status == null) { - throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); - } - // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -143,12 +168,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -164,19 +189,14 @@ public class PetApi { } /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return List * @throws ApiException if fails to make API call */ public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'tags' is set - if (tags == null) { - throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); - } - // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -185,12 +205,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -206,8 +226,8 @@ public class PetApi { } /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Pet * @throws ApiException if fails to make API call */ @@ -232,7 +252,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -241,25 +261,104 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return InlineResponse200 + * @throws ApiException if fails to make API call + */ + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return byte[] + * @throws ApiException if fails to make API call + */ + public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException if fails to make API call */ public void updatePet(Pet body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -272,7 +371,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -294,7 +393,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException if fails to make API call */ - public void updatePetWithForm(Long petId, String name, String status) throws ApiException { + public void updatePetWithForm(String petId, String name, String status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -319,7 +418,7 @@ if (status != null) localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -339,10 +438,9 @@ if (status != null) * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ModelApiResponse * @throws ApiException if fails to make API call */ - public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -367,7 +465,7 @@ if (file != null) localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -378,7 +476,7 @@ if (file != null) String[] localVarAuthNames = new String[] { "petstore_auth" }; - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 65d0ff6a615..bed19115aa0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class StoreApi { private ApiClient apiClient; @@ -61,7 +61,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -75,6 +75,43 @@ public class StoreApi { apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return List + * @throws ApiException if fails to make API call + */ + public List findOrdersByStatus(String status) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + + GenericType> localVarReturnType = new GenericType>() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -96,7 +133,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -110,6 +147,41 @@ public class StoreApi { GenericType> localVarReturnType = new GenericType>() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getInventoryInObject() throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key" }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -117,7 +189,7 @@ public class StoreApi { * @return Order * @throws ApiException if fails to make API call */ - public Order getOrderById(Long orderId) throws ApiException { + public Order getOrderById(String orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -138,7 +210,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -147,7 +219,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); @@ -155,18 +227,13 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Order * @throws ApiException if fails to make API call */ public Order placeOrder(Order body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); - } - // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -179,7 +246,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -188,7 +255,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 8a1cba219a6..a6a28778e09 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class UserApi { private ApiClient apiClient; @@ -37,17 +37,12 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @throws ApiException if fails to make API call */ public void createUser(User body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); - } - // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -60,7 +55,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -77,17 +72,12 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(List body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); - } - // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -100,7 +90,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -117,17 +107,12 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException if fails to make API call */ public void createUsersWithListInput(List body) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); - } - // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -140,7 +125,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -181,7 +166,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -190,7 +175,7 @@ public class UserApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_http_basic" }; apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); @@ -223,7 +208,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -240,24 +225,14 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return String * @throws ApiException if fails to make API call */ public String loginUser(String username, String password) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); - } - - // verify the required parameter 'password' is set - if (password == null) { - throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); - } - // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -272,7 +247,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -306,7 +281,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -324,7 +299,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @throws ApiException if fails to make API call */ public void updateUser(String username, User body) throws ApiException { @@ -335,11 +310,6 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); - } - // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -353,7 +323,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index acdcaa52fcd..d7cfe647b59 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index fc96078e06e..a956d40501b 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index e70241f1171..9534d08fd36 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index d56e70d7689..37262216c72 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index da8a3553b00..c8e19c39c30 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index e8e19c2d32e..fad08101a44 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index 0d620e5addd..920d45354d5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 1586ae89d6d..9d0b1a22e98 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..57084986396 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,198 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +public class InlineResponse200 { + + private List tags = new ArrayList(); + private Long id = null; + private Object category = null; + + + public enum StatusEnum { + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + private String name = null; + private List photoUrls = new ArrayList(); + + + /** + **/ + public InlineResponse200 tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + **/ + public InlineResponse200 id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public InlineResponse200 category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + * pet status in the store + **/ + public InlineResponse200 status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(example = "null", value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.tags, inlineResponse200.tags) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category) && + Objects.equals(this.status, inlineResponse200.status) && + Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 1db08de21f4..32010398f48 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index fe1bf3f483d..00000000000 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") -public class ModelApiResponse { - - private Integer code = null; - private String type = null; - private String message = null; - - - /** - **/ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("code") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - - /** - **/ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - - /** - **/ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(this.code, _apiResponse.code) && - Objects.equals(this.type, _apiResponse.type) && - Objects.equals(this.message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 1f89198ddda..0fad49d781d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index cc7dbe3dd6e..72b8652423e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 136aa894eb4..e5b35f51539 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Order { private Long id = null; @@ -39,24 +39,14 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = false; + private Boolean complete = null; - /** - **/ - public Order id(Long id) { - this.id = id; - return this; - } - @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 859a1ce8c3c..2ae12be0c91 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index be6b9c3c92a..7233dae4aae 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 276ff12d6eb..5a680e60356 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 646f9969f30..6017c1f66ab 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java index 51583853257..9af7c537877 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -70,7 +70,6 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } - /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -117,7 +116,6 @@ public class PetApiTest { assertEquals(category.getId(), Long.valueOf(categoryIdInt)); assertEquals(category.getName(), categoryMap.get("name")); } - */ @Test public void testUpdatePet() throws Exception { @@ -190,7 +188,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId(), "furt", null); + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 7ccbdf3f32b..b0106d2f4c6 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,7 +33,6 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } - /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -46,14 +45,13 @@ public class StoreApiTest { assertTrue(firstEntry.getKey() instanceof String); assertTrue(firstEntry.getValue() instanceof Integer); } - */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -64,13 +62,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(order.getId()); + api.getOrderById(String.valueOf(order.getId())); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index f2b11d703c2..fd85a16cd07 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation +## Installation & Usage To install the API client library to your local Maven repository, simply execute: @@ -20,9 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -### Maven users - -Add this dependency to your project's POM: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml @@ -31,164 +29,9 @@ Add this dependency to your project's POM: 1.0.0 compile -``` - -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "io.swagger:swagger-petstore-okhttp-gson:1.0.0" -``` - -### Others - -At first generate the JAR by executing: - - mvn package - -Then manually install the following JARs: - -* target/swagger-petstore-okhttp-gson-1.0.0.jar -* target/lib/*.jar - -## Getting Started - -Please follow the [installation](#installation) instruction and execute the following Java code: - -```java - -import io.swagger.client.*; -import io.swagger.client.auth.*; -import io.swagger.client.model.*; -import io.swagger.client.api.PetApi; - -import java.io.File; -import java.util.*; - -public class PetApiExample { - - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - - // Configure OAuth2 access token for authorization: petstore_auth - OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); - petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - - - - PetApi apiInstance = new PetApi(); - - Pet body = new Pet(); // Pet | Pet object that needs to be added to the store - - try { - apiInstance.addPet(body); - } catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); - } - } -} ``` -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' -*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status -*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - -## Documentation for Models - - - [Animal](docs/Animal.md) - - [Cat](docs/Cat.md) - - [Category](docs/Category.md) - - [Dog](docs/Dog.md) - - [InlineResponse200](docs/InlineResponse200.md) - - [Model200Response](docs/Model200Response.md) - - [ModelReturn](docs/ModelReturn.md) - - [Name](docs/Name.md) - - [Order](docs/Order.md) - - [Pet](docs/Pet.md) - - [SpecialModelName](docs/SpecialModelName.md) - - [Tag](docs/Tag.md) - - [User](docs/User.md) - - -## Documentation for Authorization - -Authentication schemes defined for the API: -### petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - write:pets: modify pets in your account - - read:pets: read your pets - -### test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -### test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - -### test_http_basic - -- **Type**: HTTP basic authentication - -### test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -### test_api_key_header - -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header - - ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -197,3 +40,4 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Animal.md b/samples/client/petstore/java/okhttp-gson/docs/Animal.md deleted file mode 100644 index 3ecb7f991f3..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Animal.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Animal - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md b/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md deleted file mode 100644 index 1c17767c2b7..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Cat.md b/samples/client/petstore/java/okhttp-gson/docs/Cat.md deleted file mode 100644 index 373af540c41..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Cat.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Cat - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**declawed** | **Boolean** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Category.md b/samples/client/petstore/java/okhttp-gson/docs/Category.md deleted file mode 100644 index e2df0803278..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Category.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Category - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Dog.md b/samples/client/petstore/java/okhttp-gson/docs/Dog.md deleted file mode 100644 index a1d638d3bad..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Dog.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Dog - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**className** | **String** | | -**breed** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md b/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md deleted file mode 100644 index 8e400e7bcd7..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md +++ /dev/null @@ -1,21 +0,0 @@ - -# FormatTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **Integer** | | [optional] -**int32** | **Integer** | | [optional] -**int64** | **Long** | | [optional] -**number** | [**BigDecimal**](BigDecimal.md) | | -**_float** | **Float** | | [optional] -**_double** | **Double** | | [optional] -**string** | **String** | | [optional] -**_byte** | **byte[]** | | [optional] -**binary** | **byte[]** | | [optional] -**date** | [**Date**](Date.md) | | [optional] -**dateTime** | [**Date**](Date.md) | | [optional] -**password** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md b/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md deleted file mode 100644 index 487ebe429e4..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md +++ /dev/null @@ -1,24 +0,0 @@ - -# InlineResponse200 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**photoUrls** | **List<String>** | | [optional] -**name** | **String** | | [optional] -**id** | **Long** | | -**category** | **Object** | | [optional] -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md b/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md deleted file mode 100644 index 0819b88c4f4..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md +++ /dev/null @@ -1,10 +0,0 @@ - -# Model200Response - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md b/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md deleted file mode 100644 index 3eec8686cc9..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md +++ /dev/null @@ -1,12 +0,0 @@ - -# ModelApiResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **Integer** | | [optional] -**type** | **String** | | [optional] -**message** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md b/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md deleted file mode 100644 index a679b04953e..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md +++ /dev/null @@ -1,10 +0,0 @@ - -# ModelReturn - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Name.md b/samples/client/petstore/java/okhttp-gson/docs/Name.md deleted file mode 100644 index a1adac1dd39..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Name.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Name - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **Integer** | | -**snakeCase** | **Integer** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Order.md b/samples/client/petstore/java/okhttp-gson/docs/Order.md deleted file mode 100644 index b1709c14eee..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Order.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Order - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**petId** | **Long** | | [optional] -**quantity** | **Integer** | | [optional] -**shipDate** | [**Date**](Date.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] -**complete** | **Boolean** | | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -PLACED | placed -APPROVED | approved -DELIVERED | delivered - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Pet.md b/samples/client/petstore/java/okhttp-gson/docs/Pet.md deleted file mode 100644 index 20a1c298dd6..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Pet.md +++ /dev/null @@ -1,24 +0,0 @@ - -# Pet - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**category** | [**Category**](Category.md) | | [optional] -**name** | **String** | | -**photoUrls** | **List<String>** | | -**tags** | [**List<Tag>**](Tag.md) | | [optional] -**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] - - - -## Enum: StatusEnum -Name | Value ----- | ----- -AVAILABLE | available -PENDING | pending -SOLD | sold - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson/docs/PetApi.md deleted file mode 100644 index e0314e20e51..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/PetApi.md +++ /dev/null @@ -1,448 +0,0 @@ -# PetApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image - - - -# **addPet** -> addPet(body) - -Add a new pet to the store - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.addPet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **deletePet** -> deletePet(petId, apiKey) - -Deletes a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | Pet id to delete -String apiKey = "apiKey_example"; // String | -try { - apiInstance.deletePet(petId, apiKey); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#deletePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| Pet id to delete | - **apiKey** | **String**| | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByStatus** -> List<Pet> findPetsByStatus(status) - -Finds Pets by status - -Multiple status values can be provided with comma separated strings - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter -try { - List result = apiInstance.findPetsByStatus(status); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByStatus"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **findPetsByTags** -> List<Pet> findPetsByTags(tags) - -Finds Pets by tags - -Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -List tags = Arrays.asList("tags_example"); // List | Tags to filter by -try { - List result = apiInstance.findPetsByTags(tags); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#findPetsByTags"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **tags** | [**List<String>**](String.md)| Tags to filter by | - -### Return type - -[**List<Pet>**](Pet.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getPetById** -> Pet getPetById(petId) - -Find pet by ID - -Returns a single pet - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to return -try { - Pet result = apiInstance.getPetById(petId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#getPetById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to return | - -### Return type - -[**Pet**](Pet.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updatePet** -> updatePet(body) - -Update an existing pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Pet body = new Pet(); // Pet | Pet object that needs to be added to the store -try { - apiInstance.updatePet(body); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePet"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/json, application/xml - - **Accept**: application/xml, application/json - - -# **updatePetWithForm** -> updatePetWithForm(petId, name, status) - -Updates a pet in the store with form data - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet that needs to be updated -String name = "name_example"; // String | Updated name of the pet -String status = "status_example"; // String | Updated status of the pet -try { - apiInstance.updatePetWithForm(petId, name, status); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#updatePetWithForm"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet that needs to be updated | - **name** | **String**| Updated name of the pet | [optional] - **status** | **String**| Updated status of the pet | [optional] - -### Return type - -null (empty response body) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: application/x-www-form-urlencoded - - **Accept**: application/xml, application/json - - -# **uploadFile** -> ModelApiResponse uploadFile(petId, additionalMetadata, file) - -uploads an image - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.PetApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure OAuth2 access token for authorization: petstore_auth -OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); -petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - -PetApi apiInstance = new PetApi(); -Long petId = 789L; // Long | ID of pet to update -String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server -File file = new File("/path/to/file.txt"); // File | file to upload -try { - ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling PetApi#uploadFile"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **petId** | **Long**| ID of pet to update | - **additionalMetadata** | **String**| Additional data to pass to server | [optional] - **file** | **File**| file to upload | [optional] - -### Return type - -[**ModelApiResponse**](ModelApiResponse.md) - -### Authorization - -[petstore_auth](../README.md#petstore_auth) - -### HTTP request headers - - - **Content-Type**: multipart/form-data - - **Accept**: application/json - diff --git a/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md b/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md deleted file mode 100644 index c2c6117c552..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md +++ /dev/null @@ -1,10 +0,0 @@ - -# SpecialModelName - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**specialPropertyName** | **Long** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md b/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md deleted file mode 100644 index 0b30791725a..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md +++ /dev/null @@ -1,197 +0,0 @@ -# StoreApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet - - - -# **deleteOrder** -> deleteOrder(orderId) - -Delete purchase order by ID - -For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -String orderId = "orderId_example"; // String | ID of the order that needs to be deleted -try { - apiInstance.deleteOrder(orderId); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#deleteOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **String**| ID of the order that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getInventory** -> Map<String, Integer> getInventory() - -Returns pet inventories by status - -Returns a map of status codes to quantities - -### Example -```java -// Import classes: -//import io.swagger.client.ApiClient; -//import io.swagger.client.ApiException; -//import io.swagger.client.Configuration; -//import io.swagger.client.auth.*; -//import io.swagger.client.api.StoreApi; - -ApiClient defaultClient = Configuration.getDefaultApiClient(); - -// Configure API key authorization: api_key -ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); -api_key.setApiKey("YOUR API KEY"); -// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//api_key.setApiKeyPrefix("Token"); - -StoreApi apiInstance = new StoreApi(); -try { - Map result = apiInstance.getInventory(); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getInventory"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**Map<String, Integer>**](Map.md) - -### Authorization - -[api_key](../README.md#api_key) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - - -# **getOrderById** -> Order getOrderById(orderId) - -Find purchase order by ID - -For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Long orderId = 789L; // Long | ID of pet that needs to be fetched -try { - Order result = apiInstance.getOrderById(orderId); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#getOrderById"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **orderId** | **Long**| ID of pet that needs to be fetched | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **placeOrder** -> Order placeOrder(body) - -Place an order for a pet - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.StoreApi; - - -StoreApi apiInstance = new StoreApi(); -Order body = new Order(); // Order | order placed for purchasing the pet -try { - Order result = apiInstance.placeOrder(body); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling StoreApi#placeOrder"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | - -### Return type - -[**Order**](Order.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Tag.md b/samples/client/petstore/java/okhttp-gson/docs/Tag.md deleted file mode 100644 index de6814b55d5..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/Tag.md +++ /dev/null @@ -1,11 +0,0 @@ - -# Tag - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**name** | **String** | | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/User.md b/samples/client/petstore/java/okhttp-gson/docs/User.md deleted file mode 100644 index 8b6753dd284..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/User.md +++ /dev/null @@ -1,17 +0,0 @@ - -# User - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**id** | **Long** | | [optional] -**username** | **String** | | [optional] -**firstName** | **String** | | [optional] -**lastName** | **String** | | [optional] -**email** | **String** | | [optional] -**password** | **String** | | [optional] -**phone** | **String** | | [optional] -**userStatus** | **Integer** | User Status | [optional] - - - diff --git a/samples/client/petstore/java/okhttp-gson/docs/UserApi.md b/samples/client/petstore/java/okhttp-gson/docs/UserApi.md deleted file mode 100644 index 8cdc15992ee..00000000000 --- a/samples/client/petstore/java/okhttp-gson/docs/UserApi.md +++ /dev/null @@ -1,370 +0,0 @@ -# UserApi - -All URIs are relative to *http://petstore.swagger.io/v2* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**createUser**](UserApi.md#createUser) | **POST** /user | Create user -[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - - -# **createUser** -> createUser(body) - -Create user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -User body = new User(); // User | Created user object -try { - apiInstance.createUser(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithArrayInput** -> createUsersWithArrayInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithArrayInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **createUsersWithListInput** -> createUsersWithListInput(body) - -Creates list of users with given input array - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -List body = Arrays.asList(new User()); // List | List of user object -try { - apiInstance.createUsersWithListInput(body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#createUsersWithListInput"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **deleteUser** -> deleteUser(username) - -Delete user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be deleted -try { - apiInstance.deleteUser(username); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#deleteUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be deleted | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **getUserByName** -> User getUserByName(username) - -Get user by user name - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. -try { - User result = apiInstance.getUserByName(username); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#getUserByName"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | - -### Return type - -[**User**](User.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **loginUser** -> String loginUser(username, password) - -Logs user into the system - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | The user name for login -String password = "password_example"; // String | The password for login in clear text -try { - String result = apiInstance.loginUser(username, password); - System.out.println(result); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#loginUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| The user name for login | - **password** | **String**| The password for login in clear text | - -### Return type - -**String** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **logoutUser** -> logoutUser() - -Logs out current logged in user session - - - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -try { - apiInstance.logoutUser(); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#logoutUser"); - e.printStackTrace(); -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - - -# **updateUser** -> updateUser(username, body) - -Updated user - -This can only be done by the logged in user. - -### Example -```java -// Import classes: -//import io.swagger.client.ApiException; -//import io.swagger.client.api.UserApi; - - -UserApi apiInstance = new UserApi(); -String username = "username_example"; // String | name that need to be deleted -User body = new User(); // User | Updated user object -try { - apiInstance.updateUser(username, body); -} catch (ApiException e) { - System.err.println("Exception when calling UserApi#updateUser"); - e.printStackTrace(); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **username** | **String**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | - -### Return type - -null (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/xml, application/json - diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 9328cb74d84..ef5ae6fa25d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -146,7 +146,12 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_http_basic", new HttpBasicAuth()); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 38c89d2d0fc..564721b4128 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index e879206d377..d165a15b2c7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index e1b2c38f0a2..3527bb741c6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 32556afd1b6..67634780b8e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index ac7ad688c56..1bfdafb1fcb 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -18,7 +18,7 @@ import com.squareup.okhttp.Response; import java.io.IOException; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.lang.reflect.Type; @@ -50,11 +50,6 @@ public class PetApi { private Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling addPet(Async)"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -66,7 +61,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -96,7 +91,7 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void addPet(Pet body) throws ApiException { @@ -106,7 +101,7 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -118,7 +113,7 @@ public class PetApi { /** * Add a new pet to the store (asynchronously) * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -148,6 +143,103 @@ public class PetApi { apiClient.executeAsync(call, callback); return call; } + /* Build call for addPetUsingByteArray */ + private Call addPetUsingByteArrayCall(byte[] body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + + // create path and map variables + String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json", "application/xml" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "petstore_auth" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public void addPetUsingByteArray(byte[] body) throws ApiException { + addPetUsingByteArrayWithHttpInfo(body); + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse addPetUsingByteArrayWithHttpInfo(byte[] body) throws ApiException { + Call call = addPetUsingByteArrayCall(body, null, null); + return apiClient.execute(call); + } + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store (asynchronously) + * + * @param body Pet object in the form of byte array (optional) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call addPetUsingByteArrayAsync(byte[] body, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = addPetUsingByteArrayCall(body, progressListener, progressRequestListener); + apiClient.executeAsync(call, callback); + return call; + } /* Build call for deletePet */ private Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; @@ -171,7 +263,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -260,25 +352,20 @@ public class PetApi { private Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'status' is set - if (status == null) { - throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); - } - // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); List localVarQueryParams = new ArrayList(); if (status != null) - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -308,7 +395,7 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return List * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -320,7 +407,7 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return ApiResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -333,7 +420,7 @@ public class PetApi { /** * Finds Pets by status (asynchronously) * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -368,25 +455,20 @@ public class PetApi { private Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'tags' is set - if (tags == null) { - throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); - } - // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); List localVarQueryParams = new ArrayList(); if (tags != null) - localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -415,8 +497,8 @@ public class PetApi { /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return List * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -427,8 +509,8 @@ public class PetApi { /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return ApiResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -440,8 +522,8 @@ public class PetApi { /** * Finds Pets by tags (asynchronously) - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -493,7 +575,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -516,14 +598,14 @@ public class PetApi { }); } - String[] localVarAuthNames = new String[] { "api_key" }; + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Pet * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -534,8 +616,8 @@ public class PetApi { /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -547,8 +629,8 @@ public class PetApi { /** * Find pet by ID (asynchronously) - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -579,15 +661,224 @@ public class PetApi { apiClient.executeAsync(call, localVarReturnType, callback); return call; } + /* Build call for getPetByIdInObject */ + private Call getPetByIdInObjectCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdInObject(Async)"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return InlineResponse200 + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { + ApiResponse resp = getPetByIdInObjectWithHttpInfo(petId); + return resp.getData(); + } + + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getPetByIdInObjectWithHttpInfo(Long petId) throws ApiException { + Call call = getPetByIdInObjectCall(petId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' (asynchronously) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call getPetByIdInObjectAsync(Long petId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = getPetByIdInObjectCall(petId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /* Build call for petPetIdtestingByteArraytrueGet */ + private Call petPetIdtestingByteArraytrueGetCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException("Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet(Async)"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return byte[] + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { + ApiResponse resp = petPetIdtestingByteArraytrueGetWithHttpInfo(petId); + return resp.getData(); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse petPetIdtestingByteArraytrueGetWithHttpInfo(Long petId) throws ApiException { + Call call = petPetIdtestingByteArraytrueGetCall(petId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' (asynchronously) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call petPetIdtestingByteArraytrueGetAsync(Long petId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = petPetIdtestingByteArraytrueGetCall(petId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } /* Build call for updatePet */ private Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling updatePet(Async)"); - } - // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -599,7 +890,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -629,7 +920,7 @@ public class PetApi { /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updatePet(Pet body) throws ApiException { @@ -639,7 +930,7 @@ public class PetApi { /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -651,7 +942,7 @@ public class PetApi { /** * Update an existing pet (asynchronously) * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -682,7 +973,7 @@ public class PetApi { return call; } /* Build call for updatePetWithForm */ - private Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call updatePetWithFormCall(String petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -706,7 +997,7 @@ public class PetApi { localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -741,7 +1032,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public void updatePetWithForm(Long petId, String name, String status) throws ApiException { + public void updatePetWithForm(String petId, String name, String status) throws ApiException { updatePetWithFormWithHttpInfo(petId, name, status); } @@ -754,7 +1045,7 @@ public class PetApi { * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { + public ApiResponse updatePetWithFormWithHttpInfo(String petId, String name, String status) throws ApiException { Call call = updatePetWithFormCall(petId, name, status, null, null); return apiClient.execute(call); } @@ -769,7 +1060,7 @@ public class PetApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback callback) throws ApiException { + public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -819,7 +1110,7 @@ public class PetApi { localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -852,12 +1143,10 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ModelApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { - ApiResponse resp = uploadFileWithHttpInfo(petId, additionalMetadata, file); - return resp.getData(); + public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + uploadFileWithHttpInfo(petId, additionalMetadata, file); } /** @@ -866,13 +1155,12 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ApiResponse + * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { + public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { Call call = uploadFileCall(petId, additionalMetadata, file, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); + return apiClient.execute(call); } /** @@ -885,7 +1173,7 @@ public class PetApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback callback) throws ApiException { + public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -907,8 +1195,7 @@ public class PetApi { } Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); + apiClient.executeAsync(call, callback); return call; } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 5d960d0b104..4d803d3b575 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -65,7 +65,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -147,6 +147,109 @@ public class StoreApi { apiClient.executeAsync(call, callback); return call; } + /* Build call for findOrdersByStatus */ + private Call findOrdersByStatusCall(String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + + // create path and map variables + String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); + + List localVarQueryParams = new ArrayList(); + if (status != null) + localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return List + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public List findOrdersByStatus(String status) throws ApiException { + ApiResponse> resp = findOrdersByStatusWithHttpInfo(status); + return resp.getData(); + } + + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return ApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse> findOrdersByStatusWithHttpInfo(String status) throws ApiException { + Call call = findOrdersByStatusCall(status, null, null); + Type localVarReturnType = new TypeToken>(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Finds orders by status (asynchronously) + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call findOrdersByStatusAsync(String status, final ApiCallback> callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = findOrdersByStatusCall(status, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken>(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } /* Build call for getInventory */ private Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; @@ -162,7 +265,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -245,19 +348,13 @@ public class StoreApi { apiClient.executeAsync(call, localVarReturnType, callback); return call; } - /* Build call for getOrderById */ - private Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + /* Build call for getInventoryInObject */ + private Call getInventoryInObjectCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'orderId' is set - if (orderId == null) { - throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); - } - // create path and map variables - String localVarPath = "/store/order/{orderId}".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); List localVarQueryParams = new ArrayList(); @@ -266,7 +363,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -289,7 +386,111 @@ public class StoreApi { }); } - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Object getInventoryInObject() throws ApiException { + ApiResponse resp = getInventoryInObjectWithHttpInfo(); + return resp.getData(); + } + + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getInventoryInObjectWithHttpInfo() throws ApiException { + Call call = getInventoryInObjectCall(null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' (asynchronously) + * Returns an arbitrary object which is actually a map of status codes to quantities + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call getInventoryInObjectAsync(final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = getInventoryInObjectCall(progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /* Build call for getOrderById */ + private Call getOrderByIdCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'orderId' is set + if (orderId == null) { + throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); + } + + + // create path and map variables + String localVarPath = "/store/order/{orderId}".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } @@ -300,7 +501,7 @@ public class StoreApi { * @return Order * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public Order getOrderById(Long orderId) throws ApiException { + public Order getOrderById(String orderId) throws ApiException { ApiResponse resp = getOrderByIdWithHttpInfo(orderId); return resp.getData(); } @@ -312,7 +513,7 @@ public class StoreApi { * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { + public ApiResponse getOrderByIdWithHttpInfo(String orderId) throws ApiException { Call call = getOrderByIdCall(orderId, null, null); Type localVarReturnType = new TypeToken(){}.getType(); return apiClient.execute(call, localVarReturnType); @@ -326,7 +527,7 @@ public class StoreApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call getOrderByIdAsync(Long orderId, final ApiCallback callback) throws ApiException { + public Call getOrderByIdAsync(String orderId, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -356,11 +557,6 @@ public class StoreApi { private Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling placeOrder(Async)"); - } - // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -372,7 +568,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -395,14 +591,14 @@ public class StoreApi { }); } - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Order * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -414,7 +610,7 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -427,7 +623,7 @@ public class StoreApi { /** * Place an order for a pet (asynchronously) * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index be0269ef28f..5126228e323 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -48,11 +48,6 @@ public class UserApi { private Call createUserCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling createUser(Async)"); - } - // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -64,7 +59,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -94,7 +89,7 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUser(User body) throws ApiException { @@ -104,7 +99,7 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -116,7 +111,7 @@ public class UserApi { /** * Create user (asynchronously) * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -150,11 +145,6 @@ public class UserApi { private Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); - } - // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -166,7 +156,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -196,7 +186,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithArrayInput(List body) throws ApiException { @@ -206,7 +196,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -218,7 +208,7 @@ public class UserApi { /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (required) + * @param body List of user object (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -252,11 +242,6 @@ public class UserApi { private Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); - } - // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -268,7 +253,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -298,7 +283,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithListInput(List body) throws ApiException { @@ -308,7 +293,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -320,7 +305,7 @@ public class UserApi { /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (required) + * @param body List of user object (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -371,7 +356,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -394,7 +379,7 @@ public class UserApi { }); } - String[] localVarAuthNames = new String[] { }; + String[] localVarAuthNames = new String[] { "test_http_basic" }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } @@ -474,7 +459,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -564,16 +549,6 @@ public class UserApi { private Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException("Missing the required parameter 'username' when calling loginUser(Async)"); - } - - // verify the required parameter 'password' is set - if (password == null) { - throw new ApiException("Missing the required parameter 'password' when calling loginUser(Async)"); - } - // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -589,7 +564,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -619,8 +594,8 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return String * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -632,8 +607,8 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -646,8 +621,8 @@ public class UserApi { /** * Logs user into the system (asynchronously) * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -693,7 +668,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -781,11 +756,6 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)"); } - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)"); - } - // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") @@ -798,7 +768,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/xml", "application/json" + "application/json", "application/xml" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -829,7 +799,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updateUser(String username, User body) throws ApiException { @@ -840,7 +810,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -853,7 +823,7 @@ public class UserApi { * Updated user (asynchronously) * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index fa2d5293018..526c1163672 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index 81d6fddf5b0..a109275004e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..15bb92523fe --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,168 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class InlineResponse200 { + + @SerializedName("tags") + private List tags = new ArrayList(); + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + @ApiModelProperty(value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.tags, inlineResponse200.tags) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category) && + Objects.equals(this.status, inlineResponse200.status) && + Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index 20d2fc58dd3..00000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - - -public class ModelApiResponse { - - @SerializedName("code") - private Integer code = null; - - @SerializedName("type") - private String type = null; - - @SerializedName("message") - private String message = null; - - /** - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(this.code, _apiResponse.code) && - Objects.equals(this.type, _apiResponse.type) && - Objects.equals(this.message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index b0ebd0e8758..cc13fe4bfd0 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = false; + private Boolean complete = null; /** **/ @@ -60,9 +60,6 @@ public enum StatusEnum { public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** **/ diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java index 5345e2a1646..000dbd96bfb 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java @@ -150,7 +150,6 @@ public class ApiClientTest { } } - /* @Test public void testSetUsernameAndPassword() { HttpBasicAuth auth = null; @@ -172,7 +171,6 @@ public class ApiClientTest { auth.setUsername(null); auth.setPassword(null); } - */ @Test public void testSetApiKeyAndPrefix() { diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java index e378356d0d4..97e708fb2ec 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -72,7 +72,6 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } - /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -87,7 +86,6 @@ public class PetApiTest { assertNotNull(fetched.getCategory()); assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } - */ @Test public void testCreateAndGetPetWithHttpInfo() throws Exception { @@ -199,7 +197,6 @@ public class PetApiTest { assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0)); } - /* @Test public void testGetPetByIdInObject() throws Exception { Pet pet = new Pet(); @@ -233,7 +230,6 @@ public class PetApiTest { assertEquals(category.getId(), categoryIdLong); assertEquals(category.getName(), categoryMap.get("name")); } - */ @Test public void testUpdatePet() throws Exception { @@ -310,7 +306,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId(), "furt", null); + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 0d1910dc1e7..2f4c4297250 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -38,7 +38,6 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } - /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -52,14 +51,13 @@ public class StoreApiTest { // NOTE: Gson parses integer value to double. assertTrue(firstEntry.getValue() instanceof Double); } - */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -70,13 +68,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(order.getId()); + api.getOrderById(String.valueOf(order.getId())); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/retrofit/README.md b/samples/client/petstore/java/retrofit/README.md index 93488cf4e5c..b687b09ab26 100644 --- a/samples/client/petstore/java/retrofit/README.md +++ b/samples/client/petstore/java/retrofit/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java index 6540997c319..ed1ff85acab 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java @@ -47,10 +47,10 @@ public class ApiClient { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 1ec34d9e71d..1ce483dd74c 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:01.525+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:35.471+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index a019a4bf886..af2482b371f 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -7,7 +7,7 @@ import retrofit.http.*; import retrofit.mime.*; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -20,7 +20,7 @@ public interface PetApi { * Add a new pet to the store * Sync method * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Void */ @@ -32,7 +32,7 @@ public interface PetApi { /** * Add a new pet to the store * Async method - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @param cb callback method * @return void */ @@ -41,6 +41,31 @@ public interface PetApi { void addPet( @Body Pet body, Callback cb ); + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * Sync method + * + * @param body Pet object in the form of byte array (optional) + * @return Void + */ + + @POST("/pet?testing_byte_array=true") + Void addPetUsingByteArray( + @Body byte[] body + ); + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * Async method + * @param body Pet object in the form of byte array (optional) + * @param cb callback method + * @return void + */ + + @POST("/pet?testing_byte_array=true") + void addPetUsingByteArray( + @Body byte[] body, Callback cb + ); /** * Deletes a pet * Sync method @@ -72,57 +97,57 @@ public interface PetApi { * Finds Pets by status * Sync method * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return List */ @GET("/pet/findByStatus") List findPetsByStatus( - @Query("status") CSVParams status + @Query("status") List status ); /** * Finds Pets by status * Async method - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @param cb callback method * @return void */ @GET("/pet/findByStatus") void findPetsByStatus( - @Query("status") CSVParams status, Callback> cb + @Query("status") List status, Callback> cb ); /** * Finds Pets by tags * Sync method - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return List */ @GET("/pet/findByTags") List findPetsByTags( - @Query("tags") CSVParams tags + @Query("tags") List tags ); /** * Finds Pets by tags * Async method - * @param tags Tags to filter by (required) + * @param tags Tags to filter by (optional) * @param cb callback method * @return void */ @GET("/pet/findByTags") void findPetsByTags( - @Query("tags") CSVParams tags, Callback> cb + @Query("tags") List tags, Callback> cb ); /** * Find pet by ID * Sync method - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Pet */ @@ -134,7 +159,7 @@ public interface PetApi { /** * Find pet by ID * Async method - * @param petId ID of pet to return (required) + * @param petId ID of pet that needs to be fetched (required) * @param cb callback method * @return void */ @@ -143,11 +168,61 @@ public interface PetApi { void getPetById( @Path("petId") Long petId, Callback cb ); + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Sync method + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return InlineResponse200 + */ + + @GET("/pet/{petId}?response=inline_arbitrary_object") + InlineResponse200 getPetByIdInObject( + @Path("petId") Long petId + ); + + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Async method + * @param petId ID of pet that needs to be fetched (required) + * @param cb callback method + * @return void + */ + + @GET("/pet/{petId}?response=inline_arbitrary_object") + void getPetByIdInObject( + @Path("petId") Long petId, Callback cb + ); + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Sync method + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return byte[] + */ + + @GET("/pet/{petId}?testing_byte_array=true") + byte[] petPetIdtestingByteArraytrueGet( + @Path("petId") Long petId + ); + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Async method + * @param petId ID of pet that needs to be fetched (required) + * @param cb callback method + * @return void + */ + + @GET("/pet/{petId}?testing_byte_array=true") + void petPetIdtestingByteArraytrueGet( + @Path("petId") Long petId, Callback cb + ); /** * Update an existing pet * Sync method * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Void */ @@ -159,7 +234,7 @@ public interface PetApi { /** * Update an existing pet * Async method - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @param cb callback method * @return void */ @@ -181,7 +256,7 @@ public interface PetApi { @FormUrlEncoded @POST("/pet/{petId}") Void updatePetWithForm( - @Path("petId") Long petId, @Field("name") String name, @Field("status") String status + @Path("petId") String petId, @Field("name") String name, @Field("status") String status ); /** @@ -197,7 +272,7 @@ public interface PetApi { @FormUrlEncoded @POST("/pet/{petId}") void updatePetWithForm( - @Path("petId") Long petId, @Field("name") String name, @Field("status") String status, Callback cb + @Path("petId") String petId, @Field("name") String name, @Field("status") String status, Callback cb ); /** * uploads an image @@ -206,12 +281,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ModelApiResponse + * @return Void */ @Multipart @POST("/pet/{petId}/uploadImage") - ModelApiResponse uploadFile( + Void uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file ); @@ -228,6 +303,6 @@ public interface PetApi { @Multipart @POST("/pet/{petId}/uploadImage") void uploadFile( - @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb + @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index def4aa2efc7..ede732a986b 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -39,6 +39,31 @@ public interface StoreApi { void deleteOrder( @Path("orderId") String orderId, Callback cb ); + /** + * Finds orders by status + * Sync method + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return List + */ + + @GET("/store/findByStatus") + List findOrdersByStatus( + @Query("status") String status + ); + + /** + * Finds orders by status + * Async method + * @param status Status value that needs to be considered for query (optional, default to placed) + * @param cb callback method + * @return void + */ + + @GET("/store/findByStatus") + void findOrdersByStatus( + @Query("status") String status, Callback> cb + ); /** * Returns pet inventories by status * Sync method @@ -61,6 +86,28 @@ public interface StoreApi { void getInventory( Callback> cb ); + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Sync method + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + */ + + @GET("/store/inventory?response=arbitrary_object") + Object getInventoryInObject(); + + + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Async method + * @param cb callback method + * @return void + */ + + @GET("/store/inventory?response=arbitrary_object") + void getInventoryInObject( + Callback cb + ); /** * Find purchase order by ID * Sync method @@ -71,7 +118,7 @@ public interface StoreApi { @GET("/store/order/{orderId}") Order getOrderById( - @Path("orderId") Long orderId + @Path("orderId") String orderId ); /** @@ -84,13 +131,13 @@ public interface StoreApi { @GET("/store/order/{orderId}") void getOrderById( - @Path("orderId") Long orderId, Callback cb + @Path("orderId") String orderId, Callback cb ); /** * Place an order for a pet * Sync method * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Order */ @@ -102,7 +149,7 @@ public interface StoreApi { /** * Place an order for a pet * Async method - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @param cb callback method * @return void */ diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java index 8c3380d07d4..ea7285de79c 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java @@ -18,7 +18,7 @@ public interface UserApi { * Create user * Sync method * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @return Void */ @@ -30,7 +30,7 @@ public interface UserApi { /** * Create user * Async method - * @param body Created user object (required) + * @param body Created user object (optional) * @param cb callback method * @return void */ @@ -43,7 +43,7 @@ public interface UserApi { * Creates list of users with given input array * Sync method * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Void */ @@ -55,7 +55,7 @@ public interface UserApi { /** * Creates list of users with given input array * Async method - * @param body List of user object (required) + * @param body List of user object (optional) * @param cb callback method * @return void */ @@ -68,7 +68,7 @@ public interface UserApi { * Creates list of users with given input array * Sync method * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Void */ @@ -80,7 +80,7 @@ public interface UserApi { /** * Creates list of users with given input array * Async method - * @param body List of user object (required) + * @param body List of user object (optional) * @param cb callback method * @return void */ @@ -143,8 +143,8 @@ public interface UserApi { * Logs user into the system * Sync method * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return String */ @@ -156,8 +156,8 @@ public interface UserApi { /** * Logs user into the system * Async method - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @param cb callback method * @return void */ @@ -193,7 +193,7 @@ public interface UserApi { * Sync method * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @return Void */ @@ -206,7 +206,7 @@ public interface UserApi { * Updated user * Async method * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @param cb callback method * @return void */ diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..b17bf005009 --- /dev/null +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,168 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class InlineResponse200 { + + @SerializedName("tags") + private List tags = new ArrayList(); + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + @ApiModelProperty(value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(tags, inlineResponse200.tags) && + Objects.equals(id, inlineResponse200.id) && + Objects.equals(category, inlineResponse200.category) && + Objects.equals(status, inlineResponse200.status) && + Objects.equals(name, inlineResponse200.name) && + Objects.equals(photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index bb5313b42d4..00000000000 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - - -public class ModelApiResponse { - - @SerializedName("code") - private Integer code = null; - - @SerializedName("type") - private String type = null; - - @SerializedName("message") - private String message = null; - - /** - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(code, _apiResponse.code) && - Objects.equals(type, _apiResponse.type) && - Objects.equals(message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java index 196a5702404..f1fb2ad7409 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = false; + private Boolean complete = null; /** **/ @@ -60,9 +60,6 @@ public enum StatusEnum { public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** **/ diff --git a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java index 9fa93650d54..a943a8ffe6e 100644 --- a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -2,8 +2,7 @@ package io.swagger.petstore.test; import io.swagger.TestUtils; -import io.swagger.client.*; -import io.swagger.client.CollectionFormats.*; +import io.swagger.client.ApiClient; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -62,7 +61,7 @@ public class PetApiTest { api.updatePet(pet); - List pets = api.findPetsByStatus(new CSVParams("available")); + List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})); assertNotNull(pets); boolean found = false; @@ -90,7 +89,7 @@ public class PetApiTest { api.updatePet(pet); - List pets = api.findPetsByTags(new CSVParams("friendly")); + List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"})); assertNotNull(pets); boolean found = false; @@ -111,7 +110,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId(), "furt", null); + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java index c823245355a..07d3b6a298d 100644 --- a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,7 +33,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -44,13 +44,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId()); + Order fetched = api.getOrderById(String.valueOf(order.getId())); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(order.getId()); + api.getOrderById(String.valueOf(order.getId())); // fail("expected an error"); } catch (RetrofitError e) { // ok diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java index e49bdf24d7b..ffff8c26d4f 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java @@ -49,8 +49,16 @@ public class ApiClient { Interceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); + } else if (authName == "test_api_client_id") { + auth = new ApiKeyAuth("header", "x-test_api_client_id"); + } else if (authName == "test_api_client_secret") { + auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "test_api_key_query") { + auth = new ApiKeyAuth("query", "test_api_key_query"); + } else if (authName == "test_api_key_header") { + auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index fd13370ea3a..dace285deca 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:03.337+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:36.537+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index ec9d67a7449..f56c7de3ddf 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,7 +9,7 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -21,7 +21,7 @@ public interface PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Call */ @@ -30,6 +30,18 @@ public interface PetApi { @Body Pet body ); + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @return Call + */ + + @POST("pet?testing_byte_array=true") + Call addPetUsingByteArray( + @Body byte[] body + ); + /** * Deletes a pet * @@ -46,31 +58,31 @@ public interface PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return Call> */ @GET("pet/findByStatus") Call> findPetsByStatus( - @Query("status") CSVParams status + @Query("status") List status ); /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return Call> */ @GET("pet/findByTags") Call> findPetsByTags( - @Query("tags") CSVParams tags + @Query("tags") List tags ); /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Call */ @@ -79,10 +91,34 @@ public interface PetApi { @Path("petId") Long petId ); + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return Call + */ + + @GET("pet/{petId}?response=inline_arbitrary_object") + Call getPetByIdInObject( + @Path("petId") Long petId + ); + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return Call + */ + + @GET("pet/{petId}?testing_byte_array=true") + Call petPetIdtestingByteArraytrueGet( + @Path("petId") Long petId + ); + /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Call */ @@ -103,7 +139,7 @@ public interface PetApi { @FormUrlEncoded @POST("pet/{petId}") Call updatePetWithForm( - @Path("petId") Long petId, @Field("name") String name, @Field("status") String status + @Path("petId") String petId, @Field("name") String name, @Field("status") String status ); /** @@ -112,12 +148,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return Call + * @return Call */ @Multipart @POST("pet/{petId}/uploadImage") - Call uploadFile( + Call uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file\"; filename=\"file\"") RequestBody file ); diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java index 1651c07482c..55a3ea5b46a 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java @@ -28,6 +28,18 @@ public interface StoreApi { @Path("orderId") String orderId ); + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return Call> + */ + + @GET("store/findByStatus") + Call> findOrdersByStatus( + @Query("status") String status + ); + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -38,6 +50,16 @@ public interface StoreApi { Call> getInventory(); + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Call + */ + + @GET("store/inventory?response=arbitrary_object") + Call getInventoryInObject(); + + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -47,13 +69,13 @@ public interface StoreApi { @GET("store/order/{orderId}") Call getOrderById( - @Path("orderId") Long orderId + @Path("orderId") String orderId ); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java index a0f17545a0f..ce02953a0c8 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java @@ -19,7 +19,7 @@ public interface UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @return Call */ @@ -31,7 +31,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Call */ @@ -43,7 +43,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Call */ @@ -79,8 +79,8 @@ public interface UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return Call */ @@ -103,7 +103,7 @@ public interface UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..b17bf005009 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,168 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class InlineResponse200 { + + @SerializedName("tags") + private List tags = new ArrayList(); + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + @ApiModelProperty(value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(tags, inlineResponse200.tags) && + Objects.equals(id, inlineResponse200.id) && + Objects.equals(category, inlineResponse200.category) && + Objects.equals(status, inlineResponse200.status) && + Objects.equals(name, inlineResponse200.name) && + Objects.equals(photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index bb5313b42d4..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - - -public class ModelApiResponse { - - @SerializedName("code") - private Integer code = null; - - @SerializedName("type") - private String type = null; - - @SerializedName("message") - private String message = null; - - /** - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(code, _apiResponse.code) && - Objects.equals(type, _apiResponse.type) && - Objects.equals(message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java new file mode 100644 index 00000000000..920640ad2cb --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java @@ -0,0 +1,69 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class ObjectReturn { + + @SerializedName("return") + private Integer _return = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public Integer getReturn() { + return _return; + } + public void setReturn(Integer _return) { + this._return = _return; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObjectReturn _return = (ObjectReturn) o; + return Objects.equals(_return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObjectReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java index 196a5702404..f1fb2ad7409 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = false; + private Boolean complete = null; /** **/ @@ -60,9 +60,6 @@ public enum StatusEnum { public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** **/ diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java index ac8abefb216..3905fb962e3 100644 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -3,7 +3,6 @@ package io.swagger.petstore.test; import io.swagger.TestUtils; import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -66,7 +65,7 @@ public class PetApiTest { api.updatePet(pet).execute(); - List pets = api.findPetsByStatus(new CSVParams("available")).execute().body(); + List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})).execute().body(); assertNotNull(pets); boolean found = false; @@ -94,7 +93,7 @@ public class PetApiTest { api.updatePet(pet).execute(); - List pets = api.findPetsByTags(new CSVParams("friendly")).execute().body(); + List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"})).execute().body(); assertNotNull(pets); boolean found = false; @@ -115,7 +114,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()).execute().body(); - api.updatePetWithForm(fetched.getId(), "furt", null).execute(); + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null).execute(); Pet updated = api.getPetById(fetched.getId()).execute().body(); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 249d5dc4828..bda483d3fd4 100644 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,7 +33,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order).execute(); - Order fetched = api.getOrderById(order.getId()).execute().body(); + Order fetched = api.getOrderById(String.valueOf(order.getId())).execute().body(); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -44,12 +44,12 @@ public class StoreApiTest { Order order = createOrder(); Response aa = api.placeOrder(order).execute(); - Order fetched = api.getOrderById(order.getId()).execute().body(); + Order fetched = api.getOrderById(String.valueOf(order.getId())).execute().body(); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())).execute(); - api.getOrderById(order.getId()).execute(); + api.getOrderById(String.valueOf(order.getId())).execute(); //also in retrofit 1 should return an error but don't, check server api impl. } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java index 32799fdf3d8..5582509be76 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java @@ -49,8 +49,16 @@ public class ApiClient { Interceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); + } else if (authName == "test_api_client_id") { + auth = new ApiKeyAuth("header", "x-test_api_client_id"); + } else if (authName == "test_api_client_secret") { + auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "test_api_key_query") { + auth = new ApiKeyAuth("query", "test_api_key_query"); + } else if (authName == "test_api_key_header") { + auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java index 423a5762822..873647cb45e 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:05.103+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:37:27.438+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 4a2e64b726e..5f35286fb30 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,7 +9,7 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; +import io.swagger.client.model.InlineResponse200; import java.io.File; import java.util.ArrayList; @@ -21,7 +21,7 @@ public interface PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Call */ @@ -30,6 +30,18 @@ public interface PetApi { @Body Pet body ); + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array (optional) + * @return Call + */ + + @POST("pet?testing_byte_array=true") + Observable addPetUsingByteArray( + @Body byte[] body + ); + /** * Deletes a pet * @@ -46,31 +58,31 @@ public interface PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for filter (required) + * @param status Status values that need to be considered for query (optional, default to available) * @return Call> */ @GET("pet/findByStatus") Observable> findPetsByStatus( - @Query("status") CSVParams status + @Query("status") List status ); /** * Finds Pets by tags - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (required) + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (optional) * @return Call> */ @GET("pet/findByTags") Observable> findPetsByTags( - @Query("tags") CSVParams tags + @Query("tags") List tags ); /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return (required) + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) * @return Call */ @@ -79,10 +91,34 @@ public interface PetApi { @Path("petId") Long petId ); + /** + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return Call + */ + + @GET("pet/{petId}?response=inline_arbitrary_object") + Observable getPetByIdInObject( + @Path("petId") Long petId + ); + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched (required) + * @return Call + */ + + @GET("pet/{petId}?testing_byte_array=true") + Observable petPetIdtestingByteArraytrueGet( + @Path("petId") Long petId + ); + /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (required) + * @param body Pet object that needs to be added to the store (optional) * @return Call */ @@ -103,7 +139,7 @@ public interface PetApi { @FormUrlEncoded @POST("pet/{petId}") Observable updatePetWithForm( - @Path("petId") Long petId, @Field("name") String name, @Field("status") String status + @Path("petId") String petId, @Field("name") String name, @Field("status") String status ); /** @@ -112,12 +148,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return Call + * @return Call */ @Multipart @POST("pet/{petId}/uploadImage") - Observable uploadFile( + Observable uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file\"; filename=\"file\"") RequestBody file ); diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java index 19be150428b..a0a60b0e3b6 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java @@ -28,6 +28,18 @@ public interface StoreApi { @Path("orderId") String orderId ); + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query (optional, default to placed) + * @return Call> + */ + + @GET("store/findByStatus") + Observable> findOrdersByStatus( + @Query("status") String status + ); + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -38,6 +50,16 @@ public interface StoreApi { Observable> getInventory(); + /** + * Fake endpoint to test arbitrary object return by 'Get inventory' + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Call + */ + + @GET("store/inventory?response=arbitrary_object") + Observable getInventoryInObject(); + + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -47,13 +69,13 @@ public interface StoreApi { @GET("store/order/{orderId}") Observable getOrderById( - @Path("orderId") Long orderId + @Path("orderId") String orderId ); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (required) + * @param body order placed for purchasing the pet (optional) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java index 4cad0d804d7..e5a17e2bef9 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java @@ -19,7 +19,7 @@ public interface UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (required) + * @param body Created user object (optional) * @return Call */ @@ -31,7 +31,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Call */ @@ -43,7 +43,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param body List of user object (optional) * @return Call */ @@ -79,8 +79,8 @@ public interface UserApi { /** * Logs user into the system * - * @param username The user name for login (required) - * @param password The password for login in clear text (required) + * @param username The user name for login (optional) + * @param password The password for login in clear text (optional) * @return Call */ @@ -103,7 +103,7 @@ public interface UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (required) + * @param body Updated user object (optional) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 00000000000..b17bf005009 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,168 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + + +public class InlineResponse200 { + + @SerializedName("tags") + private List tags = new ArrayList(); + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + @ApiModelProperty(value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(tags, inlineResponse200.tags) && + Objects.equals(id, inlineResponse200.id) && + Objects.equals(category, inlineResponse200.category) && + Objects.equals(status, inlineResponse200.status) && + Objects.equals(name, inlineResponse200.name) && + Objects.equals(photoUrls, inlineResponse200.photoUrls); + } + + @Override + public int hashCode() { + return Objects.hash(tags, id, category, status, name, photoUrls); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java deleted file mode 100644 index bb5313b42d4..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - - -public class ModelApiResponse { - - @SerializedName("code") - private Integer code = null; - - @SerializedName("type") - private String type = null; - - @SerializedName("message") - private String message = null; - - /** - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelApiResponse _apiResponse = (ModelApiResponse) o; - return Objects.equals(code, _apiResponse.code) && - Objects.equals(type, _apiResponse.type) && - Objects.equals(message, _apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java new file mode 100644 index 00000000000..920640ad2cb --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java @@ -0,0 +1,69 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class ObjectReturn { + + @SerializedName("return") + private Integer _return = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public Integer getReturn() { + return _return; + } + public void setReturn(Integer _return) { + this._return = _return; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObjectReturn _return = (ObjectReturn) o; + return Objects.equals(_return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObjectReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java index 196a5702404..f1fb2ad7409 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = false; + private Boolean complete = null; /** **/ @@ -60,9 +60,6 @@ public enum StatusEnum { public Long getId() { return id; } - public void setId(Long id) { - this.id = id; - } /** **/ diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java index e506ec00e9a..a433321a0f9 100644 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -1,7 +1,6 @@ package io.swagger.petstore.test; import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -80,7 +79,7 @@ public class PetApiTest { api.updatePet(pet).subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { - api.findPetsByStatus(new CSVParams("available")).subscribe(new SkeletonSubscriber>() { + api.findPetsByStatus(Arrays.asList(new String[]{"available"})).subscribe(new SkeletonSubscriber>() { @Override public void onNext(List pets) { assertNotNull(pets); @@ -117,7 +116,7 @@ public class PetApiTest { api.updatePet(pet).subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { - api.findPetsByTags(new CSVParams("friendly")).subscribe(new SkeletonSubscriber>() { + api.findPetsByTags(Arrays.asList(new String[]{"friendly"})).subscribe(new SkeletonSubscriber>() { @Override public void onNext(List pets) { assertNotNull(pets); @@ -146,7 +145,7 @@ public class PetApiTest { api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { @Override public void onNext(final Pet fetched) { - api.updatePetWithForm(fetched.getId(), "furt", null) + api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null) .subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { @@ -202,7 +201,7 @@ public class PetApiTest { api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file); - api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { + api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { @Override public void onError(Throwable e) { // this also yields a 400 for other tests, so I guess it's okay... @@ -252,4 +251,4 @@ public class PetApiTest { return pet; } -} +} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java index f5a34eab200..39785f755ca 100644 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -36,7 +36,7 @@ public class StoreApiTest { public void testPlaceOrder() throws Exception { final Order order = createOrder(); api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { + api.getOrderById(String.valueOf(order.getId())).subscribe(new SkeletonSubscriber() { @Override public void onNext(Order fetched) { assertEquals(order.getId(), fetched.getId()); @@ -51,7 +51,7 @@ public class StoreApiTest { final Order order = createOrder(); api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { + api.getOrderById(String.valueOf(order.getId())).subscribe(new SkeletonSubscriber() { @Override public void onNext(Order fetched) { assertEquals(fetched.getId(), order.getId()); @@ -60,7 +60,7 @@ public class StoreApiTest { api.deleteOrder(String.valueOf(order.getId())).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()) + api.getOrderById(String.valueOf(order.getId())) .subscribe(new SkeletonSubscriber() { @Override public void onNext(Order order) { From fb04bb7d4d14ed1a39665576017517412a3ec217 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 10:13:54 +0800 Subject: [PATCH 23/63] Revert "Revert "[Java] Add auto-generated documentation in Markdown to Java clients"" --- bin/java-petstore-all.sh | 1 + bin/java-petstore-feign.sh | 2 +- bin/java-petstore-jersey2.sh | 2 +- bin/java-petstore-okhttp-gson.sh | 2 +- bin/java-petstore-retrofit.sh | 2 +- bin/java-petstore-retrofit2.sh | 2 +- bin/java-petstore-retrofit2rx.sh | 2 +- bin/java-petstore.sh | 2 +- .../XhhGitIgnore/sdk_unit_testing_binary.json | 67 +++ .../sdk_unit_testing_file_downloading.json | 30 ++ .../codegen/languages/JavaClientCodegen.java | 104 +++- .../languages/JavascriptClientCodegen.java | 20 - .../src/main/resources/Java/README.mustache | 119 ++++- .../src/main/resources/Java/api_doc.mustache | 82 ++++ .../resources/Java/enum_outer_doc.mustache | 7 + .../Java/libraries/feign/README.mustache | 43 ++ .../okhttp-gson/enum_outer_doc.mustache | 7 + .../libraries/okhttp-gson/model_doc.mustache | 3 + .../Java/libraries/retrofit/README.mustache | 43 ++ .../Java/libraries/retrofit2/README.mustache | 43 ++ .../main/resources/Java/model_doc.mustache | 3 + .../src/main/resources/Java/pojo_doc.mustache | 15 + .../resources/Javascript/api_doc.mustache | 20 +- .../client/petstore/java/default/README.md | 162 ++++++- .../petstore/java/default/docs/Animal.md | 10 + .../petstore/java/default/docs/ApiResponse.md | 12 + .../client/petstore/java/default/docs/Cat.md | 11 + .../petstore/java/default/docs/Category.md | 11 + .../client/petstore/java/default/docs/Dog.md | 11 + .../petstore/java/default/docs/FormatTest.md | 21 + .../java/default/docs/InlineResponse200.md | 24 + .../java/default/docs/Model200Response.md | 10 + .../java/default/docs/ModelApiResponse.md | 12 + .../petstore/java/default/docs/ModelReturn.md | 10 + .../client/petstore/java/default/docs/Name.md | 11 + .../petstore/java/default/docs/Order.md | 24 + .../client/petstore/java/default/docs/Pet.md | 24 + .../petstore/java/default/docs/PetApi.md | 448 ++++++++++++++++++ .../java/default/docs/SpecialModelName.md | 10 + .../petstore/java/default/docs/StoreApi.md | 197 ++++++++ .../client/petstore/java/default/docs/Tag.md | 11 + .../client/petstore/java/default/docs/User.md | 17 + .../petstore/java/default/docs/UserApi.md | 370 +++++++++++++++ .../java/io/swagger/client/api/PetApi.java | 188 ++------ .../java/io/swagger/client/api/StoreApi.java | 93 +--- .../java/io/swagger/client/api/UserApi.java | 60 ++- .../client/model/InlineResponse200.java | 198 -------- .../client/model/ModelApiResponse.java | 113 +++++ .../java/io/swagger/client/model/Order.java | 12 +- .../java/io/swagger/PetstoreProfiling.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 4 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- samples/client/petstore/java/feign/README.md | 2 +- .../io/swagger/client/FormAwareEncoder.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 63 +-- .../java/io/swagger/client/api/StoreApi.java | 31 +- .../java/io/swagger/client/api/UserApi.java | 14 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 113 +++++ .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 2 +- .../java/io/swagger/client/model/Order.java | 14 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 2 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../client/petstore/java/jersey2/README.md | 159 ++++++- .../petstore/java/jersey2/docs/Animal.md | 10 + .../petstore/java/jersey2/docs/ApiResponse.md | 12 + .../client/petstore/java/jersey2/docs/Cat.md | 11 + .../petstore/java/jersey2/docs/Category.md | 11 + .../client/petstore/java/jersey2/docs/Dog.md | 11 + .../petstore/java/jersey2/docs/FormatTest.md | 21 + .../java/jersey2/docs/InlineResponse200.md | 13 + .../java/jersey2/docs/Model200Response.md | 10 + .../java/jersey2/docs/ModelApiResponse.md | 12 + .../petstore/java/jersey2/docs/ModelReturn.md | 10 + .../client/petstore/java/jersey2/docs/Name.md | 11 + .../petstore/java/jersey2/docs/Order.md | 24 + .../client/petstore/java/jersey2/docs/Pet.md | 24 + .../petstore/java/jersey2/docs/PetApi.md | 448 ++++++++++++++++++ .../java/jersey2/docs/SpecialModelName.md | 10 + .../petstore/java/jersey2/docs/StoreApi.md | 197 ++++++++ .../client/petstore/java/jersey2/docs/Tag.md | 11 + .../client/petstore/java/jersey2/docs/User.md | 17 + .../petstore/java/jersey2/docs/UserApi.md | 370 +++++++++++++++ .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/JSON.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 190 ++------ .../java/io/swagger/client/api/StoreApi.java | 95 +--- .../java/io/swagger/client/api/UserApi.java | 62 ++- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/InlineResponse200.java | 198 -------- .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 113 +++++ .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 2 +- .../java/io/swagger/client/model/Order.java | 14 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../io/swagger/petstore/test/PetApiTest.java | 4 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- .../petstore/java/okhttp-gson/README.md | 162 ++++++- .../petstore/java/okhttp-gson/docs/Animal.md | 10 + .../java/okhttp-gson/docs/ApiResponse.md | 12 + .../petstore/java/okhttp-gson/docs/Cat.md | 11 + .../java/okhttp-gson/docs/Category.md | 11 + .../petstore/java/okhttp-gson/docs/Dog.md | 11 + .../java/okhttp-gson/docs/FormatTest.md | 21 + .../okhttp-gson/docs/InlineResponse200.md | 24 + .../java/okhttp-gson/docs/Model200Response.md | 10 + .../java/okhttp-gson/docs/ModelApiResponse.md | 12 + .../java/okhttp-gson/docs/ModelReturn.md | 10 + .../petstore/java/okhttp-gson/docs/Name.md | 11 + .../petstore/java/okhttp-gson/docs/Order.md | 24 + .../petstore/java/okhttp-gson/docs/Pet.md | 24 + .../petstore/java/okhttp-gson/docs/PetApi.md | 448 ++++++++++++++++++ .../java/okhttp-gson/docs/SpecialModelName.md | 10 + .../java/okhttp-gson/docs/StoreApi.md | 197 ++++++++ .../petstore/java/okhttp-gson/docs/Tag.md | 11 + .../petstore/java/okhttp-gson/docs/User.md | 17 + .../petstore/java/okhttp-gson/docs/UserApi.md | 370 +++++++++++++++ .../java/io/swagger/client/ApiClient.java | 5 - .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 423 +++-------------- .../java/io/swagger/client/api/StoreApi.java | 232 +-------- .../java/io/swagger/client/api/UserApi.java | 84 ++-- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../client/model/InlineResponse200.java | 168 ------- .../client/model/ModelApiResponse.java | 96 ++++ .../java/io/swagger/client/model/Order.java | 5 +- .../java/io/swagger/client/ApiClientTest.java | 2 + .../io/swagger/petstore/test/PetApiTest.java | 6 +- .../swagger/petstore/test/StoreApiTest.java | 8 +- .../client/petstore/java/retrofit/README.md | 2 +- .../java/io/swagger/client/ApiClient.java | 6 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 119 +---- .../java/io/swagger/client/api/StoreApi.java | 55 +-- .../java/io/swagger/client/api/UserApi.java | 24 +- .../client/model/InlineResponse200.java | 168 ------- .../client/model/ModelApiResponse.java | 96 ++++ .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 9 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../java/io/swagger/client/ApiClient.java | 8 - .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 62 +-- .../java/io/swagger/client/api/StoreApi.java | 26 +- .../java/io/swagger/client/api/UserApi.java | 12 +- .../client/model/InlineResponse200.java | 168 ------- .../client/model/ModelApiResponse.java | 96 ++++ .../io/swagger/client/model/ObjectReturn.java | 69 --- .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 7 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- .../java/io/swagger/client/ApiClient.java | 8 - .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 62 +-- .../java/io/swagger/client/api/StoreApi.java | 26 +- .../java/io/swagger/client/api/UserApi.java | 12 +- .../client/model/InlineResponse200.java | 168 ------- .../client/model/ModelApiResponse.java | 96 ++++ .../io/swagger/client/model/ObjectReturn.java | 69 --- .../java/io/swagger/client/model/Order.java | 5 +- .../io/swagger/petstore/test/PetApiTest.java | 11 +- .../swagger/petstore/test/StoreApiTest.java | 6 +- 191 files changed, 6103 insertions(+), 2856 deletions(-) create mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json create mode 100644 modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json create mode 100644 modules/swagger-codegen/src/main/resources/Java/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/model_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache create mode 100644 samples/client/petstore/java/default/docs/Animal.md create mode 100644 samples/client/petstore/java/default/docs/ApiResponse.md create mode 100644 samples/client/petstore/java/default/docs/Cat.md create mode 100644 samples/client/petstore/java/default/docs/Category.md create mode 100644 samples/client/petstore/java/default/docs/Dog.md create mode 100644 samples/client/petstore/java/default/docs/FormatTest.md create mode 100644 samples/client/petstore/java/default/docs/InlineResponse200.md create mode 100644 samples/client/petstore/java/default/docs/Model200Response.md create mode 100644 samples/client/petstore/java/default/docs/ModelApiResponse.md create mode 100644 samples/client/petstore/java/default/docs/ModelReturn.md create mode 100644 samples/client/petstore/java/default/docs/Name.md create mode 100644 samples/client/petstore/java/default/docs/Order.md create mode 100644 samples/client/petstore/java/default/docs/Pet.md create mode 100644 samples/client/petstore/java/default/docs/PetApi.md create mode 100644 samples/client/petstore/java/default/docs/SpecialModelName.md create mode 100644 samples/client/petstore/java/default/docs/StoreApi.md create mode 100644 samples/client/petstore/java/default/docs/Tag.md create mode 100644 samples/client/petstore/java/default/docs/User.md create mode 100644 samples/client/petstore/java/default/docs/UserApi.md delete mode 100644 samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/jersey2/docs/Animal.md create mode 100644 samples/client/petstore/java/jersey2/docs/ApiResponse.md create mode 100644 samples/client/petstore/java/jersey2/docs/Cat.md create mode 100644 samples/client/petstore/java/jersey2/docs/Category.md create mode 100644 samples/client/petstore/java/jersey2/docs/Dog.md create mode 100644 samples/client/petstore/java/jersey2/docs/FormatTest.md create mode 100644 samples/client/petstore/java/jersey2/docs/InlineResponse200.md create mode 100644 samples/client/petstore/java/jersey2/docs/Model200Response.md create mode 100644 samples/client/petstore/java/jersey2/docs/ModelApiResponse.md create mode 100644 samples/client/petstore/java/jersey2/docs/ModelReturn.md create mode 100644 samples/client/petstore/java/jersey2/docs/Name.md create mode 100644 samples/client/petstore/java/jersey2/docs/Order.md create mode 100644 samples/client/petstore/java/jersey2/docs/Pet.md create mode 100644 samples/client/petstore/java/jersey2/docs/PetApi.md create mode 100644 samples/client/petstore/java/jersey2/docs/SpecialModelName.md create mode 100644 samples/client/petstore/java/jersey2/docs/StoreApi.md create mode 100644 samples/client/petstore/java/jersey2/docs/Tag.md create mode 100644 samples/client/petstore/java/jersey2/docs/User.md create mode 100644 samples/client/petstore/java/jersey2/docs/UserApi.md delete mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Animal.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Cat.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Category.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Dog.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/FormatTest.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Model200Response.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Name.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Order.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Pet.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/PetApi.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/StoreApi.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/Tag.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/User.md create mode 100644 samples/client/petstore/java/okhttp-gson/docs/UserApi.md delete mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java diff --git a/bin/java-petstore-all.sh b/bin/java-petstore-all.sh index 635e8523edb..143ebc819c5 100755 --- a/bin/java-petstore-all.sh +++ b/bin/java-petstore-all.sh @@ -7,3 +7,4 @@ ./bin/java-petstore-okhttp-gson.sh ./bin/java-petstore-retrofit.sh ./bin/java-petstore-retrofit2.sh +./bin/java-petstore-retrofit2rx.sh diff --git a/bin/java-petstore-feign.sh b/bin/java-petstore-feign.sh index 6f0a5fdf8ff..063b85f70a1 100755 --- a/bin/java-petstore-feign.sh +++ b/bin/java-petstore-feign.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-jersey2.sh b/bin/java-petstore-jersey2.sh index cb51c1e1a8d..a715e7ff545 100755 --- a/bin/java-petstore-jersey2.sh +++ b/bin/java-petstore-jersey2.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-okhttp-gson.sh b/bin/java-petstore-okhttp-gson.sh index 17a48ddee53..f656624a6c6 100755 --- a/bin/java-petstore-okhttp-gson.sh +++ b/bin/java-petstore-okhttp-gson.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit.sh b/bin/java-petstore-retrofit.sh index d9228fb2eca..db4001e4c9e 100755 --- a/bin/java-petstore-retrofit.sh +++ b/bin/java-petstore-retrofit.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit2.sh b/bin/java-petstore-retrofit2.sh index fbd1f9779e4..3fda4df3166 100755 --- a/bin/java-petstore-retrofit2.sh +++ b/bin/java-petstore-retrofit2.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2.json -o samples/client/petstore/java/retrofit2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore-retrofit2rx.sh b/bin/java-petstore-retrofit2rx.sh index b0320644142..d714cc33455 100755 --- a/bin/java-petstore-retrofit2rx.sh +++ b/bin/java-petstore-retrofit2rx.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-retrofit2rx.json -o samples/client/petstore/java/retrofit2rx -DuseRxJava=true" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/java-petstore.sh b/bin/java-petstore.sh index 17a1b0d6b98..ed80c841df6 100755 --- a/bin/java-petstore.sh +++ b/bin/java-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json new file mode 100644 index 00000000000..2d87e3bcb7f --- /dev/null +++ b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_binary.json @@ -0,0 +1,67 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "SDK Unit Testing - File Downloading" + }, + "schemes": [ + "http" + ], + "host": "localhost:3000", + "basePath": "/unittesting", + "paths": { + "/request/file_uploading": { + "get": { + "operationId": "file_uploading", + "tags": [ + "Request" + ], + "parameters": [ + {"name": "f1", + "in": "formData", + "type": "string", + "format": "binary", + "required": true + }, + {"name": "f2", + "in": "formData", + "type": "string", + "format": "binary", + "required": false + } + ], + "consumes": [ + "multipart/form-data" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, + "/response/file_downloading": { + "get": { + "operationId": "file_downloading", + "tags": [ + "Response" + ], + "produces": [ + "multipart/form-data" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } +} diff --git a/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json new file mode 100644 index 00000000000..6169272c05d --- /dev/null +++ b/modules/swagger-codegen/XhhGitIgnore/sdk_unit_testing_file_downloading.json @@ -0,0 +1,30 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "SDK Unit Testing - File Downloading" + }, + "schemes": [ + "http" + ], + "host": "localhost:3000", + "basePath": "/unittesting", + "paths": { + "/response/file_downloading": { + "get": { + "operationId": "file_downloading", + "tags": [ + "Response" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "file" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 380a1eee2a1..9fe2b6fc370 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -43,7 +43,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { protected boolean serializeBigDecimalAsString = false; protected boolean useRxJava = false; protected boolean hideGenerationTimestamp = false; - + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public JavaClientCodegen() { super(); @@ -60,6 +61,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { "localVarPath", "localVarQueryParams", "localVarHeaderParams", "localVarFormParams", "localVarPostBody", "localVarAccepts", "localVarAccept", "localVarContentTypes", "localVarContentType", "localVarAuthNames", "localReturnType", + "ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil", // language reserved words "abstract", "continue", "for", "new", "switch", "assert", @@ -208,6 +210,10 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put(FULL_JAVA_UTIL, fullJavaUtil); additionalProperties.put("javaUtilPrefix", javaUtilPrefix); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + importMapping.put("List", "java.util.List"); if (fullJavaUtil) { @@ -269,7 +275,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } // library-specific files - if ("okhttp-gson".equals(getLibrary())) { + if (StringUtils.isEmpty(getLibrary())) { + // generate markdown docs + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); + } else if ("okhttp-gson".equals(getLibrary())) { + // generate markdown docs + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java")); @@ -282,6 +295,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java")); supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java")); } else if("jersey2".equals(getLibrary())) { + // generate markdown docs + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); } @@ -353,6 +369,26 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/'); } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + @Override public String toVarName(String name) { // sanitize name @@ -497,6 +533,70 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { return super.toDefaultValue(p); } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equals(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "\"" + escapeText(example) + "\""; + } else if ("Integer".equals(type) || "Short".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Long".equals(type)) { + if (example == null) { + example = "56"; + } + example = example + "L"; + } else if ("Float".equals(type)) { + if (example == null) { + example = "3.4"; + } + example = example + "F"; + } else if ("Double".equals(type)) { + example = "3.4"; + example = example + "D"; + } else if ("Boolean".equals(type)) { + if (example == null) { + example = "true"; + } + } else if ("File".equals(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "new File(\"" + escapeText(example) + "\")"; + } else if ("Date".equals(type)) { + example = "new Date()"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = "new " + type + "()"; + } + + if (example == null) { + example = "null"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "Arrays.asList(" + example + ")"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "new HashMap()"; + } + + p.example = example; + } + @Override public String getSwaggerType(Property p) { String swaggerType = super.getSwaggerType(p); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index d2d3808f8eb..846796e3b8f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -524,26 +524,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo type = p.dataType; } - typeMapping.put("array", "Array"); - typeMapping.put("List", "Array"); - typeMapping.put("map", "Object"); - typeMapping.put("object", "Object"); - typeMapping.put("boolean", "Boolean"); - typeMapping.put("char", "String"); - typeMapping.put("string", "String"); - typeMapping.put("short", "Integer"); - typeMapping.put("int", "Integer"); - typeMapping.put("integer", "Integer"); - typeMapping.put("long", "Integer"); - typeMapping.put("float", "Number"); - typeMapping.put("double", "Number"); - typeMapping.put("number", "Number"); - typeMapping.put("DateTime", "Date"); - typeMapping.put("Date", "Date"); - typeMapping.put("file", "File"); - // binary not supported in JavaScript client right now, using String as a workaround - typeMapping.put("binary", "String"); - if ("String".equals(type)) { if (example == null) { example = p.paramName + "_example"; diff --git a/modules/swagger-codegen/src/main/resources/Java/README.mustache b/modules/swagger-codegen/src/main/resources/Java/README.mustache index 50e2cf3fbe9..f3b766a67d8 100644 --- a/modules/swagger-codegen/src/main/resources/Java/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/README.mustache @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation & Usage +## Installation To install the API client library to your local Maven repository, simply execute: @@ -20,18 +20,124 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +### Maven users + +Add this dependency to your project's POM: ```xml - {{groupId}} - {{artifactId}} - {{artifactVersion}} + {{{groupId}}} + {{{artifactId}}} + {{{artifactVersion}}} compile - ``` +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}" +``` + +### Others + +At first generate the JAR by executing: + + mvn package + +Then manually install the following JARs: + +* target/{{{artifactId}}}-{{{artifactVersion}}}.jar +* target/lib/*.jar + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +import {{{invokerPackage}}}.*; +import {{{invokerPackage}}}.auth.*; +import {{{invokerPackage}}}.model.*; +import {{{package}}}.{{{classname}}}; + +import java.io.File; +import java.util.*; + +public class {{{classname}}}Example { + + public static void main(String[] args) { + {{#hasAuthMethods}}ApiClient defaultClient = Configuration.getDefaultApiClient(); + {{#authMethods}}{{#isBasic}} + // Configure HTTP basic authorization: {{{name}}} + HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); + {{{name}}}.setUsername("YOUR USERNAME"); + {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} + // Configure API key authorization: {{{name}}} + ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); + {{{name}}}.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} + // Configure OAuth2 access token for authorization: {{{name}}} + OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); + {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} + {{/authMethods}} + {{/hasAuthMethods}} + + {{{classname}}} apiInstance = new {{{classname}}}(); + {{#allParams}} + {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} + {{/allParams}} + try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} + } catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); + } + } +} +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation for Models + +{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +## Documentation for Authorization + +{{^authMethods}}All endpoints do not require authorization. +{{/authMethods}}Authentication schemes defined for the API: +{{#authMethods}}### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorizatoin URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -40,4 +146,3 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} {{/hasMore}}{{/apis}}{{/apiInfo}} - diff --git a/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache new file mode 100644 index 00000000000..93c5bc5b13a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache new file mode 100644 index 00000000000..14b5d524c4a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/enum_outer_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}} +* `{{.}}` +{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache new file mode 100644 index 00000000000..50e2cf3fbe9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/README.mustache @@ -0,0 +1,43 @@ +# {{artifactId}} + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation & Usage + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: + +```xml + + {{groupId}} + {{artifactId}} + {{artifactVersion}} + compile + + +``` + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache new file mode 100644 index 00000000000..a7e706eba4e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/enum_outer_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{value}}`) +{{#enumVars}}{{/allowableValues}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache new file mode 100644 index 00000000000..a3703db3bf9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model_doc.mustache @@ -0,0 +1,3 @@ +{{#models}}{{#model}} +{{#isEnum}}{{>libraries/okhttp-gson/enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache new file mode 100644 index 00000000000..50e2cf3fbe9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/README.mustache @@ -0,0 +1,43 @@ +# {{artifactId}} + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation & Usage + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: + +```xml + + {{groupId}} + {{artifactId}} + {{artifactVersion}} + compile + + +``` + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache new file mode 100644 index 00000000000..50e2cf3fbe9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/README.mustache @@ -0,0 +1,43 @@ +# {{artifactId}} + +## Requirements + +Building the API client library requires [Maven](https://maven.apache.org/) to be installed. + +## Installation & Usage + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn deploy +``` + +Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. + +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: + +```xml + + {{groupId}} + {{artifactId}} + {{artifactVersion}} + compile + + +``` + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} + diff --git a/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache new file mode 100644 index 00000000000..658df8d5322 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/model_doc.mustache @@ -0,0 +1,3 @@ +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache new file mode 100644 index 00000000000..0e4c0749866 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache index 714350a2170..f5aad995da5 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/api_doc.mustache @@ -12,7 +12,7 @@ Method | HTTP request | Description {{#operation}} # **{{operationId}}** -> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}{{#hasParams}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}){{/hasParams}} +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}) {{summary}}{{#notes}} @@ -26,25 +26,25 @@ var defaultClient = {{{moduleName}}}.ApiClient.default; {{#authMethods}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.username = 'YOUR USERNAME' -{{{name}}}.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} +{{{name}}}.username = 'YOUR USERNAME'; +{{{name}}}.password = 'YOUR PASSWORD';{{/isBasic}}{{#isApiKey}} // Configure API key authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.apiKey = "YOUR API KEY" +{{{name}}}.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) -//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}} +//{{{name}}}.apiKeyPrefix = 'Token';{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}} +{{{name}}}.accessToken = 'YOUR ACCESS TOKEN';{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} -var apiInstance = new {{{moduleName}}}.{{{classname}}}(){{#hasParams}} +var apiInstance = new {{{moduleName}}}.{{{classname}}}();{{#hasParams}} {{#vendorExtensions.x-codegen-hasRequiredParams}}{{#allParams}}{{#required}} -var {{{paramName}}} = {{{example}}}; // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}} +var {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} {{/required}}{{/allParams}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}} var opts = { {{#allParams}}{{^required}} - '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{=< >=}}{<&dataType>}<={{ }}=> {{{description}}}{{/required}}{{/allParams}} + '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{{dataType}}} | {{{description}}}{{/required}}{{/allParams}} };{{/hasOptionalParams}}{{/hasParams}} {{#usePromises}} apiInstance.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}).then(function({{#returnType}}data{{/returnType}}) { @@ -61,7 +61,7 @@ var callback = function(error, data, response) { {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} } }; -api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback); +apiInstance.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback); {{/usePromises}} ``` diff --git a/samples/client/petstore/java/default/README.md b/samples/client/petstore/java/default/README.md index cc9672eab41..562d76a8db4 100644 --- a/samples/client/petstore/java/default/README.md +++ b/samples/client/petstore/java/default/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation & Usage +## Installation To install the API client library to your local Maven repository, simply execute: @@ -20,7 +20,9 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +### Maven users + +Add this dependency to your project's POM: ```xml @@ -29,9 +31,164 @@ After the client library is installed/deployed, you can use it in your Maven pro 1.0.0 compile +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "io.swagger:swagger-java-client:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + + mvn package + +Then manually install the following JARs: + +* target/swagger-java-client-1.0.0.jar +* target/lib/*.jar + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import io.swagger.client.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; +import io.swagger.client.api.PetApi; + +import java.io.File; +import java.util.*; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + + + PetApi apiInstance = new PetApi(); + + Pet body = new Pet(); // Pet | Pet object that needs to be added to the store + + try { + apiInstance.addPet(body); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); + } + } +} ``` +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) + - [Category](docs/Category.md) + - [Dog](docs/Dog.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation for Authorization + +Authentication schemes defined for the API: +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + +### test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +### test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### test_http_basic + +- **Type**: HTTP basic authentication + +### test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +### test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + + ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -40,4 +197,3 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io - diff --git a/samples/client/petstore/java/default/docs/Animal.md b/samples/client/petstore/java/default/docs/Animal.md new file mode 100644 index 00000000000..3ecb7f991f3 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Animal.md @@ -0,0 +1,10 @@ + +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | + + + diff --git a/samples/client/petstore/java/default/docs/ApiResponse.md b/samples/client/petstore/java/default/docs/ApiResponse.md new file mode 100644 index 00000000000..1c17767c2b7 --- /dev/null +++ b/samples/client/petstore/java/default/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/Cat.md b/samples/client/petstore/java/default/docs/Cat.md new file mode 100644 index 00000000000..373af540c41 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Cat.md @@ -0,0 +1,11 @@ + +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**declawed** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/Category.md b/samples/client/petstore/java/default/docs/Category.md new file mode 100644 index 00000000000..e2df0803278 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/Dog.md b/samples/client/petstore/java/default/docs/Dog.md new file mode 100644 index 00000000000..a1d638d3bad --- /dev/null +++ b/samples/client/petstore/java/default/docs/Dog.md @@ -0,0 +1,11 @@ + +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**breed** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/FormatTest.md b/samples/client/petstore/java/default/docs/FormatTest.md new file mode 100644 index 00000000000..8e400e7bcd7 --- /dev/null +++ b/samples/client/petstore/java/default/docs/FormatTest.md @@ -0,0 +1,21 @@ + +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **Integer** | | [optional] +**int32** | **Integer** | | [optional] +**int64** | **Long** | | [optional] +**number** | [**BigDecimal**](BigDecimal.md) | | +**_float** | **Float** | | [optional] +**_double** | **Double** | | [optional] +**string** | **String** | | [optional] +**_byte** | **byte[]** | | [optional] +**binary** | **byte[]** | | [optional] +**date** | [**Date**](Date.md) | | [optional] +**dateTime** | [**Date**](Date.md) | | [optional] +**password** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/InlineResponse200.md b/samples/client/petstore/java/default/docs/InlineResponse200.md new file mode 100644 index 00000000000..487ebe429e4 --- /dev/null +++ b/samples/client/petstore/java/default/docs/InlineResponse200.md @@ -0,0 +1,24 @@ + +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photoUrls** | **List<String>** | | [optional] +**name** | **String** | | [optional] +**id** | **Long** | | +**category** | **Object** | | [optional] +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | available +PENDING | pending +SOLD | sold + + + diff --git a/samples/client/petstore/java/default/docs/Model200Response.md b/samples/client/petstore/java/default/docs/Model200Response.md new file mode 100644 index 00000000000..0819b88c4f4 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Model200Response.md @@ -0,0 +1,10 @@ + +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/ModelApiResponse.md b/samples/client/petstore/java/default/docs/ModelApiResponse.md new file mode 100644 index 00000000000..3eec8686cc9 --- /dev/null +++ b/samples/client/petstore/java/default/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ + +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/ModelReturn.md b/samples/client/petstore/java/default/docs/ModelReturn.md new file mode 100644 index 00000000000..a679b04953e --- /dev/null +++ b/samples/client/petstore/java/default/docs/ModelReturn.md @@ -0,0 +1,10 @@ + +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/Name.md b/samples/client/petstore/java/default/docs/Name.md new file mode 100644 index 00000000000..a1adac1dd39 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Name.md @@ -0,0 +1,11 @@ + +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | +**snakeCase** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/Order.md b/samples/client/petstore/java/default/docs/Order.md new file mode 100644 index 00000000000..b1709c14eee --- /dev/null +++ b/samples/client/petstore/java/default/docs/Order.md @@ -0,0 +1,24 @@ + +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**petId** | **Long** | | [optional] +**quantity** | **Integer** | | [optional] +**shipDate** | [**Date**](Date.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] +**complete** | **Boolean** | | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +PLACED | placed +APPROVED | approved +DELIVERED | delivered + + + diff --git a/samples/client/petstore/java/default/docs/Pet.md b/samples/client/petstore/java/default/docs/Pet.md new file mode 100644 index 00000000000..20a1c298dd6 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Pet.md @@ -0,0 +1,24 @@ + +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | available +PENDING | pending +SOLD | sold + + + diff --git a/samples/client/petstore/java/default/docs/PetApi.md b/samples/client/petstore/java/default/docs/PetApi.md new file mode 100644 index 00000000000..e0314e20e51 --- /dev/null +++ b/samples/client/petstore/java/default/docs/PetApi.md @@ -0,0 +1,448 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.addPet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | Pet id to delete +String apiKey = "apiKey_example"; // String | +try { + apiInstance.deletePet(petId, apiKey); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByStatus** +> List<Pet> findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter +try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> List<Pet> findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List tags = Arrays.asList("tags_example"); // List | Tags to filter by +try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to return +try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.updatePet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet that needs to be updated +String name = "name_example"; // String | Updated name of the pet +String status = "status_example"; // String | Updated status of the pet +try { + apiInstance.updatePetWithForm(petId, name, status); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + + +# **uploadFile** +> ModelApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to update +String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server +File file = new File("/path/to/file.txt"); // File | file to upload +try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/default/docs/SpecialModelName.md b/samples/client/petstore/java/default/docs/SpecialModelName.md new file mode 100644 index 00000000000..c2c6117c552 --- /dev/null +++ b/samples/client/petstore/java/default/docs/SpecialModelName.md @@ -0,0 +1,10 @@ + +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **Long** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/StoreApi.md b/samples/client/petstore/java/default/docs/StoreApi.md new file mode 100644 index 00000000000..0b30791725a --- /dev/null +++ b/samples/client/petstore/java/default/docs/StoreApi.md @@ -0,0 +1,197 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +String orderId = "orderId_example"; // String | ID of the order that needs to be deleted +try { + apiInstance.deleteOrder(orderId); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getInventory** +> Map<String, Integer> getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.StoreApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +StoreApi apiInstance = new StoreApi(); +try { + Map result = apiInstance.getInventory(); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**Map<String, Integer>**](Map.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Long orderId = 789L; // Long | ID of pet that needs to be fetched +try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **Long**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Order body = new Order(); // Order | order placed for purchasing the pet +try { + Order result = apiInstance.placeOrder(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/default/docs/Tag.md b/samples/client/petstore/java/default/docs/Tag.md new file mode 100644 index 00000000000..de6814b55d5 --- /dev/null +++ b/samples/client/petstore/java/default/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/User.md b/samples/client/petstore/java/default/docs/User.md new file mode 100644 index 00000000000..8b6753dd284 --- /dev/null +++ b/samples/client/petstore/java/default/docs/User.md @@ -0,0 +1,17 @@ + +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **Integer** | User Status | [optional] + + + diff --git a/samples/client/petstore/java/default/docs/UserApi.md b/samples/client/petstore/java/default/docs/UserApi.md new file mode 100644 index 00000000000..8cdc15992ee --- /dev/null +++ b/samples/client/petstore/java/default/docs/UserApi.md @@ -0,0 +1,370 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +User body = new User(); // User | Created user object +try { + apiInstance.createUser(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithArrayInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithListInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be deleted +try { + apiInstance.deleteUser(username); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. +try { + User result = apiInstance.getUserByName(username); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The user name for login +String password = "password_example"; // String | The password for login in clear text +try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +try { + apiInstance.logoutUser(); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | name that need to be deleted +User body = new User(); // User | Updated user object +try { + apiInstance.updateUser(username, body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index fdc5110304f..584c85aaae4 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -39,12 +39,17 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException if fails to make API call */ public void addPet(Pet body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -57,42 +62,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - "application/json", "application/xml" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "petstore_auth" }; - - - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); - } - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @throws ApiException if fails to make API call - */ - public void addPetUsingByteArray(byte[] body) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -136,7 +106,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -153,13 +123,18 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return List * @throws ApiException if fails to make API call */ public List findPetsByStatus(List status) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -168,12 +143,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -189,14 +164,19 @@ public class PetApi { } /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return List * @throws ApiException if fails to make API call */ public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -205,12 +185,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -226,8 +206,8 @@ public class PetApi { } /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Pet * @throws ApiException if fails to make API call */ @@ -252,7 +232,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -261,104 +241,25 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + String[] localVarAuthNames = new String[] { "api_key" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return InlineResponse200 - * @throws ApiException if fails to make API call - */ - public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); - } - - // create path and map variables - String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return byte[] - * @throws ApiException if fails to make API call - */ - public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); - } - - // create path and map variables - String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException if fails to make API call */ public void updatePet(Pet body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -371,7 +272,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -393,7 +294,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException if fails to make API call */ - public void updatePetWithForm(String petId, String name, String status) throws ApiException { + public void updatePetWithForm(Long petId, String name, String status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -418,7 +319,7 @@ if (status != null) localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -438,9 +339,10 @@ if (status != null) * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) + * @return ModelApiResponse * @throws ApiException if fails to make API call */ - public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -465,7 +367,7 @@ if (file != null) localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -476,7 +378,7 @@ if (file != null) String[] localVarAuthNames = new String[] { "petstore_auth" }; - - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); - } + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 3f2e38c0e3a..59a1a58266e 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -61,7 +61,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -75,43 +75,6 @@ public class StoreApi { apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List - * @throws ApiException if fails to make API call - */ - public List findOrdersByStatus(String status) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; - - GenericType> localVarReturnType = new GenericType>() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -133,7 +96,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -147,41 +110,6 @@ public class StoreApi { GenericType> localVarReturnType = new GenericType>() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Object - * @throws ApiException if fails to make API call - */ - public Object getInventoryInObject() throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -189,7 +117,7 @@ public class StoreApi { * @return Order * @throws ApiException if fails to make API call */ - public Order getOrderById(String orderId) throws ApiException { + public Order getOrderById(Long orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -210,7 +138,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -219,7 +147,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; + String[] localVarAuthNames = new String[] { }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); @@ -227,13 +155,18 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Order * @throws ApiException if fails to make API call */ public Order placeOrder(Order body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); + } + // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -246,7 +179,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -255,7 +188,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + String[] localVarAuthNames = new String[] { }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index 600ad0b678a..7ab75eabd34 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -37,12 +37,17 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @throws ApiException if fails to make API call */ public void createUser(User body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); + } + // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -55,7 +60,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -72,12 +77,17 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(List body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); + } + // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -90,7 +100,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -107,12 +117,17 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException if fails to make API call */ public void createUsersWithListInput(List body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); + } + // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -125,7 +140,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -166,7 +181,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -175,7 +190,7 @@ public class UserApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_http_basic" }; + String[] localVarAuthNames = new String[] { }; apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); @@ -208,7 +223,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -225,14 +240,24 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String * @throws ApiException if fails to make API call */ public String loginUser(String username, String password) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -247,7 +272,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -281,7 +306,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -299,7 +324,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @throws ApiException if fails to make API call */ public void updateUser(String username, User body) throws ApiException { @@ -310,6 +335,11 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); + } + // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -323,7 +353,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index ee6afefe265..00000000000 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,198 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - - - - - - -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - - /** - **/ - public InlineResponse200 tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - **/ - public InlineResponse200 id(Long id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", required = true, value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - public InlineResponse200 category(Object category) { - this.category = category; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - * pet status in the store - **/ - public InlineResponse200 status(StatusEnum status) { - this.status = status; - return this; - } - - @ApiModelProperty(example = "null", value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - **/ - public InlineResponse200 name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - public InlineResponse200 photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(this.tags, inlineResponse200.tags) && - Objects.equals(this.id, inlineResponse200.id) && - Objects.equals(this.category, inlineResponse200.category) && - Objects.equals(this.status, inlineResponse200.status) && - Objects.equals(this.name, inlineResponse200.name) && - Objects.equals(this.photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..62300f1a0eb --- /dev/null +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,113 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + + +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 43ddec1ff6a..94be5295f5d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -39,14 +39,24 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = null; + private Boolean complete = false; + /** + **/ + public Order id(Long id) { + this.id = id; + return this; + } + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java b/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java index 0c5ef6f1eda..d0be1523e45 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/PetstoreProfiling.java @@ -48,7 +48,7 @@ public class PetstoreProfiling { /* UPDATE PET WITH FORM */ start = System.nanoTime(); - petApi.updatePetWithForm(String.valueOf(newPetId), "new profiler", "sold"); + petApi.updatePetWithForm(newPetId, "new profiler", "sold"); results.add(buildResult(index, "UPDATE PET", System.nanoTime() - start)); /* DELETE PET */ diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java index ad971ea6669..9e927a69ba2 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -73,6 +73,7 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -119,6 +120,7 @@ public class PetApiTest { assertEquals(category.getId(), Long.valueOf(categoryIdInt)); assertEquals(category.getName(), categoryMap.get("name")); } + */ @Test public void testUpdatePet() throws Exception { @@ -191,7 +193,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); + api.updatePetWithForm(fetched.getId(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 403f9b64ec9..4b33d380f14 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -35,6 +35,7 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -47,13 +48,14 @@ public class StoreApiTest { assertTrue(firstEntry.getKey() instanceof String); assertTrue(firstEntry.getValue() instanceof Integer); } + */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -64,13 +66,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(String.valueOf(order.getId())); + api.getOrderById(order.getId()); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/feign/README.md b/samples/client/petstore/java/feign/README.md index 3ca7abfb557..d5d447e2865 100644 --- a/samples/client/petstore/java/feign/README.md +++ b/samples/client/petstore/java/feign/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java index bf9378fc9c1..043861f4e53 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java @@ -14,7 +14,7 @@ import feign.codec.EncodeException; import feign.codec.Encoder; import feign.RequestTemplate; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class FormAwareEncoder implements Encoder { public static final String UTF_8 = "utf-8"; private static final String LINE_FEED = "\r\n"; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java index b8a4d2924f6..6439885ed11 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index 2d5ac8be9ee..e2e1ad0bee6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -3,7 +3,7 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -12,14 +12,14 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") public interface PetApi extends ApiClient.Api { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return void */ @RequestLine("POST /pet") @@ -29,19 +29,6 @@ public interface PetApi extends ApiClient.Api { }) void addPet(Pet body); - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @return void - */ - @RequestLine("POST /pet?testing_byte_array=true") - @Headers({ - "Content-type: application/json", - "Accepts: application/json", - }) - void addPetUsingByteArray(byte[] body); - /** * Deletes a pet * @@ -60,7 +47,7 @@ public interface PetApi extends ApiClient.Api { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return List */ @RequestLine("GET /pet/findByStatus?status={status}") @@ -72,8 +59,8 @@ public interface PetApi extends ApiClient.Api { /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return List */ @RequestLine("GET /pet/findByTags?tags={tags}") @@ -85,8 +72,8 @@ public interface PetApi extends ApiClient.Api { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Pet */ @RequestLine("GET /pet/{petId}") @@ -96,36 +83,10 @@ public interface PetApi extends ApiClient.Api { }) Pet getPetById(@Param("petId") Long petId); - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return InlineResponse200 - */ - @RequestLine("GET /pet/{petId}?response=inline_arbitrary_object") - @Headers({ - "Content-type: application/json", - "Accepts: application/json", - }) - InlineResponse200 getPetByIdInObject(@Param("petId") Long petId); - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return byte[] - */ - @RequestLine("GET /pet/{petId}?testing_byte_array=true") - @Headers({ - "Content-type: application/json", - "Accepts: application/json", - }) - byte[] petPetIdtestingByteArraytrueGet(@Param("petId") Long petId); - /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return void */ @RequestLine("PUT /pet") @@ -148,7 +109,7 @@ public interface PetApi extends ApiClient.Api { "Content-type: application/x-www-form-urlencoded", "Accepts: application/json", }) - void updatePetWithForm(@Param("petId") String petId, @Param("name") String name, @Param("status") String status); + void updatePetWithForm(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); /** * uploads an image @@ -156,12 +117,12 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return void + * @return ModelApiResponse */ @RequestLine("POST /pet/{petId}/uploadImage") @Headers({ "Content-type: multipart/form-data", "Accepts: application/json", }) - void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + ModelApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 0c358eae7df..45c9610c5c0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public interface StoreApi extends ApiClient.Api { @@ -27,19 +27,6 @@ public interface StoreApi extends ApiClient.Api { }) void deleteOrder(@Param("orderId") String orderId); - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List - */ - @RequestLine("GET /store/findByStatus?status={status}") - @Headers({ - "Content-type: application/json", - "Accepts: application/json", - }) - List findOrdersByStatus(@Param("status") String status); - /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -52,18 +39,6 @@ public interface StoreApi extends ApiClient.Api { }) Map getInventory(); - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Object - */ - @RequestLine("GET /store/inventory?response=arbitrary_object") - @Headers({ - "Content-type: application/json", - "Accepts: application/json", - }) - Object getInventoryInObject(); - /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -75,12 +50,12 @@ public interface StoreApi extends ApiClient.Api { "Content-type: application/json", "Accepts: application/json", }) - Order getOrderById(@Param("orderId") String orderId); + Order getOrderById(@Param("orderId") Long orderId); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Order */ @RequestLine("POST /store/order") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index ff46fb078b5..ae731977c6b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -10,14 +10,14 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public interface UserApi extends ApiClient.Api { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @return void */ @RequestLine("POST /user") @@ -30,7 +30,7 @@ public interface UserApi extends ApiClient.Api { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return void */ @RequestLine("POST /user/createWithArray") @@ -43,7 +43,7 @@ public interface UserApi extends ApiClient.Api { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return void */ @RequestLine("POST /user/createWithList") @@ -82,8 +82,8 @@ public interface UserApi extends ApiClient.Api { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String */ @RequestLine("GET /user/login?username={username}&password={password}") @@ -109,7 +109,7 @@ public interface UserApi extends ApiClient.Api { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @return void */ @RequestLine("PUT /user/{username}") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 20987177b52..8e3eb2af935 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index 5312e49f241..3d79c411824 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 7d472b3e71b..66f4830bce0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index 920c9a7ac6c..96d35603bf5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 9917e21724a..9c6b5e35de6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index bcc40ca5b24..41b7842d606 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..91fb6b5b939 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,113 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index 539032cec41..2994e48adaf 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index c29314eb091..e51b32ff5a2 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index e713b75a845..3c0ea427c41 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Order { private Long id = null; @@ -39,14 +39,24 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = null; + private Boolean complete = false; + /** + **/ + public Order id(Long id) { + this.id = id; + return this; + } + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index 2d7a49dd47f..ee4ce28371b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index 51f88ff4306..786d75c976c 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 981302df547..4e323812065 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 5502f018489..23e363a518e 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:33.302+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java index bf068652905..a2e8c34d95e 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -120,7 +120,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(fetched.getId().toString(), "furt", null); + api.updatePetWithForm(fetched.getId(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 32dcd6d0c0e..ca14be28a80 100644 --- a/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/feign/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -35,7 +35,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId().toString()); + Order fetched = api.getOrderById(order.getId()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -46,13 +46,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(order.getId().toString()); + Order fetched = api.getOrderById(order.getId()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(order.getId().toString()); try { - api.getOrderById(order.getId().toString()); + api.getOrderById(order.getId()); fail("expected an error"); } catch (FeignException e) { assertTrue(e.getMessage().startsWith("status 404 ")); diff --git a/samples/client/petstore/java/jersey2/README.md b/samples/client/petstore/java/jersey2/README.md index 930a4f28c55..6b6db099581 100644 --- a/samples/client/petstore/java/jersey2/README.md +++ b/samples/client/petstore/java/jersey2/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation & Usage +## Installation To install the API client library to your local Maven repository, simply execute: @@ -20,7 +20,9 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +### Maven users + +Add this dependency to your project's POM: ```xml @@ -29,9 +31,161 @@ After the client library is installed/deployed, you can use it in your Maven pro 1.0.0 compile +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "io.swagger:swagger-petstore-jersey2:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + + mvn package + +Then manually install the following JARs: + +* target/swagger-petstore-jersey2-1.0.0.jar +* target/lib/*.jar + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import io.swagger.client.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; +import io.swagger.client.api.PetApi; + +import java.io.File; +import java.util.*; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + + + PetApi apiInstance = new PetApi(); + + Pet body = new Pet(); // Pet | Pet object that needs to be added to the store + + try { + apiInstance.addPet(body); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); + } + } +} ``` +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Category](docs/Category.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation for Authorization + +Authentication schemes defined for the API: +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + +### test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +### test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### test_http_basic + +- **Type**: HTTP basic authentication + +### test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +### test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + + ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -40,4 +194,3 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io - diff --git a/samples/client/petstore/java/jersey2/docs/Animal.md b/samples/client/petstore/java/jersey2/docs/Animal.md new file mode 100644 index 00000000000..3ecb7f991f3 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Animal.md @@ -0,0 +1,10 @@ + +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | + + + diff --git a/samples/client/petstore/java/jersey2/docs/ApiResponse.md b/samples/client/petstore/java/jersey2/docs/ApiResponse.md new file mode 100644 index 00000000000..1c17767c2b7 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/Cat.md b/samples/client/petstore/java/jersey2/docs/Cat.md new file mode 100644 index 00000000000..373af540c41 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Cat.md @@ -0,0 +1,11 @@ + +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**declawed** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/Category.md b/samples/client/petstore/java/jersey2/docs/Category.md new file mode 100644 index 00000000000..e2df0803278 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/Dog.md b/samples/client/petstore/java/jersey2/docs/Dog.md new file mode 100644 index 00000000000..a1d638d3bad --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Dog.md @@ -0,0 +1,11 @@ + +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**breed** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/FormatTest.md b/samples/client/petstore/java/jersey2/docs/FormatTest.md new file mode 100644 index 00000000000..8e400e7bcd7 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/FormatTest.md @@ -0,0 +1,21 @@ + +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **Integer** | | [optional] +**int32** | **Integer** | | [optional] +**int64** | **Long** | | [optional] +**number** | [**BigDecimal**](BigDecimal.md) | | +**_float** | **Float** | | [optional] +**_double** | **Double** | | [optional] +**string** | **String** | | [optional] +**_byte** | **byte[]** | | [optional] +**binary** | **byte[]** | | [optional] +**date** | [**Date**](Date.md) | | [optional] +**dateTime** | [**Date**](Date.md) | | [optional] +**password** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/InlineResponse200.md b/samples/client/petstore/java/jersey2/docs/InlineResponse200.md new file mode 100644 index 00000000000..232cb0ed5c1 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/InlineResponse200.md @@ -0,0 +1,13 @@ +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photoUrls** | **List<String>** | | [optional] +**name** | **String** | | [optional] +**id** | **Long** | | +**category** | **Object** | | [optional] +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/client/petstore/java/jersey2/docs/Model200Response.md b/samples/client/petstore/java/jersey2/docs/Model200Response.md new file mode 100644 index 00000000000..0819b88c4f4 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Model200Response.md @@ -0,0 +1,10 @@ + +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md b/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md new file mode 100644 index 00000000000..3eec8686cc9 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ + +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/ModelReturn.md b/samples/client/petstore/java/jersey2/docs/ModelReturn.md new file mode 100644 index 00000000000..a679b04953e --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/ModelReturn.md @@ -0,0 +1,10 @@ + +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/Name.md b/samples/client/petstore/java/jersey2/docs/Name.md new file mode 100644 index 00000000000..a1adac1dd39 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Name.md @@ -0,0 +1,11 @@ + +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | +**snakeCase** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/Order.md b/samples/client/petstore/java/jersey2/docs/Order.md new file mode 100644 index 00000000000..b1709c14eee --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Order.md @@ -0,0 +1,24 @@ + +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**petId** | **Long** | | [optional] +**quantity** | **Integer** | | [optional] +**shipDate** | [**Date**](Date.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] +**complete** | **Boolean** | | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +PLACED | placed +APPROVED | approved +DELIVERED | delivered + + + diff --git a/samples/client/petstore/java/jersey2/docs/Pet.md b/samples/client/petstore/java/jersey2/docs/Pet.md new file mode 100644 index 00000000000..20a1c298dd6 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Pet.md @@ -0,0 +1,24 @@ + +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | available +PENDING | pending +SOLD | sold + + + diff --git a/samples/client/petstore/java/jersey2/docs/PetApi.md b/samples/client/petstore/java/jersey2/docs/PetApi.md new file mode 100644 index 00000000000..e0314e20e51 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/PetApi.md @@ -0,0 +1,448 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.addPet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | Pet id to delete +String apiKey = "apiKey_example"; // String | +try { + apiInstance.deletePet(petId, apiKey); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByStatus** +> List<Pet> findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter +try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> List<Pet> findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List tags = Arrays.asList("tags_example"); // List | Tags to filter by +try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to return +try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.updatePet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet that needs to be updated +String name = "name_example"; // String | Updated name of the pet +String status = "status_example"; // String | Updated status of the pet +try { + apiInstance.updatePetWithForm(petId, name, status); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + + +# **uploadFile** +> ModelApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to update +String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server +File file = new File("/path/to/file.txt"); // File | file to upload +try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/jersey2/docs/SpecialModelName.md b/samples/client/petstore/java/jersey2/docs/SpecialModelName.md new file mode 100644 index 00000000000..c2c6117c552 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/SpecialModelName.md @@ -0,0 +1,10 @@ + +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **Long** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/StoreApi.md b/samples/client/petstore/java/jersey2/docs/StoreApi.md new file mode 100644 index 00000000000..0b30791725a --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/StoreApi.md @@ -0,0 +1,197 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +String orderId = "orderId_example"; // String | ID of the order that needs to be deleted +try { + apiInstance.deleteOrder(orderId); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getInventory** +> Map<String, Integer> getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.StoreApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +StoreApi apiInstance = new StoreApi(); +try { + Map result = apiInstance.getInventory(); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**Map<String, Integer>**](Map.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Long orderId = 789L; // Long | ID of pet that needs to be fetched +try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **Long**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Order body = new Order(); // Order | order placed for purchasing the pet +try { + Order result = apiInstance.placeOrder(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/jersey2/docs/Tag.md b/samples/client/petstore/java/jersey2/docs/Tag.md new file mode 100644 index 00000000000..de6814b55d5 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/User.md b/samples/client/petstore/java/jersey2/docs/User.md new file mode 100644 index 00000000000..8b6753dd284 --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/User.md @@ -0,0 +1,17 @@ + +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **Integer** | User Status | [optional] + + + diff --git a/samples/client/petstore/java/jersey2/docs/UserApi.md b/samples/client/petstore/java/jersey2/docs/UserApi.md new file mode 100644 index 00000000000..8cdc15992ee --- /dev/null +++ b/samples/client/petstore/java/jersey2/docs/UserApi.md @@ -0,0 +1,370 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +User body = new User(); // User | Created user object +try { + apiInstance.createUser(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithArrayInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithListInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be deleted +try { + apiInstance.deleteUser(username); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. +try { + User result = apiInstance.getUserByName(username); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The user name for login +String password = "password_example"; // String | The password for login in clear text +try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +try { + apiInstance.logoutUser(); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | name that need to be deleted +User body = new User(); // User | Updated user object +try { + apiInstance.updateUser(username, body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index 0b0368d214f..f513e2165c7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index 256cd5ff087..c6c4f0b1cd6 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 51b30d45655..8d447238daf 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import javax.ws.rs.ext.ContextResolver; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class JSON implements ContextResolver { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index d09ea6040bf..6fb0888876f 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index b42e4d241ae..cd18a247928 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index 61ba97f3fea..d96bf5dcc0b 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import io.swagger.client.Pair; import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") public class PetApi { private ApiClient apiClient; @@ -39,12 +39,17 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException if fails to make API call */ public void addPet(Pet body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -57,42 +62,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - "application/json", "application/xml" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "petstore_auth" }; - - - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); - } - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @throws ApiException if fails to make API call - */ - public void addPetUsingByteArray(byte[] body) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -136,7 +106,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -153,13 +123,18 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return List * @throws ApiException if fails to make API call */ public List findPetsByStatus(List status) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -168,12 +143,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -189,14 +164,19 @@ public class PetApi { } /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return List * @throws ApiException if fails to make API call */ public List findPetsByTags(List tags) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -205,12 +185,12 @@ public class PetApi { Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -226,8 +206,8 @@ public class PetApi { } /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Pet * @throws ApiException if fails to make API call */ @@ -252,7 +232,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -261,104 +241,25 @@ public class PetApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + String[] localVarAuthNames = new String[] { "api_key" }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return InlineResponse200 - * @throws ApiException if fails to make API call - */ - public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); - } - - // create path and map variables - String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return byte[] - * @throws ApiException if fails to make API call - */ - public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet"); - } - - // create path and map variables - String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException if fails to make API call */ public void updatePet(Pet body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -371,7 +272,7 @@ public class PetApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -393,7 +294,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException if fails to make API call */ - public void updatePetWithForm(String petId, String name, String status) throws ApiException { + public void updatePetWithForm(Long petId, String name, String status) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -418,7 +319,7 @@ if (status != null) localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -438,9 +339,10 @@ if (status != null) * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) + * @return ModelApiResponse * @throws ApiException if fails to make API call */ - public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -465,7 +367,7 @@ if (file != null) localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -476,7 +378,7 @@ if (file != null) String[] localVarAuthNames = new String[] { "petstore_auth" }; - - apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); - } + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index bed19115aa0..65d0ff6a615 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class StoreApi { private ApiClient apiClient; @@ -61,7 +61,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -75,43 +75,6 @@ public class StoreApi { apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List - * @throws ApiException if fails to make API call - */ - public List findOrdersByStatus(String status) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; - - GenericType> localVarReturnType = new GenericType>() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -133,7 +96,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -147,41 +110,6 @@ public class StoreApi { GenericType> localVarReturnType = new GenericType>() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Object - * @throws ApiException if fails to make API call - */ - public Object getInventoryInObject() throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); - - // query params - List localVarQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - - - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - - String[] localVarAuthNames = new String[] { "api_key" }; - - GenericType localVarReturnType = new GenericType() {}; - return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); - } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -189,7 +117,7 @@ public class StoreApi { * @return Order * @throws ApiException if fails to make API call */ - public Order getOrderById(String orderId) throws ApiException { + public Order getOrderById(Long orderId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -210,7 +138,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -219,7 +147,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; + String[] localVarAuthNames = new String[] { }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); @@ -227,13 +155,18 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Order * @throws ApiException if fails to make API call */ public Order placeOrder(Order body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); + } + // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -246,7 +179,7 @@ public class StoreApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -255,7 +188,7 @@ public class StoreApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + String[] localVarAuthNames = new String[] { }; GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index a6a28778e09..8a1cba219a6 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class UserApi { private ApiClient apiClient; @@ -37,12 +37,17 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @throws ApiException if fails to make API call */ public void createUser(User body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); + } + // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -55,7 +60,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -72,12 +77,17 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException if fails to make API call */ public void createUsersWithArrayInput(List body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); + } + // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -90,7 +100,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -107,12 +117,17 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException if fails to make API call */ public void createUsersWithListInput(List body) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); + } + // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -125,7 +140,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -166,7 +181,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -175,7 +190,7 @@ public class UserApi { }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - String[] localVarAuthNames = new String[] { "test_http_basic" }; + String[] localVarAuthNames = new String[] { }; apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); @@ -208,7 +223,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -225,14 +240,24 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String * @throws ApiException if fails to make API call */ public String loginUser(String username, String password) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -247,7 +272,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -281,7 +306,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); @@ -299,7 +324,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @throws ApiException if fails to make API call */ public void updateUser(String username, User body) throws ApiException { @@ -310,6 +335,11 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); + } + // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); @@ -323,7 +353,7 @@ public class UserApi { final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index d7cfe647b59..acdcaa52fcd 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index a956d40501b..fc96078e06e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index 9534d08fd36..e70241f1171 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index 37262216c72..d56e70d7689 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index c8e19c39c30..da8a3553b00 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index fad08101a44..e8e19c2d32e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index 920d45354d5..0d620e5addd 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 9d0b1a22e98..1586ae89d6d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index 57084986396..00000000000 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,198 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - - /** - **/ - public InlineResponse200 tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - **/ - public InlineResponse200 id(Long id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", required = true, value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - public InlineResponse200 category(Object category) { - this.category = category; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - * pet status in the store - **/ - public InlineResponse200 status(StatusEnum status) { - this.status = status; - return this; - } - - @ApiModelProperty(example = "null", value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - **/ - public InlineResponse200 name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - public InlineResponse200 photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(this.tags, inlineResponse200.tags) && - Objects.equals(this.id, inlineResponse200.id) && - Objects.equals(this.category, inlineResponse200.category) && - Objects.equals(this.status, inlineResponse200.status) && - Objects.equals(this.name, inlineResponse200.name) && - Objects.equals(this.photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 32010398f48..1db08de21f4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..fe1bf3f483d --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,113 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 0fad49d781d..1f89198ddda 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index 72b8652423e..cc7dbe3dd6e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index e5b35f51539..136aa894eb4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Order { private Long id = null; @@ -39,14 +39,24 @@ public class Order { } private StatusEnum status = null; - private Boolean complete = null; + private Boolean complete = false; + /** + **/ + public Order id(Long id) { + this.id = id; + return this; + } + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 2ae12be0c91..859a1ce8c3c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index 7233dae4aae..be6b9c3c92a 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 5a680e60356..276ff12d6eb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 6017c1f66ab..646f9969f30 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:32.196+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java index 9af7c537877..51583853257 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -70,6 +70,7 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -116,6 +117,7 @@ public class PetApiTest { assertEquals(category.getId(), Long.valueOf(categoryIdInt)); assertEquals(category.getName(), categoryMap.get("name")); } + */ @Test public void testUpdatePet() throws Exception { @@ -188,7 +190,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); + api.updatePetWithForm(fetched.getId(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index b0106d2f4c6..7ccbdf3f32b 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,6 +33,7 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -45,13 +46,14 @@ public class StoreApiTest { assertTrue(firstEntry.getKey() instanceof String); assertTrue(firstEntry.getValue() instanceof Integer); } + */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -62,13 +64,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(String.valueOf(order.getId())); + api.getOrderById(order.getId()); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index fd85a16cd07..f2b11d703c2 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -4,7 +4,7 @@ Building the API client library requires [Maven](https://maven.apache.org/) to be installed. -## Installation & Usage +## Installation To install the API client library to your local Maven repository, simply execute: @@ -20,7 +20,9 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +### Maven users + +Add this dependency to your project's POM: ```xml @@ -29,9 +31,164 @@ After the client library is installed/deployed, you can use it in your Maven pro 1.0.0 compile +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "io.swagger:swagger-petstore-okhttp-gson:1.0.0" +``` + +### Others + +At first generate the JAR by executing: + + mvn package + +Then manually install the following JARs: + +* target/swagger-petstore-okhttp-gson-1.0.0.jar +* target/lib/*.jar + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import io.swagger.client.*; +import io.swagger.client.auth.*; +import io.swagger.client.model.*; +import io.swagger.client.api.PetApi; + +import java.io.File; +import java.util.*; + +public class PetApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + + // Configure OAuth2 access token for authorization: petstore_auth + OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); + petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + + + + PetApi apiInstance = new PetApi(); + + Pet body = new Pet(); // Pet | Pet object that needs to be added to the store + + try { + apiInstance.addPet(body); + } catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); + } + } +} ``` +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) + - [Category](docs/Category.md) + - [Dog](docs/Dog.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation for Authorization + +Authentication schemes defined for the API: +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + +### test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +### test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### test_http_basic + +- **Type**: HTTP basic authentication + +### test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +### test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + + ## Recommendation It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issue. @@ -40,4 +197,3 @@ It's recommended to create an instance of `ApiClient` per thread in a multithrea apiteam@swagger.io - diff --git a/samples/client/petstore/java/okhttp-gson/docs/Animal.md b/samples/client/petstore/java/okhttp-gson/docs/Animal.md new file mode 100644 index 00000000000..3ecb7f991f3 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Animal.md @@ -0,0 +1,10 @@ + +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md b/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md new file mode 100644 index 00000000000..1c17767c2b7 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/ApiResponse.md @@ -0,0 +1,12 @@ + +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Cat.md b/samples/client/petstore/java/okhttp-gson/docs/Cat.md new file mode 100644 index 00000000000..373af540c41 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Cat.md @@ -0,0 +1,11 @@ + +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**declawed** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Category.md b/samples/client/petstore/java/okhttp-gson/docs/Category.md new file mode 100644 index 00000000000..e2df0803278 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Category.md @@ -0,0 +1,11 @@ + +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Dog.md b/samples/client/petstore/java/okhttp-gson/docs/Dog.md new file mode 100644 index 00000000000..a1d638d3bad --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Dog.md @@ -0,0 +1,11 @@ + +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**className** | **String** | | +**breed** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md b/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md new file mode 100644 index 00000000000..8e400e7bcd7 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/FormatTest.md @@ -0,0 +1,21 @@ + +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **Integer** | | [optional] +**int32** | **Integer** | | [optional] +**int64** | **Long** | | [optional] +**number** | [**BigDecimal**](BigDecimal.md) | | +**_float** | **Float** | | [optional] +**_double** | **Double** | | [optional] +**string** | **String** | | [optional] +**_byte** | **byte[]** | | [optional] +**binary** | **byte[]** | | [optional] +**date** | [**Date**](Date.md) | | [optional] +**dateTime** | [**Date**](Date.md) | | [optional] +**password** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md b/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md new file mode 100644 index 00000000000..487ebe429e4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/InlineResponse200.md @@ -0,0 +1,24 @@ + +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**photoUrls** | **List<String>** | | [optional] +**name** | **String** | | [optional] +**id** | **Long** | | +**category** | **Object** | | [optional] +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | available +PENDING | pending +SOLD | sold + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md b/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md new file mode 100644 index 00000000000..0819b88c4f4 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Model200Response.md @@ -0,0 +1,10 @@ + +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md b/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md new file mode 100644 index 00000000000..3eec8686cc9 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ + +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md b/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md new file mode 100644 index 00000000000..a679b04953e --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/ModelReturn.md @@ -0,0 +1,10 @@ + +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Name.md b/samples/client/petstore/java/okhttp-gson/docs/Name.md new file mode 100644 index 00000000000..a1adac1dd39 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Name.md @@ -0,0 +1,11 @@ + +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | +**snakeCase** | **Integer** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Order.md b/samples/client/petstore/java/okhttp-gson/docs/Order.md new file mode 100644 index 00000000000..b1709c14eee --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Order.md @@ -0,0 +1,24 @@ + +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**petId** | **Long** | | [optional] +**quantity** | **Integer** | | [optional] +**shipDate** | [**Date**](Date.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] +**complete** | **Boolean** | | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +PLACED | placed +APPROVED | approved +DELIVERED | delivered + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Pet.md b/samples/client/petstore/java/okhttp-gson/docs/Pet.md new file mode 100644 index 00000000000..20a1c298dd6 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Pet.md @@ -0,0 +1,24 @@ + +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | +**tags** | [**List<Tag>**](Tag.md) | | [optional] +**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] + + + +## Enum: StatusEnum +Name | Value +---- | ----- +AVAILABLE | available +PENDING | pending +SOLD | sold + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson/docs/PetApi.md new file mode 100644 index 00000000000..e0314e20e51 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/PetApi.md @@ -0,0 +1,448 @@ +# PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.addPet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#addPet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | Pet id to delete +String apiKey = "apiKey_example"; // String | +try { + apiInstance.deletePet(petId, apiKey); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#deletePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByStatus** +> List<Pet> findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List status = Arrays.asList("status_example"); // List | Status values that need to be considered for filter +try { + List result = apiInstance.findPetsByStatus(status); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByStatus"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **findPetsByTags** +> List<Pet> findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +List tags = Arrays.asList("tags_example"); // List | Tags to filter by +try { + List result = apiInstance.findPetsByTags(tags); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#findPetsByTags"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to return +try { + Pet result = apiInstance.getPetById(petId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#getPetById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Pet body = new Pet(); // Pet | Pet object that needs to be added to the store +try { + apiInstance.updatePet(body); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePet"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet that needs to be updated +String name = "name_example"; // String | Updated name of the pet +String status = "status_example"; // String | Updated status of the pet +try { + apiInstance.updatePetWithForm(petId, name, status); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#updatePetWithForm"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +null (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + + +# **uploadFile** +> ModelApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.PetApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure OAuth2 access token for authorization: petstore_auth +OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); +petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); + +PetApi apiInstance = new PetApi(); +Long petId = 789L; // Long | ID of pet to update +String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server +File file = new File("/path/to/file.txt"); // File | file to upload +try { + ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, file); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling PetApi#uploadFile"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **Long**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +[**ModelApiResponse**](ModelApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + diff --git a/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md b/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md new file mode 100644 index 00000000000..c2c6117c552 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/SpecialModelName.md @@ -0,0 +1,10 @@ + +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**specialPropertyName** | **Long** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md b/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md new file mode 100644 index 00000000000..0b30791725a --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/StoreApi.md @@ -0,0 +1,197 @@ +# StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +String orderId = "orderId_example"; // String | ID of the order that needs to be deleted +try { + apiInstance.deleteOrder(orderId); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#deleteOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getInventory** +> Map<String, Integer> getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```java +// Import classes: +//import io.swagger.client.ApiClient; +//import io.swagger.client.ApiException; +//import io.swagger.client.Configuration; +//import io.swagger.client.auth.*; +//import io.swagger.client.api.StoreApi; + +ApiClient defaultClient = Configuration.getDefaultApiClient(); + +// Configure API key authorization: api_key +ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key"); +api_key.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//api_key.setApiKeyPrefix("Token"); + +StoreApi apiInstance = new StoreApi(); +try { + Map result = apiInstance.getInventory(); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getInventory"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**Map<String, Integer>**](Map.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Long orderId = 789L; // Long | ID of pet that needs to be fetched +try { + Order result = apiInstance.getOrderById(orderId); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#getOrderById"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **Long**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.StoreApi; + + +StoreApi apiInstance = new StoreApi(); +Order body = new Order(); // Order | order placed for purchasing the pet +try { + Order result = apiInstance.placeOrder(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling StoreApi#placeOrder"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/okhttp-gson/docs/Tag.md b/samples/client/petstore/java/okhttp-gson/docs/Tag.md new file mode 100644 index 00000000000..de6814b55d5 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/Tag.md @@ -0,0 +1,11 @@ + +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/User.md b/samples/client/petstore/java/okhttp-gson/docs/User.md new file mode 100644 index 00000000000..8b6753dd284 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/User.md @@ -0,0 +1,17 @@ + +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Long** | | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **Integer** | User Status | [optional] + + + diff --git a/samples/client/petstore/java/okhttp-gson/docs/UserApi.md b/samples/client/petstore/java/okhttp-gson/docs/UserApi.md new file mode 100644 index 00000000000..8cdc15992ee --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/docs/UserApi.md @@ -0,0 +1,370 @@ +# UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +User body = new User(); // User | Created user object +try { + apiInstance.createUser(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithArrayInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +List body = Arrays.asList(new User()); // List | List of user object +try { + apiInstance.createUsersWithListInput(body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#createUsersWithListInput"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be deleted +try { + apiInstance.deleteUser(username); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#deleteUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. +try { + User result = apiInstance.getUserByName(username); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#getUserByName"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | The user name for login +String password = "password_example"; // String | The password for login in clear text +try { + String result = apiInstance.loginUser(username, password); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#loginUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +try { + apiInstance.logoutUser(); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#logoutUser"); + e.printStackTrace(); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.UserApi; + + +UserApi apiInstance = new UserApi(); +String username = "username_example"; // String | name that need to be deleted +User body = new User(); // User | Updated user object +try { + apiInstance.updateUser(username, body); +} catch (ApiException e) { + System.err.println("Exception when calling UserApi#updateUser"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index ef5ae6fa25d..9328cb74d84 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -146,12 +146,7 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); authentications.put("petstore_auth", new OAuth()); - authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); - authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); - authentications.put("test_http_basic", new HttpBasicAuth()); - authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); - authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 564721b4128..38c89d2d0fc 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index d165a15b2c7..e879206d377 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index 3527bb741c6..e1b2c38f0a2 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 67634780b8e..32556afd1b6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index 1bfdafb1fcb..ac7ad688c56 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -18,7 +18,7 @@ import com.squareup.okhttp.Response; import java.io.IOException; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.lang.reflect.Type; @@ -50,6 +50,11 @@ public class PetApi { private Call addPetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling addPet(Async)"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -61,7 +66,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -91,7 +96,7 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void addPet(Pet body) throws ApiException { @@ -101,7 +106,7 @@ public class PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -113,7 +118,7 @@ public class PetApi { /** * Add a new pet to the store (asynchronously) * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -143,103 +148,6 @@ public class PetApi { apiClient.executeAsync(call, callback); return call; } - /* Build call for addPetUsingByteArray */ - private Call addPetUsingByteArrayCall(byte[] body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - - // create path and map variables - String localVarPath = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json"); - - List localVarQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json", "application/xml" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "petstore_auth" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public void addPetUsingByteArray(byte[] body) throws ApiException { - addPetUsingByteArrayWithHttpInfo(body); - } - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @return ApiResponse - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse addPetUsingByteArrayWithHttpInfo(byte[] body) throws ApiException { - Call call = addPetUsingByteArrayCall(body, null, null); - return apiClient.execute(call); - } - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store (asynchronously) - * - * @param body Pet object in the form of byte array (optional) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call addPetUsingByteArrayAsync(byte[] body, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - Call call = addPetUsingByteArrayCall(body, progressListener, progressRequestListener); - apiClient.executeAsync(call, callback); - return call; - } /* Build call for deletePet */ private Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; @@ -263,7 +171,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -352,20 +260,25 @@ public class PetApi { private Call findPetsByStatusCall(List status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); + } + // create path and map variables String localVarPath = "/pet/findByStatus".replaceAll("\\{format\\}","json"); List localVarQueryParams = new ArrayList(); if (status != null) - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -395,7 +308,7 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return List * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -407,7 +320,7 @@ public class PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return ApiResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -420,7 +333,7 @@ public class PetApi { /** * Finds Pets by status (asynchronously) * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -455,20 +368,25 @@ public class PetApi { private Call findPetsByTagsCall(List tags, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); + } + // create path and map variables String localVarPath = "/pet/findByTags".replaceAll("\\{format\\}","json"); List localVarQueryParams = new ArrayList(); if (tags != null) - localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "tags", tags)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); Map localVarHeaderParams = new HashMap(); Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -497,8 +415,8 @@ public class PetApi { /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return List * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -509,8 +427,8 @@ public class PetApi { /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return ApiResponse> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -522,8 +440,8 @@ public class PetApi { /** * Finds Pets by tags (asynchronously) - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -575,7 +493,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -598,14 +516,14 @@ public class PetApi { }); } - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; + String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Pet * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -616,8 +534,8 @@ public class PetApi { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -629,8 +547,8 @@ public class PetApi { /** * Find pet by ID (asynchronously) - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -661,224 +579,15 @@ public class PetApi { apiClient.executeAsync(call, localVarReturnType, callback); return call; } - /* Build call for getPetByIdInObject */ - private Call getPetByIdInObjectCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdInObject(Async)"); - } - - - // create path and map variables - String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - List localVarQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return InlineResponse200 - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { - ApiResponse resp = getPetByIdInObjectWithHttpInfo(petId); - return resp.getData(); - } - - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return ApiResponse - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getPetByIdInObjectWithHttpInfo(Long petId) throws ApiException { - Call call = getPetByIdInObjectCall(petId, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' (asynchronously) - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call getPetByIdInObjectAsync(Long petId, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - Call call = getPetByIdInObjectCall(petId, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /* Build call for petPetIdtestingByteArraytrueGet */ - private Call petPetIdtestingByteArraytrueGetCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // verify the required parameter 'petId' is set - if (petId == null) { - throw new ApiException("Missing the required parameter 'petId' when calling petPetIdtestingByteArraytrueGet(Async)"); - } - - - // create path and map variables - String localVarPath = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json") - .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - - List localVarQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return byte[] - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public byte[] petPetIdtestingByteArraytrueGet(Long petId) throws ApiException { - ApiResponse resp = petPetIdtestingByteArraytrueGetWithHttpInfo(petId); - return resp.getData(); - } - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return ApiResponse - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse petPetIdtestingByteArraytrueGetWithHttpInfo(Long petId) throws ApiException { - Call call = petPetIdtestingByteArraytrueGetCall(petId, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' (asynchronously) - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call petPetIdtestingByteArraytrueGetAsync(Long petId, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - Call call = petPetIdtestingByteArraytrueGetCall(petId, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } /* Build call for updatePet */ private Call updatePetCall(Pet body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling updatePet(Async)"); + } + // create path and map variables String localVarPath = "/pet".replaceAll("\\{format\\}","json"); @@ -890,7 +599,7 @@ public class PetApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -920,7 +629,7 @@ public class PetApi { /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updatePet(Pet body) throws ApiException { @@ -930,7 +639,7 @@ public class PetApi { /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -942,7 +651,7 @@ public class PetApi { /** * Update an existing pet (asynchronously) * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -973,7 +682,7 @@ public class PetApi { return call; } /* Build call for updatePetWithForm */ - private Call updatePetWithFormCall(String petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call updatePetWithFormCall(Long petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set @@ -997,7 +706,7 @@ public class PetApi { localVarFormParams.put("status", status); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -1032,7 +741,7 @@ public class PetApi { * @param status Updated status of the pet (optional) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public void updatePetWithForm(String petId, String name, String status) throws ApiException { + public void updatePetWithForm(Long petId, String name, String status) throws ApiException { updatePetWithFormWithHttpInfo(petId, name, status); } @@ -1045,7 +754,7 @@ public class PetApi { * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse updatePetWithFormWithHttpInfo(String petId, String name, String status) throws ApiException { + public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { Call call = updatePetWithFormCall(petId, name, status, null, null); return apiClient.execute(call); } @@ -1060,7 +769,7 @@ public class PetApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback callback) throws ApiException { + public Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -1110,7 +819,7 @@ public class PetApi { localVarFormParams.put("file", file); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -1143,10 +852,12 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) + * @return ModelApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { - uploadFileWithHttpInfo(petId, additionalMetadata, file); + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { + ApiResponse resp = uploadFileWithHttpInfo(petId, additionalMetadata, file); + return resp.getData(); } /** @@ -1155,12 +866,13 @@ public class PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return ApiResponse + * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { + public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { Call call = uploadFileCall(petId, additionalMetadata, file, null, null); - return apiClient.execute(call); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); } /** @@ -1173,7 +885,7 @@ public class PetApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback callback) throws ApiException { + public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -1195,7 +907,8 @@ public class PetApi { } Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener); - apiClient.executeAsync(call, callback); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); return call; } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 4d803d3b575..5d960d0b104 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -65,7 +65,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -147,109 +147,6 @@ public class StoreApi { apiClient.executeAsync(call, callback); return call; } - /* Build call for findOrdersByStatus */ - private Call findOrdersByStatusCall(String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - - // create path and map variables - String localVarPath = "/store/findByStatus".replaceAll("\\{format\\}","json"); - - List localVarQueryParams = new ArrayList(); - if (status != null) - localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status)); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public List findOrdersByStatus(String status) throws ApiException { - ApiResponse> resp = findOrdersByStatusWithHttpInfo(status); - return resp.getData(); - } - - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return ApiResponse> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse> findOrdersByStatusWithHttpInfo(String status) throws ApiException { - Call call = findOrdersByStatusCall(status, null, null); - Type localVarReturnType = new TypeToken>(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Finds orders by status (asynchronously) - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call findOrdersByStatusAsync(String status, final ApiCallback> callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - Call call = findOrdersByStatusCall(status, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken>(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } /* Build call for getInventory */ private Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; @@ -265,7 +162,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -348,106 +245,8 @@ public class StoreApi { apiClient.executeAsync(call, localVarReturnType, callback); return call; } - /* Build call for getInventoryInObject */ - private Call getInventoryInObjectCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - - // create path and map variables - String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); - - List localVarQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json", "application/xml" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { - @Override - public Response intercept(Interceptor.Chain chain) throws IOException { - Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Object - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Object getInventoryInObject() throws ApiException { - ApiResponse resp = getInventoryInObjectWithHttpInfo(); - return resp.getData(); - } - - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return ApiResponse - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getInventoryInObjectWithHttpInfo() throws ApiException { - Call call = getInventoryInObjectCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' (asynchronously) - * Returns an arbitrary object which is actually a map of status codes to quantities - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public Call getInventoryInObjectAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - Call call = getInventoryInObjectCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } /* Build call for getOrderById */ - private Call getOrderByIdCall(String orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call getOrderByIdCall(Long orderId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'orderId' is set @@ -467,7 +266,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -490,7 +289,7 @@ public class StoreApi { }); } - String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" }; + String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } @@ -501,7 +300,7 @@ public class StoreApi { * @return Order * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public Order getOrderById(String orderId) throws ApiException { + public Order getOrderById(Long orderId) throws ApiException { ApiResponse resp = getOrderByIdWithHttpInfo(orderId); return resp.getData(); } @@ -513,7 +312,7 @@ public class StoreApi { * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse getOrderByIdWithHttpInfo(String orderId) throws ApiException { + public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { Call call = getOrderByIdCall(orderId, null, null); Type localVarReturnType = new TypeToken(){}.getType(); return apiClient.execute(call, localVarReturnType); @@ -527,7 +326,7 @@ public class StoreApi { * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call getOrderByIdAsync(String orderId, final ApiCallback callback) throws ApiException { + public Call getOrderByIdAsync(Long orderId, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -557,6 +356,11 @@ public class StoreApi { private Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling placeOrder(Async)"); + } + // create path and map variables String localVarPath = "/store/order".replaceAll("\\{format\\}","json"); @@ -568,7 +372,7 @@ public class StoreApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -591,14 +395,14 @@ public class StoreApi { }); } - String[] localVarAuthNames = new String[] { "test_api_client_id", "test_api_client_secret" }; + String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Order * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -610,7 +414,7 @@ public class StoreApi { /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -623,7 +427,7 @@ public class StoreApi { /** * Place an order for a pet (asynchronously) * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index 5126228e323..be0269ef28f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -48,6 +48,11 @@ public class UserApi { private Call createUserCall(User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createUser(Async)"); + } + // create path and map variables String localVarPath = "/user".replaceAll("\\{format\\}","json"); @@ -59,7 +64,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -89,7 +94,7 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUser(User body) throws ApiException { @@ -99,7 +104,7 @@ public class UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -111,7 +116,7 @@ public class UserApi { /** * Create user (asynchronously) * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -145,6 +150,11 @@ public class UserApi { private Call createUsersWithArrayInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); + } + // create path and map variables String localVarPath = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -156,7 +166,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -186,7 +196,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithArrayInput(List body) throws ApiException { @@ -196,7 +206,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -208,7 +218,7 @@ public class UserApi { /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (optional) + * @param body List of user object (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -242,6 +252,11 @@ public class UserApi { private Call createUsersWithListInputCall(List body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); + } + // create path and map variables String localVarPath = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -253,7 +268,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -283,7 +298,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithListInput(List body) throws ApiException { @@ -293,7 +308,7 @@ public class UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -305,7 +320,7 @@ public class UserApi { /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (optional) + * @param body List of user object (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -356,7 +371,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -379,7 +394,7 @@ public class UserApi { }); } - String[] localVarAuthNames = new String[] { "test_http_basic" }; + String[] localVarAuthNames = new String[] { }; return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } @@ -459,7 +474,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -549,6 +564,16 @@ public class UserApi { private Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException("Missing the required parameter 'username' when calling loginUser(Async)"); + } + + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException("Missing the required parameter 'password' when calling loginUser(Async)"); + } + // create path and map variables String localVarPath = "/user/login".replaceAll("\\{format\\}","json"); @@ -564,7 +589,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -594,8 +619,8 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -607,8 +632,8 @@ public class UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -621,8 +646,8 @@ public class UserApi { /** * Logs user into the system (asynchronously) * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -668,7 +693,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -756,6 +781,11 @@ public class UserApi { throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)"); } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling updateUser(Async)"); + } + // create path and map variables String localVarPath = "/user/{username}".replaceAll("\\{format\\}","json") @@ -768,7 +798,7 @@ public class UserApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - "application/json", "application/xml" + "application/xml", "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); @@ -799,7 +829,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updateUser(String username, User body) throws ApiException { @@ -810,7 +840,7 @@ public class UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ @@ -823,7 +853,7 @@ public class UserApi { * Updated user (asynchronously) * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 526c1163672..fa2d5293018 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index a109275004e..81d6fddf5b0 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:34.419+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index 15bb92523fe..00000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,168 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - - -public class InlineResponse200 { - - @SerializedName("tags") - private List tags = new ArrayList(); - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(this.tags, inlineResponse200.tags) && - Objects.equals(this.id, inlineResponse200.id) && - Objects.equals(this.category, inlineResponse200.category) && - Objects.equals(this.status, inlineResponse200.status) && - Objects.equals(this.name, inlineResponse200.name) && - Objects.equals(this.photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..20d2fc58dd3 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,96 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + + +public class ModelApiResponse { + + @SerializedName("code") + private Integer code = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("message") + private String message = null; + + /** + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index cc13fe4bfd0..b0ebd0e8758 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = null; + private Boolean complete = false; /** **/ @@ -60,6 +60,9 @@ public enum StatusEnum { public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** **/ diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java index 000dbd96bfb..5345e2a1646 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java @@ -150,6 +150,7 @@ public class ApiClientTest { } } + /* @Test public void testSetUsernameAndPassword() { HttpBasicAuth auth = null; @@ -171,6 +172,7 @@ public class ApiClientTest { auth.setUsername(null); auth.setPassword(null); } + */ @Test public void testSetApiKeyAndPrefix() { diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java index 97e708fb2ec..e378356d0d4 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -72,6 +72,7 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + /* @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); @@ -86,6 +87,7 @@ public class PetApiTest { assertNotNull(fetched.getCategory()); assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + */ @Test public void testCreateAndGetPetWithHttpInfo() throws Exception { @@ -197,6 +199,7 @@ public class PetApiTest { assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0)); } + /* @Test public void testGetPetByIdInObject() throws Exception { Pet pet = new Pet(); @@ -230,6 +233,7 @@ public class PetApiTest { assertEquals(category.getId(), categoryIdLong); assertEquals(category.getName(), categoryMap.get("name")); } + */ @Test public void testUpdatePet() throws Exception { @@ -306,7 +310,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); + api.updatePetWithForm(fetched.getId(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 2f4c4297250..0d1910dc1e7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -38,6 +38,7 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + /* @Test public void testGetInventoryInObject() throws Exception { Object inventoryObj = api.getInventoryInObject(); @@ -51,13 +52,14 @@ public class StoreApiTest { // NOTE: Gson parses integer value to double. assertTrue(firstEntry.getValue() instanceof Double); } + */ @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -68,13 +70,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(String.valueOf(order.getId())); + api.getOrderById(order.getId()); // fail("expected an error"); } catch (ApiException e) { // ok diff --git a/samples/client/petstore/java/retrofit/README.md b/samples/client/petstore/java/retrofit/README.md index b687b09ab26..93488cf4e5c 100644 --- a/samples/client/petstore/java/retrofit/README.md +++ b/samples/client/petstore/java/retrofit/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java index ed1ff85acab..6540997c319 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java @@ -47,10 +47,10 @@ public class ApiClient { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "api_key") { - auth = new ApiKeyAuth("header", "api_key"); - } else if (authName == "petstore_auth") { + if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); + } else if (authName == "api_key") { + auth = new ApiKeyAuth("header", "api_key"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 1ce483dd74c..1ec34d9e71d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:35.471+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:01.525+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index af2482b371f..a019a4bf886 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -7,7 +7,7 @@ import retrofit.http.*; import retrofit.mime.*; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -20,7 +20,7 @@ public interface PetApi { * Add a new pet to the store * Sync method * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Void */ @@ -32,7 +32,7 @@ public interface PetApi { /** * Add a new pet to the store * Async method - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @param cb callback method * @return void */ @@ -41,31 +41,6 @@ public interface PetApi { void addPet( @Body Pet body, Callback cb ); - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * Sync method - * - * @param body Pet object in the form of byte array (optional) - * @return Void - */ - - @POST("/pet?testing_byte_array=true") - Void addPetUsingByteArray( - @Body byte[] body - ); - - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * Async method - * @param body Pet object in the form of byte array (optional) - * @param cb callback method - * @return void - */ - - @POST("/pet?testing_byte_array=true") - void addPetUsingByteArray( - @Body byte[] body, Callback cb - ); /** * Deletes a pet * Sync method @@ -97,57 +72,57 @@ public interface PetApi { * Finds Pets by status * Sync method * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return List */ @GET("/pet/findByStatus") List findPetsByStatus( - @Query("status") List status + @Query("status") CSVParams status ); /** * Finds Pets by status * Async method - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @param cb callback method * @return void */ @GET("/pet/findByStatus") void findPetsByStatus( - @Query("status") List status, Callback> cb + @Query("status") CSVParams status, Callback> cb ); /** * Finds Pets by tags * Sync method - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return List */ @GET("/pet/findByTags") List findPetsByTags( - @Query("tags") List tags + @Query("tags") CSVParams tags ); /** * Finds Pets by tags * Async method - * @param tags Tags to filter by (optional) + * @param tags Tags to filter by (required) * @param cb callback method * @return void */ @GET("/pet/findByTags") void findPetsByTags( - @Query("tags") List tags, Callback> cb + @Query("tags") CSVParams tags, Callback> cb ); /** * Find pet by ID * Sync method - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Pet */ @@ -159,7 +134,7 @@ public interface PetApi { /** * Find pet by ID * Async method - * @param petId ID of pet that needs to be fetched (required) + * @param petId ID of pet to return (required) * @param cb callback method * @return void */ @@ -168,61 +143,11 @@ public interface PetApi { void getPetById( @Path("petId") Long petId, Callback cb ); - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Sync method - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return InlineResponse200 - */ - - @GET("/pet/{petId}?response=inline_arbitrary_object") - InlineResponse200 getPetByIdInObject( - @Path("petId") Long petId - ); - - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Async method - * @param petId ID of pet that needs to be fetched (required) - * @param cb callback method - * @return void - */ - - @GET("/pet/{petId}?response=inline_arbitrary_object") - void getPetByIdInObject( - @Path("petId") Long petId, Callback cb - ); - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Sync method - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return byte[] - */ - - @GET("/pet/{petId}?testing_byte_array=true") - byte[] petPetIdtestingByteArraytrueGet( - @Path("petId") Long petId - ); - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Async method - * @param petId ID of pet that needs to be fetched (required) - * @param cb callback method - * @return void - */ - - @GET("/pet/{petId}?testing_byte_array=true") - void petPetIdtestingByteArraytrueGet( - @Path("petId") Long petId, Callback cb - ); /** * Update an existing pet * Sync method * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Void */ @@ -234,7 +159,7 @@ public interface PetApi { /** * Update an existing pet * Async method - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @param cb callback method * @return void */ @@ -256,7 +181,7 @@ public interface PetApi { @FormUrlEncoded @POST("/pet/{petId}") Void updatePetWithForm( - @Path("petId") String petId, @Field("name") String name, @Field("status") String status + @Path("petId") Long petId, @Field("name") String name, @Field("status") String status ); /** @@ -272,7 +197,7 @@ public interface PetApi { @FormUrlEncoded @POST("/pet/{petId}") void updatePetWithForm( - @Path("petId") String petId, @Field("name") String name, @Field("status") String status, Callback cb + @Path("petId") Long petId, @Field("name") String name, @Field("status") String status, Callback cb ); /** * uploads an image @@ -281,12 +206,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return Void + * @return ModelApiResponse */ @Multipart @POST("/pet/{petId}/uploadImage") - Void uploadFile( + ModelApiResponse uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file ); @@ -303,6 +228,6 @@ public interface PetApi { @Multipart @POST("/pet/{petId}/uploadImage") void uploadFile( - @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb + @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb ); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index ede732a986b..def4aa2efc7 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -39,31 +39,6 @@ public interface StoreApi { void deleteOrder( @Path("orderId") String orderId, Callback cb ); - /** - * Finds orders by status - * Sync method - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List - */ - - @GET("/store/findByStatus") - List findOrdersByStatus( - @Query("status") String status - ); - - /** - * Finds orders by status - * Async method - * @param status Status value that needs to be considered for query (optional, default to placed) - * @param cb callback method - * @return void - */ - - @GET("/store/findByStatus") - void findOrdersByStatus( - @Query("status") String status, Callback> cb - ); /** * Returns pet inventories by status * Sync method @@ -86,28 +61,6 @@ public interface StoreApi { void getInventory( Callback> cb ); - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Sync method - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Object - */ - - @GET("/store/inventory?response=arbitrary_object") - Object getInventoryInObject(); - - - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Async method - * @param cb callback method - * @return void - */ - - @GET("/store/inventory?response=arbitrary_object") - void getInventoryInObject( - Callback cb - ); /** * Find purchase order by ID * Sync method @@ -118,7 +71,7 @@ public interface StoreApi { @GET("/store/order/{orderId}") Order getOrderById( - @Path("orderId") String orderId + @Path("orderId") Long orderId ); /** @@ -131,13 +84,13 @@ public interface StoreApi { @GET("/store/order/{orderId}") void getOrderById( - @Path("orderId") String orderId, Callback cb + @Path("orderId") Long orderId, Callback cb ); /** * Place an order for a pet * Sync method * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Order */ @@ -149,7 +102,7 @@ public interface StoreApi { /** * Place an order for a pet * Async method - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @param cb callback method * @return void */ diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java index ea7285de79c..8c3380d07d4 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/UserApi.java @@ -18,7 +18,7 @@ public interface UserApi { * Create user * Sync method * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @return Void */ @@ -30,7 +30,7 @@ public interface UserApi { /** * Create user * Async method - * @param body Created user object (optional) + * @param body Created user object (required) * @param cb callback method * @return void */ @@ -43,7 +43,7 @@ public interface UserApi { * Creates list of users with given input array * Sync method * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Void */ @@ -55,7 +55,7 @@ public interface UserApi { /** * Creates list of users with given input array * Async method - * @param body List of user object (optional) + * @param body List of user object (required) * @param cb callback method * @return void */ @@ -68,7 +68,7 @@ public interface UserApi { * Creates list of users with given input array * Sync method * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Void */ @@ -80,7 +80,7 @@ public interface UserApi { /** * Creates list of users with given input array * Async method - * @param body List of user object (optional) + * @param body List of user object (required) * @param cb callback method * @return void */ @@ -143,8 +143,8 @@ public interface UserApi { * Logs user into the system * Sync method * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String */ @@ -156,8 +156,8 @@ public interface UserApi { /** * Logs user into the system * Async method - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @param cb callback method * @return void */ @@ -193,7 +193,7 @@ public interface UserApi { * Sync method * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @return Void */ @@ -206,7 +206,7 @@ public interface UserApi { * Updated user * Async method * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @param cb callback method * @return void */ diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index b17bf005009..00000000000 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,168 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - - -public class InlineResponse200 { - - @SerializedName("tags") - private List tags = new ArrayList(); - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..bb5313b42d4 --- /dev/null +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,96 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + + +public class ModelApiResponse { + + @SerializedName("code") + private Integer code = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("message") + private String message = null; + + /** + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java index f1fb2ad7409..196a5702404 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = null; + private Boolean complete = false; /** **/ @@ -60,6 +60,9 @@ public enum StatusEnum { public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** **/ diff --git a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java index a943a8ffe6e..9fa93650d54 100644 --- a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -2,7 +2,8 @@ package io.swagger.petstore.test; import io.swagger.TestUtils; -import io.swagger.client.ApiClient; +import io.swagger.client.*; +import io.swagger.client.CollectionFormats.*; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -61,7 +62,7 @@ public class PetApiTest { api.updatePet(pet); - List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})); + List pets = api.findPetsByStatus(new CSVParams("available")); assertNotNull(pets); boolean found = false; @@ -89,7 +90,7 @@ public class PetApiTest { api.updatePet(pet); - List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"})); + List pets = api.findPetsByTags(new CSVParams("friendly")); assertNotNull(pets); boolean found = false; @@ -110,7 +111,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()); - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null); + api.updatePetWithForm(fetched.getId(), "furt", null); Pet updated = api.getPetById(fetched.getId()); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 07d3b6a298d..c823245355a 100644 --- a/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,7 +33,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -44,13 +44,13 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order); - Order fetched = api.getOrderById(String.valueOf(order.getId())); + Order fetched = api.getOrderById(order.getId()); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())); try { - api.getOrderById(String.valueOf(order.getId())); + api.getOrderById(order.getId()); // fail("expected an error"); } catch (RetrofitError e) { // ok diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java index ffff8c26d4f..e49bdf24d7b 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java @@ -49,16 +49,8 @@ public class ApiClient { Interceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "test_api_client_id") { - auth = new ApiKeyAuth("header", "x-test_api_client_id"); - } else if (authName == "test_api_client_secret") { - auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); - } else if (authName == "test_api_key_query") { - auth = new ApiKeyAuth("query", "test_api_key_query"); - } else if (authName == "test_api_key_header") { - auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index dace285deca..fd13370ea3a 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:36:36.537+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:03.337+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index f56c7de3ddf..ec9d67a7449 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,7 +9,7 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -21,7 +21,7 @@ public interface PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Call */ @@ -30,18 +30,6 @@ public interface PetApi { @Body Pet body ); - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @return Call - */ - - @POST("pet?testing_byte_array=true") - Call addPetUsingByteArray( - @Body byte[] body - ); - /** * Deletes a pet * @@ -58,31 +46,31 @@ public interface PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return Call> */ @GET("pet/findByStatus") Call> findPetsByStatus( - @Query("status") List status + @Query("status") CSVParams status ); /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return Call> */ @GET("pet/findByTags") Call> findPetsByTags( - @Query("tags") List tags + @Query("tags") CSVParams tags ); /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Call */ @@ -91,34 +79,10 @@ public interface PetApi { @Path("petId") Long petId ); - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return Call - */ - - @GET("pet/{petId}?response=inline_arbitrary_object") - Call getPetByIdInObject( - @Path("petId") Long petId - ); - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return Call - */ - - @GET("pet/{petId}?testing_byte_array=true") - Call petPetIdtestingByteArraytrueGet( - @Path("petId") Long petId - ); - /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Call */ @@ -139,7 +103,7 @@ public interface PetApi { @FormUrlEncoded @POST("pet/{petId}") Call updatePetWithForm( - @Path("petId") String petId, @Field("name") String name, @Field("status") String status + @Path("petId") Long petId, @Field("name") String name, @Field("status") String status ); /** @@ -148,12 +112,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return Call + * @return Call */ @Multipart @POST("pet/{petId}/uploadImage") - Call uploadFile( + Call uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file\"; filename=\"file\"") RequestBody file ); diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java index 55a3ea5b46a..1651c07482c 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java @@ -28,18 +28,6 @@ public interface StoreApi { @Path("orderId") String orderId ); - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return Call> - */ - - @GET("store/findByStatus") - Call> findOrdersByStatus( - @Query("status") String status - ); - /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -50,16 +38,6 @@ public interface StoreApi { Call> getInventory(); - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Call - */ - - @GET("store/inventory?response=arbitrary_object") - Call getInventoryInObject(); - - /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -69,13 +47,13 @@ public interface StoreApi { @GET("store/order/{orderId}") Call getOrderById( - @Path("orderId") String orderId + @Path("orderId") Long orderId ); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java index ce02953a0c8..a0f17545a0f 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/UserApi.java @@ -19,7 +19,7 @@ public interface UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @return Call */ @@ -31,7 +31,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Call */ @@ -43,7 +43,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Call */ @@ -79,8 +79,8 @@ public interface UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return Call */ @@ -103,7 +103,7 @@ public interface UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index b17bf005009..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,168 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - - -public class InlineResponse200 { - - @SerializedName("tags") - private List tags = new ArrayList(); - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..bb5313b42d4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,96 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + + +public class ModelApiResponse { + + @SerializedName("code") + private Integer code = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("message") + private String message = null; + + /** + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java deleted file mode 100644 index 920640ad2cb..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/ObjectReturn.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - -@ApiModel(description = "") -public class ObjectReturn { - - @SerializedName("return") - private Integer _return = null; - - - - /** - **/ - @ApiModelProperty(value = "") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ObjectReturn _return = (ObjectReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ObjectReturn {\n"); - - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java index f1fb2ad7409..196a5702404 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = null; + private Boolean complete = false; /** **/ @@ -60,6 +60,9 @@ public enum StatusEnum { public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** **/ diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java index 3905fb962e3..ac8abefb216 100644 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -3,6 +3,7 @@ package io.swagger.petstore.test; import io.swagger.TestUtils; import io.swagger.client.ApiClient; +import io.swagger.client.CollectionFormats.*; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -65,7 +66,7 @@ public class PetApiTest { api.updatePet(pet).execute(); - List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})).execute().body(); + List pets = api.findPetsByStatus(new CSVParams("available")).execute().body(); assertNotNull(pets); boolean found = false; @@ -93,7 +94,7 @@ public class PetApiTest { api.updatePet(pet).execute(); - List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"})).execute().body(); + List pets = api.findPetsByTags(new CSVParams("friendly")).execute().body(); assertNotNull(pets); boolean found = false; @@ -114,7 +115,7 @@ public class PetApiTest { Pet fetched = api.getPetById(pet.getId()).execute().body(); - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null).execute(); + api.updatePetWithForm(fetched.getId(), "furt", null).execute(); Pet updated = api.getPetById(fetched.getId()).execute().body(); assertEquals(updated.getName(), "furt"); diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index bda483d3fd4..249d5dc4828 100644 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,7 +33,7 @@ public class StoreApiTest { Order order = createOrder(); api.placeOrder(order).execute(); - Order fetched = api.getOrderById(String.valueOf(order.getId())).execute().body(); + Order fetched = api.getOrderById(order.getId()).execute().body(); assertEquals(order.getId(), fetched.getId()); assertEquals(order.getPetId(), fetched.getPetId()); assertEquals(order.getQuantity(), fetched.getQuantity()); @@ -44,12 +44,12 @@ public class StoreApiTest { Order order = createOrder(); Response aa = api.placeOrder(order).execute(); - Order fetched = api.getOrderById(String.valueOf(order.getId())).execute().body(); + Order fetched = api.getOrderById(order.getId()).execute().body(); assertEquals(fetched.getId(), order.getId()); api.deleteOrder(String.valueOf(order.getId())).execute(); - api.getOrderById(String.valueOf(order.getId())).execute(); + api.getOrderById(order.getId()).execute(); //also in retrofit 1 should return an error but don't, check server api impl. } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java index 5582509be76..32799fdf3d8 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java @@ -49,16 +49,8 @@ public class ApiClient { Interceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "test_api_client_id") { - auth = new ApiKeyAuth("header", "x-test_api_client_id"); - } else if (authName == "test_api_client_secret") { - auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); - } else if (authName == "test_api_key_query") { - auth = new ApiKeyAuth("query", "test_api_key_query"); - } else if (authName == "test_api_key_header") { - auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java index 873647cb45e..423a5762822 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-13T14:37:27.438+02:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:05.103+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 5f35286fb30..4a2e64b726e 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,7 +9,7 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.InlineResponse200; +import io.swagger.client.model.ModelApiResponse; import java.io.File; import java.util.ArrayList; @@ -21,7 +21,7 @@ public interface PetApi { /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Call */ @@ -30,18 +30,6 @@ public interface PetApi { @Body Pet body ); - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @return Call - */ - - @POST("pet?testing_byte_array=true") - Observable addPetUsingByteArray( - @Body byte[] body - ); - /** * Deletes a pet * @@ -58,31 +46,31 @@ public interface PetApi { /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter (required) * @return Call> */ @GET("pet/findByStatus") Observable> findPetsByStatus( - @Query("status") List status + @Query("status") CSVParams status ); /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) * @return Call> */ @GET("pet/findByTags") Observable> findPetsByTags( - @Query("tags") List tags + @Query("tags") CSVParams tags ); /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) + * Returns a single pet + * @param petId ID of pet to return (required) * @return Call */ @@ -91,34 +79,10 @@ public interface PetApi { @Path("petId") Long petId ); - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return Call - */ - - @GET("pet/{petId}?response=inline_arbitrary_object") - Observable getPetByIdInObject( - @Path("petId") Long petId - ); - - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched (required) - * @return Call - */ - - @GET("pet/{petId}?testing_byte_array=true") - Observable petPetIdtestingByteArraytrueGet( - @Path("petId") Long petId - ); - /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store (required) * @return Call */ @@ -139,7 +103,7 @@ public interface PetApi { @FormUrlEncoded @POST("pet/{petId}") Observable updatePetWithForm( - @Path("petId") String petId, @Field("name") String name, @Field("status") String status + @Path("petId") Long petId, @Field("name") String name, @Field("status") String status ); /** @@ -148,12 +112,12 @@ public interface PetApi { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return Call + * @return Call */ @Multipart @POST("pet/{petId}/uploadImage") - Observable uploadFile( + Observable uploadFile( @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file\"; filename=\"file\"") RequestBody file ); diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java index a0a60b0e3b6..19be150428b 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/StoreApi.java @@ -28,18 +28,6 @@ public interface StoreApi { @Path("orderId") String orderId ); - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return Call> - */ - - @GET("store/findByStatus") - Observable> findOrdersByStatus( - @Query("status") String status - ); - /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -50,16 +38,6 @@ public interface StoreApi { Observable> getInventory(); - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Call - */ - - @GET("store/inventory?response=arbitrary_object") - Observable getInventoryInObject(); - - /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -69,13 +47,13 @@ public interface StoreApi { @GET("store/order/{orderId}") Observable getOrderById( - @Path("orderId") String orderId + @Path("orderId") Long orderId ); /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet (required) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java index e5a17e2bef9..4cad0d804d7 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/UserApi.java @@ -19,7 +19,7 @@ public interface UserApi { /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object (required) * @return Call */ @@ -31,7 +31,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Call */ @@ -43,7 +43,7 @@ public interface UserApi { /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object (required) * @return Call */ @@ -79,8 +79,8 @@ public interface UserApi { /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return Call */ @@ -103,7 +103,7 @@ public interface UserApi { * Updated user * This can only be done by the logged in user. * @param username name that need to be deleted (required) - * @param body Updated user object (optional) + * @param body Updated user object (required) * @return Call */ diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java deleted file mode 100644 index b17bf005009..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/InlineResponse200.java +++ /dev/null @@ -1,168 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - - -public class InlineResponse200 { - - @SerializedName("tags") - private List tags = new ArrayList(); - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java new file mode 100644 index 00000000000..bb5313b42d4 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -0,0 +1,96 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + + +public class ModelApiResponse { + + @SerializedName("code") + private Integer code = null; + + @SerializedName("type") + private String type = null; + + @SerializedName("message") + private String message = null; + + /** + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java deleted file mode 100644 index 920640ad2cb..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/ObjectReturn.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import com.google.gson.annotations.SerializedName; - - - - -@ApiModel(description = "") -public class ObjectReturn { - - @SerializedName("return") - private Integer _return = null; - - - - /** - **/ - @ApiModelProperty(value = "") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ObjectReturn _return = (ObjectReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ObjectReturn {\n"); - - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java index f1fb2ad7409..196a5702404 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Order.java @@ -52,7 +52,7 @@ public enum StatusEnum { private StatusEnum status = null; @SerializedName("complete") - private Boolean complete = null; + private Boolean complete = false; /** **/ @@ -60,6 +60,9 @@ public enum StatusEnum { public Long getId() { return id; } + public void setId(Long id) { + this.id = id; + } /** **/ diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java index a433321a0f9..e506ec00e9a 100644 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -1,6 +1,7 @@ package io.swagger.petstore.test; import io.swagger.client.ApiClient; +import io.swagger.client.CollectionFormats.*; import io.swagger.client.api.*; import io.swagger.client.model.*; @@ -79,7 +80,7 @@ public class PetApiTest { api.updatePet(pet).subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { - api.findPetsByStatus(Arrays.asList(new String[]{"available"})).subscribe(new SkeletonSubscriber>() { + api.findPetsByStatus(new CSVParams("available")).subscribe(new SkeletonSubscriber>() { @Override public void onNext(List pets) { assertNotNull(pets); @@ -116,7 +117,7 @@ public class PetApiTest { api.updatePet(pet).subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { - api.findPetsByTags(Arrays.asList(new String[]{"friendly"})).subscribe(new SkeletonSubscriber>() { + api.findPetsByTags(new CSVParams("friendly")).subscribe(new SkeletonSubscriber>() { @Override public void onNext(List pets) { assertNotNull(pets); @@ -145,7 +146,7 @@ public class PetApiTest { api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { @Override public void onNext(final Pet fetched) { - api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null) + api.updatePetWithForm(fetched.getId(), "furt", null) .subscribe(new SkeletonSubscriber() { @Override public void onCompleted() { @@ -201,7 +202,7 @@ public class PetApiTest { api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file); - api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { + api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { @Override public void onError(Throwable e) { // this also yields a 400 for other tests, so I guess it's okay... @@ -251,4 +252,4 @@ public class PetApiTest { return pet; } -} \ No newline at end of file +} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 39785f755ca..f5a34eab200 100644 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -36,7 +36,7 @@ public class StoreApiTest { public void testPlaceOrder() throws Exception { final Order order = createOrder(); api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(String.valueOf(order.getId())).subscribe(new SkeletonSubscriber() { + api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { @Override public void onNext(Order fetched) { assertEquals(order.getId(), fetched.getId()); @@ -51,7 +51,7 @@ public class StoreApiTest { final Order order = createOrder(); api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(String.valueOf(order.getId())).subscribe(new SkeletonSubscriber() { + api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { @Override public void onNext(Order fetched) { assertEquals(fetched.getId(), order.getId()); @@ -60,7 +60,7 @@ public class StoreApiTest { api.deleteOrder(String.valueOf(order.getId())).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(String.valueOf(order.getId())) + api.getOrderById(order.getId()) .subscribe(new SkeletonSubscriber() { @Override public void onNext(Order order) { From a63dbeb4c89692a1231203dbc8cf35b6c7bcd9c9 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 17:05:22 +0800 Subject: [PATCH 24/63] fix bug related to api, model doc for java server generator --- .../AbstractJavaJAXRSServerCodegen.java | 9 ++++++ .../languages/JavaInflectorServerCodegen.java | 5 ++++ .../languages/JavaJerseyServerCodegen.java | 6 ++++ .../languages/JavaResteasyServerCodegen.java | 7 ++++- .../languages/SpringMVCServerCodegen.java | 5 ++++ .../gen/java/io/swagger/api/PetApi.java | 6 +++- .../gen/java/io/swagger/api/StoreApi.java | 4 +++ .../gen/java/io/swagger/api/UserApi.java | 4 +++ .../gen/java/io/swagger/model/Category.java | 3 +- .../gen/java/io/swagger/model/Order.java | 28 +++++++++++-------- .../gen/java/io/swagger/model/Pet.java | 28 +++++++++++-------- .../gen/java/io/swagger/model/Tag.java | 3 +- .../gen/java/io/swagger/model/User.java | 3 +- .../gen/java/io/swagger/api/ApiException.java | 2 +- .../java/io/swagger/api/ApiOriginFilter.java | 2 +- .../io/swagger/api/ApiResponseMessage.java | 2 +- .../io/swagger/api/NotFoundException.java | 2 +- .../src/gen/java/io/swagger/api/PetApi.java | 4 +-- .../java/io/swagger/api/PetApiService.java | 4 +-- .../src/gen/java/io/swagger/api/StoreApi.java | 2 +- .../java/io/swagger/api/StoreApiService.java | 2 +- .../gen/java/io/swagger/api/StringUtil.java | 2 +- .../src/gen/java/io/swagger/api/UserApi.java | 2 +- .../java/io/swagger/api/UserApiService.java | 2 +- .../gen/java/io/swagger/model/Category.java | 2 +- .../src/gen/java/io/swagger/model/Order.java | 2 +- .../src/gen/java/io/swagger/model/Pet.java | 2 +- .../src/gen/java/io/swagger/model/Tag.java | 2 +- .../src/gen/java/io/swagger/model/User.java | 2 +- .../src/gen/java/io/swagger/api/PetApi.java | 6 ++-- .../java/io/swagger/api/PetApiService.java | 2 +- .../java/io/swagger/api/ApiException.java | 2 +- .../java/io/swagger/api/ApiOriginFilter.java | 2 +- .../io/swagger/api/ApiResponseMessage.java | 2 +- .../io/swagger/api/NotFoundException.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 12 ++++---- .../main/java/io/swagger/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/api/UserApi.java | 2 +- .../swagger/configuration/SwaggerConfig.java | 2 +- .../configuration/SwaggerUiConfiguration.java | 2 +- .../swagger/configuration/WebApplication.java | 2 +- .../configuration/WebMvcConfiguration.java | 2 +- .../main/java/io/swagger/model/Category.java | 2 +- .../src/main/java/io/swagger/model/Order.java | 2 +- .../src/main/java/io/swagger/model/Pet.java | 2 +- .../src/main/java/io/swagger/model/Tag.java | 2 +- .../src/main/java/io/swagger/model/User.java | 2 +- 47 files changed, 127 insertions(+), 70 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java index 4069dded643..99fab6e5444 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -25,6 +25,15 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen super(); } + @Override + public void processOpts() { + super.processOpts(); + // clear model and api doc template as AbstractJavaJAXRSServerCodegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + } + // ================ // ABSTRACT METHODS // ================ diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java index 24f7fddc524..0cf59e5faa7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaInflectorServerCodegen.java @@ -70,6 +70,11 @@ public class JavaInflectorServerCodegen extends JavaClientCodegen { public void processOpts() { super.processOpts(); + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + supportingFiles.clear(); writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java index 3b3a6dbc280..52f3eb8d844 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java @@ -20,6 +20,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { apiTemplateFiles.put("apiService.mustache", ".java"); apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); apiTemplateFiles.put("apiServiceFactory.mustache", ".java"); + apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; @@ -72,6 +73,11 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { public void processOpts() { super.processOpts(); + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java index 060c96c317e..5f715a43621 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaResteasyServerCodegen.java @@ -84,6 +84,11 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code public void processOpts() { super.processOpts(); + // clear model and api doc template as AbstractJavaJAXRSServerCodegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + if (additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); } @@ -342,4 +347,4 @@ public class JavaResteasyServerCodegen extends JavaClientCodegen implements Code } return; } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java index 1dd66c6400d..41d17a3e807 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringMVCServerCodegen.java @@ -59,6 +59,11 @@ public class SpringMVCServerCodegen extends JavaClientCodegen { public void processOpts() { super.processOpts(); + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + if (additionalProperties.containsKey(CONFIG_PACKAGE)) { this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE)); } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java index 2e8ef241f49..52ca606b544 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/PetApi.java @@ -1,9 +1,13 @@ package io.swagger.api; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java index 39ffe2436a8..b7ccabe7d8b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/StoreApi.java @@ -3,6 +3,10 @@ package io.swagger.api; import java.util.Map; import io.swagger.model.Order; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java index 19e5ab04f3a..8874d96a519 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java @@ -3,6 +3,10 @@ package io.swagger.api; import io.swagger.model.User; import java.util.List; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; import javax.ws.rs.*; import javax.ws.rs.core.Response; diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java index f2d34f77367..2b2d460203b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Category.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Category", propOrder = { "id", "name" }) diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java index 3a9cbf3c130..b0babb254e7 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Order.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Order", propOrder = { "id", "petId", "quantity", "shipDate", "status", "complete" }) @@ -26,19 +27,24 @@ public class Order { private javax.xml.datatype.XMLGregorianCalendar shipDate = null; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name="Order") +@XmlType(name="StatusEnum") @XmlEnum -public enum Order { - {values=[placed, approved, delivered], enumVars=[{name=PLACED, value=placed}, {name=APPROVED, value=approved}, {name=DELIVERED, value=delivered}]}, - - public String value() { - return name(); +public enum StatusEnum { + + PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered")); + + + private String value; + + StatusEnum (String v) { + value = v; } - public static Order fromValue(String v) { + public String value() { + return value; + } + + public static StatusEnum fromValue(String v) { return valueOf(v); } } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java index 707f90a3af8..58a58752122 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Pet.java @@ -12,9 +12,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Pet", propOrder = { "id", "category", "name", "photoUrls", "tags", "status" }) @@ -32,19 +33,24 @@ public class Pet { private List tags = new ArrayList(); -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name="Pet") +@XmlType(name="StatusEnum") @XmlEnum -public enum Pet { - {values=[available, pending, sold], enumVars=[{name=AVAILABLE, value=available}, {name=PENDING, value=pending}, {name=SOLD, value=sold}]}, - - public String value() { - return name(); +public enum StatusEnum { + + AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold")); + + + private String value; + + StatusEnum (String v) { + value = v; } - public static Pet fromValue(String v) { + public String value() { + return value; + } + + public static StatusEnum fromValue(String v) { return valueOf(v); } } diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java index 1912fa6f731..4e1921add9b 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/Tag.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "Tag", propOrder = { "id", "name" }) diff --git a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java index c35af076cf6..007344a2687 100644 --- a/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/model/User.java @@ -8,9 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlEnum; @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "", propOrder = + @XmlType(name = "User", propOrder = { "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus" }) diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java index 2a519b09b8b..50210d9df08 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java index a7a3a461a1d..759e1b5bd64 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class ApiOriginFilter implements javax.servlet.Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java index 07f1fd78fe0..5192962e40d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java index a8a136f8760..8d1f8e2fad8 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java index 8beeb2b7a93..0f00546008d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java @@ -5,8 +5,8 @@ import io.swagger.api.PetApiService; import io.swagger.api.factories.PetApiServiceFactory; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -22,7 +22,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; @Path("/pet") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java index 4d65977483c..c278574cf2a 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java @@ -6,8 +6,8 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -17,7 +17,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public abstract class PetApiService { public abstract Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java index e6ab3511835..80a950898bc 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/store") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java index c246af6e58e..947b815ad7e 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public abstract class StoreApiService { public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java index c358c74b469..cd6810659dc 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java index 966965db529..e652de73ec7 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/user") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java index a656efd6f72..8b9dd490166 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public abstract class UserApiService { public abstract Response createUser(User body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java index c74992a36ba..3469051578d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java index 7d1093ec0e2..c26eb96f683 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java @@ -9,7 +9,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java index c763a801181..ea69764da9b 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java @@ -11,7 +11,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java index 3046b9ff951..9efeecd5158 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java index 924d72b9bcc..dc970c9f116 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") public class User { private Long id = null; diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java index e439e48d212..6ab33888e61 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApi.java @@ -9,8 +9,8 @@ import io.swagger.annotations.ApiParam; import com.sun.jersey.multipart.FormDataParam; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; @@ -169,14 +169,14 @@ public class PetApi { @Path("/{petId}/uploadImage") @Consumes({ "multipart/form-data" }) @Produces({ "application/json" }) - @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ApiResponse.class, authorizations = { + @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") }) }, tags={ "pet" }) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ApiResponse.class) }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) public Response uploadFile( @ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId, @FormDataParam("additionalMetadata") String additionalMetadata, diff --git a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java index 7a2d8b60585..4cf67d11f3e 100644 --- a/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/PetApiService.java @@ -6,8 +6,8 @@ import io.swagger.model.*; import com.sun.jersey.multipart.FormDataParam; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import java.util.List; import io.swagger.api.NotFoundException; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java index 74ea4cbc4c7..53bd9eb6ef6 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java index d174ef951f4..0a795c96f26 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java index d53fb5b1bf7..7bca7cae2ed 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java index 077573dfcd5..55dc1565146 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 3db41f8b7b1..057248fac0a 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -3,8 +3,8 @@ package io.swagger.api; import io.swagger.model.*; import io.swagger.model.Pet; -import io.swagger.model.ApiResponse; import java.io.File; +import io.swagger.model.ModelApiResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -32,7 +32,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/pet", description = "the pet API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class PetApi { @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { @@ -206,19 +206,19 @@ public class PetApi { } - @ApiOperation(value = "uploads an image", notes = "", response = ApiResponse.class, authorizations = { + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { @Authorization(value = "petstore_auth", scopes = { @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "read:pets", description = "read your pets") }) }) @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ApiResponse.class) }) + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @RequestMapping(value = "/{petId}/uploadImage", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) - public ResponseEntity uploadFile( + public ResponseEntity uploadFile( @ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId , @@ -233,7 +233,7 @@ public class PetApi { ) throws NotFoundException { // do some magic! - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity(HttpStatus.OK); } } diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index 916532b6bce..d75467920f2 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/store", description = "the store API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class StoreApi { @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index c7bd55fd05b..86bf60c807c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/user", description = "the user API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class UserApi { @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java index 2e99e717296..ca3ca4b9391 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java @@ -18,7 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java index e552ecc15fb..4853295c868 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java index ea9b029ba8d..43649b562a2 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java @@ -2,7 +2,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java index 61bfeda1555..0d16189e69d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java @@ -3,7 +3,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index a59702faace..f886df7229c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index 9dd2d718ba3..dc4c9182d1d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -13,7 +13,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 2a85f8f23c5..5ac272d9b7d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -16,7 +16,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 911ea429dc7..3011a3bdd0a 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index 1bb2c285432..dc842b30691 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") public class User { private Long id = null; From 2f365b0a168ffdf6092c57a48d9df3aa5a7050dc Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 17:38:00 +0800 Subject: [PATCH 25/63] add new model file --- .../io/swagger/model/ModelApiResponse.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..26dd2b51282 --- /dev/null +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,85 @@ +package io.swagger.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import io.swagger.annotations.*; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; + + +@ApiModel(description = "") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(code).append("\n"); + sb.append(" type: ").append(type).append("\n"); + sb.append(" message: ").append(message).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} From 920dbb2183de742c5aaf46f377cbe72d3eac0943 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 17:55:02 +0800 Subject: [PATCH 26/63] regenerate petstore sample for springmv --- .../java/io/swagger/api/ApiException.java | 2 +- .../java/io/swagger/api/ApiOriginFilter.java | 2 +- .../io/swagger/api/ApiResponseMessage.java | 2 +- .../io/swagger/api/NotFoundException.java | 2 +- .../src/main/java/io/swagger/api/PetApi.java | 2 +- .../api/PettestingByteArraytrueApi.java | 56 ----- .../main/java/io/swagger/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/api/UserApi.java | 2 +- .../swagger/configuration/SwaggerConfig.java | 2 +- .../configuration/SwaggerUiConfiguration.java | 2 +- .../swagger/configuration/WebApplication.java | 2 +- .../configuration/WebMvcConfiguration.java | 2 +- .../main/java/io/swagger/model/Animal.java | 57 ----- .../java/io/swagger/model/ApiResponse.java | 85 ------- .../src/main/java/io/swagger/model/Cat.java | 72 ------ .../main/java/io/swagger/model/Category.java | 2 +- .../src/main/java/io/swagger/model/Dog.java | 72 ------ .../java/io/swagger/model/FormatTest.java | 213 ------------------ .../io/swagger/model/InlineResponse200.java | 136 ----------- .../io/swagger/model/Model200Response.java | 60 ----- .../io/swagger/model/ModelApiResponse.java | 2 +- .../java/io/swagger/model/ModelReturn.java | 60 ----- .../src/main/java/io/swagger/model/Name.java | 74 ------ .../src/main/java/io/swagger/model/Order.java | 2 +- .../src/main/java/io/swagger/model/Pet.java | 2 +- .../io/swagger/model/SpecialModelName.java | 57 ----- .../src/main/java/io/swagger/model/Tag.java | 2 +- .../src/main/java/io/swagger/model/User.java | 2 +- 28 files changed, 17 insertions(+), 959 deletions(-) delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java delete mode 100644 samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java index 53bd9eb6ef6..cdd9e904098 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java index 0a795c96f26..1b6e847cc10 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiOriginFilter implements javax.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java index 7bca7cae2ed..52c47326b30 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java index 55dc1565146..a5bb52fc58b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java index 057248fac0a..3e79c004237 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApi.java @@ -32,7 +32,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/pet", description = "the pet API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class PetApi { @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java deleted file mode 100644 index f7912cb4d28..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PettestingByteArraytrueApi.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.AuthorizationScope; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -import static org.springframework.http.MediaType.*; - -@Controller -@RequestMapping(value = "/pet?testing_byte_array=true", produces = {APPLICATION_JSON_VALUE}) -@Api(value = "/pet?testing_byte_array=true", description = "the pet?testing_byte_array=true API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class PettestingByteArraytrueApi { - - @ApiOperation(value = "Fake endpoint to test byte array in body parameter for adding a new pet to the store", notes = "", response = Void.class, authorizations = { - @Authorization(value = "petstore_auth", scopes = { - @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), - @AuthorizationScope(scope = "read:pets", description = "read your pets") - }) - }) - @io.swagger.annotations.ApiResponses(value = { - @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") }) - @RequestMapping(value = "", - produces = { "application/json", "application/xml" }, - consumes = { "application/json", "application/xml" }, - method = RequestMethod.POST) - public ResponseEntity addPetUsingByteArray( - -@ApiParam(value = "Pet object in the form of byte array" ) @RequestBody byte[] body -) - throws NotFoundException { - // do some magic! - return new ResponseEntity(HttpStatus.OK); - } - -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java index d75467920f2..b9b4dc22e47 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/StoreApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/store", description = "the store API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class StoreApi { @ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java index 86bf60c807c..777724026c7 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/UserApi.java @@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.*; @Controller @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/user", description = "the user API") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class UserApi { @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java index ca3ca4b9391..0f81ad7d00f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerConfig.java @@ -18,7 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 //Loads the spring beans required by the framework @PropertySource("classpath:swagger.properties") @Import(SwaggerUiConfiguration.class) -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class SwaggerConfig { @Bean ApiInfo apiInfo() { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java index 4853295c868..b228de3b07c 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @Configuration @EnableWebMvc -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java index 43649b562a2..a505241d556 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebApplication.java @@ -2,7 +2,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { @Override diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java index 0d16189e69d..e1ba8c520a8 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/configuration/WebMvcConfiguration.java @@ -3,7 +3,7 @@ package io.swagger.configuration; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class WebMvcConfiguration extends WebMvcConfigurationSupport { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java deleted file mode 100644 index ff0afdd4f86..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Animal.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Animal { - - private String className = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Animal animal = (Animal) o; - return Objects.equals(className, animal.className); - } - - @Override - public int hashCode() { - return Objects.hash(className); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Animal {\n"); - - sb.append(" className: ").append(className).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java deleted file mode 100644 index 31e09116e3a..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ApiResponse.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-17T17:49:05.879+08:00") -public class ApiResponse { - - private Integer code = null; - private String type = null; - private String message = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("code") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ApiResponse apiResponse = (ApiResponse) o; - return Objects.equals(code, apiResponse.code) && - Objects.equals(type, apiResponse.type) && - Objects.equals(message, apiResponse.message); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ApiResponse {\n"); - - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java deleted file mode 100644 index 884c739d46d..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Cat.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Cat extends Animal { - - private String className = null; - private Boolean declawed = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("declawed") - public Boolean getDeclawed() { - return declawed; - } - public void setDeclawed(Boolean declawed) { - this.declawed = declawed; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Cat cat = (Cat) o; - return Objects.equals(className, cat.className) && - Objects.equals(declawed, cat.declawed); - } - - @Override - public int hashCode() { - return Objects.hash(className, declawed); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Cat {\n"); - sb.append(" " + super.toString()).append("\n"); - sb.append(" className: ").append(className).append("\n"); - sb.append(" declawed: ").append(declawed).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index f886df7229c..f3e03a8c88f 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java deleted file mode 100644 index 856fb7a0e66..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Dog.java +++ /dev/null @@ -1,72 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Animal; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Dog extends Animal { - - private String className = null; - private String breed = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("className") - public String getClassName() { - return className; - } - public void setClassName(String className) { - this.className = className; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("breed") - public String getBreed() { - return breed; - } - public void setBreed(String breed) { - this.breed = breed; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Dog dog = (Dog) o; - return Objects.equals(className, dog.className) && - Objects.equals(breed, dog.breed); - } - - @Override - public int hashCode() { - return Objects.hash(className, breed); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Dog {\n"); - sb.append(" " + super.toString()).append("\n"); - sb.append(" className: ").append(className).append("\n"); - sb.append(" breed: ").append(breed).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java deleted file mode 100644 index 309ffd11616..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/FormatTest.java +++ /dev/null @@ -1,213 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; -import java.util.Date; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class FormatTest { - - private Integer integer = null; - private Integer int32 = null; - private Long int64 = null; - private BigDecimal number = null; - private Float _float = null; - private Double _double = null; - private String string = null; - private byte[] _byte = null; - private byte[] binary = null; - private Date date = null; - private Date dateTime = null; - private String password = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("integer") - public Integer getInteger() { - return integer; - } - public void setInteger(Integer integer) { - this.integer = integer; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("int32") - public Integer getInt32() { - return int32; - } - public void setInt32(Integer int32) { - this.int32 = int32; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("int64") - public Long getInt64() { - return int64; - } - public void setInt64(Long int64) { - this.int64 = int64; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("number") - public BigDecimal getNumber() { - return number; - } - public void setNumber(BigDecimal number) { - this.number = number; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("float") - public Float getFloat() { - return _float; - } - public void setFloat(Float _float) { - this._float = _float; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("double") - public Double getDouble() { - return _double; - } - public void setDouble(Double _double) { - this._double = _double; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("string") - public String getString() { - return string; - } - public void setString(String string) { - this.string = string; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("byte") - public byte[] getByte() { - return _byte; - } - public void setByte(byte[] _byte) { - this._byte = _byte; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("binary") - public byte[] getBinary() { - return binary; - } - public void setBinary(byte[] binary) { - this.binary = binary; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("date") - public Date getDate() { - return date; - } - public void setDate(Date date) { - this.date = date; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("dateTime") - public Date getDateTime() { - return dateTime; - } - public void setDateTime(Date dateTime) { - this.dateTime = dateTime; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("password") - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - FormatTest formatTest = (FormatTest) o; - return Objects.equals(integer, formatTest.integer) && - Objects.equals(int32, formatTest.int32) && - Objects.equals(int64, formatTest.int64) && - Objects.equals(number, formatTest.number) && - Objects.equals(_float, formatTest._float) && - Objects.equals(_double, formatTest._double) && - Objects.equals(string, formatTest.string) && - Objects.equals(_byte, formatTest._byte) && - Objects.equals(binary, formatTest.binary) && - Objects.equals(date, formatTest.date) && - Objects.equals(dateTime, formatTest.dateTime) && - Objects.equals(password, formatTest.password); - } - - @Override - public int hashCode() { - return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, password); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class FormatTest {\n"); - - sb.append(" integer: ").append(integer).append("\n"); - sb.append(" int32: ").append(int32).append("\n"); - sb.append(" int64: ").append(int64).append("\n"); - sb.append(" number: ").append(number).append("\n"); - sb.append(" _float: ").append(_float).append("\n"); - sb.append(" _double: ").append(_double).append("\n"); - sb.append(" string: ").append(string).append("\n"); - sb.append(" _byte: ").append(_byte).append("\n"); - sb.append(" binary: ").append(binary).append("\n"); - sb.append(" date: ").append(date).append("\n"); - sb.append(" dateTime: ").append(dateTime).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java deleted file mode 100644 index 9b7bd64697e..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/InlineResponse200.java +++ /dev/null @@ -1,136 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - public enum StatusEnum { - available, pending, sold, - }; - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java deleted file mode 100644 index d0babbf10ba..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Model200Response.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing model name starting with number - **/ -@ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Model200Response { - - private Integer name = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Model200Response _200Response = (Model200Response) o; - return Objects.equals(name, _200Response.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Model200Response {\n"); - - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java index 26dd2b51282..327e9bb92d3 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java deleted file mode 100644 index 04b1ea734f2..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelReturn.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing reserved words - **/ -@ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class ModelReturn { - - private Integer _return = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("return") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelReturn _return = (ModelReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelReturn {\n"); - - sb.append(" _return: ").append(_return).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java deleted file mode 100644 index 475abe42028..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Name.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -/** - * Model for testing model name same as property name - **/ -@ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class Name { - - private Integer name = null; - private Integer snakeCase = null; - - /** - **/ - @ApiModelProperty(required = true, value = "") - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("snake_case") - public Integer getSnakeCase() { - return snakeCase; - } - public void setSnakeCase(Integer snakeCase) { - this.snakeCase = snakeCase; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Name name = (Name) o; - return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); - } - - @Override - public int hashCode() { - return Objects.hash(name, snakeCase); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Name {\n"); - - sb.append(" name: ").append(name).append("\n"); - sb.append(" snakeCase: ").append(snakeCase).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index dc4c9182d1d..ed04a25a4a9 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -13,7 +13,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 5ac272d9b7d..b725b22c44d 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -16,7 +16,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java deleted file mode 100644 index 0aaad51d9f3..00000000000 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/SpecialModelName.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.swagger.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; - - -@ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-15T00:36:54.567+08:00") -public class SpecialModelName { - - private Long specialPropertyName = null; - - /** - **/ - @ApiModelProperty(value = "") - @JsonProperty("$special[property.name]") - public Long getSpecialPropertyName() { - return specialPropertyName; - } - public void setSpecialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SpecialModelName specialModelName = (SpecialModelName) o; - return Objects.equals(specialPropertyName, specialModelName.specialPropertyName); - } - - @Override - public int hashCode() { - return Objects.hash(specialPropertyName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SpecialModelName {\n"); - - sb.append(" specialPropertyName: ").append(specialPropertyName).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 3011a3bdd0a..97e11f1f5ab 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index dc842b30691..88615e98517 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -11,7 +11,7 @@ import java.util.Objects; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:03:40.798+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00") public class User { private Long id = null; From 7419d8634bfb9c3c19c0e98bf8889e0149a141b1 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 19:34:48 +0800 Subject: [PATCH 27/63] update jaxrs and jaxrs-resteasy petstore sample --- .../gen/java/io/swagger/api/ApiException.java | 2 +- .../java/io/swagger/api/ApiOriginFilter.java | 2 +- .../io/swagger/api/ApiResponseMessage.java | 2 +- .../io/swagger/api/NotFoundException.java | 2 +- .../src/gen/java/io/swagger/api/PetApi.java | 2 +- .../java/io/swagger/api/PetApiService.java | 2 +- .../api/PettestingByteArraytrueApi.java | 33 ---- .../PettestingByteArraytrueApiService.java | 22 --- .../src/gen/java/io/swagger/api/StoreApi.java | 2 +- .../java/io/swagger/api/StoreApiService.java | 2 +- .../gen/java/io/swagger/api/StringUtil.java | 2 +- .../src/gen/java/io/swagger/api/UserApi.java | 2 +- .../java/io/swagger/api/UserApiService.java | 2 +- .../gen/java/io/swagger/model/Category.java | 2 +- .../io/swagger/model/InlineResponse200.java | 166 ------------------ .../java/io/swagger/model/ModelReturn.java | 68 ------- .../src/gen/java/io/swagger/model/Name.java | 68 ------- .../src/gen/java/io/swagger/model/Order.java | 2 +- .../src/gen/java/io/swagger/model/Pet.java | 2 +- .../io/swagger/model/SpecialModelName.java | 68 ------- .../src/gen/java/io/swagger/model/Tag.java | 2 +- .../src/gen/java/io/swagger/model/User.java | 2 +- ...testingByteArraytrueApiServiceFactory.java | 15 -- ...PettestingByteArraytrueApiServiceImpl.java | 29 --- .../io/swagger/model/ModelApiResponse.java} | 37 +++- 25 files changed, 44 insertions(+), 494 deletions(-) delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java delete mode 100644 samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java rename samples/server/petstore/{jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java => jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java} (67%) diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java index 50210d9df08..24a37938400 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiException extends Exception{ private int code; public ApiException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java index 759e1b5bd64..48b4d658725 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiOriginFilter.java @@ -5,7 +5,7 @@ import java.io.IOException; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiOriginFilter implements javax.servlet.Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java index 5192962e40d..b1b2df77e20 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/ApiResponseMessage.java @@ -3,7 +3,7 @@ package io.swagger.api; import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java index 8d1f8e2fad8..77bd497a379 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/NotFoundException.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class NotFoundException extends ApiException { private int code; public NotFoundException (int code, String msg) { diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java index 0f00546008d..11870e95f1e 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApi.java @@ -22,7 +22,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; @Path("/pet") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class PetApi { private final PetApiService delegate = PetApiServiceFactory.getPetApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java index c278574cf2a..def447f5695 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PetApiService.java @@ -17,7 +17,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class PetApiService { public abstract Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java deleted file mode 100644 index 8c742e89268..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApi.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.swagger.api; - -import io.swagger.model.*; -import io.swagger.api.PettestingByteArraytrueApiService; -import io.swagger.api.factories.PettestingByteArraytrueApiServiceFactory; - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; - -@Path("/pet?testing_byte_array=true") - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class PettestingByteArraytrueApi { - private final PettestingByteArraytrueApiService delegate = PettestingByteArraytrueApiServiceFactory.getPettestingByteArraytrueApi(); - - @POST - - @Consumes({ "application/json", "application/xml" }) - @Produces({ "application/json", "application/xml" }) - public Response addPetUsingByteArray( byte[] body,@Context SecurityContext securityContext) - throws NotFoundException { - return delegate.addPetUsingByteArray(body,securityContext); - } -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java deleted file mode 100644 index 08186045b71..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/PettestingByteArraytrueApiService.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.swagger.api; - -import io.swagger.api.*; -import io.swagger.model.*; - - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public abstract class PettestingByteArraytrueApiService { - - public abstract Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) - throws NotFoundException; - -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java index 80a950898bc..dea36a07275 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/store") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class StoreApi { private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java index 947b815ad7e..dc740cd491d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StoreApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class StoreApiService { public abstract Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java index cd6810659dc..0cfee024b00 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.api; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java index e652de73ec7..02e6d6b24da 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApi.java @@ -20,7 +20,7 @@ import javax.ws.rs.*; @Path("/user") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class UserApi { private final UserApiService delegate = UserApiServiceFactory.getUserApi(); diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java index 8b9dd490166..e900b146061 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/api/UserApiService.java @@ -15,7 +15,7 @@ import java.io.InputStream; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public abstract class UserApiService { public abstract Response createUser(User body,SecurityContext securityContext) throws NotFoundException; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java index 3469051578d..bfeecafe689 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Category.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Category { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java deleted file mode 100644 index 408a4ccdb0e..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/InlineResponse200.java +++ /dev/null @@ -1,166 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.model.Tag; -import java.util.List; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class InlineResponse200 { - - private List tags = new ArrayList(); - private Long id = null; - private Object category = null; - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - private String name = null; - private List photoUrls = new ArrayList(); - - - /** - **/ - - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - **/ - - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - * pet status in the store - **/ - - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - /** - **/ - - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InlineResponse200 inlineResponse200 = (InlineResponse200) o; - return Objects.equals(tags, inlineResponse200.tags) && - Objects.equals(id, inlineResponse200.id) && - Objects.equals(category, inlineResponse200.category) && - Objects.equals(status, inlineResponse200.status) && - Objects.equals(name, inlineResponse200.name) && - Objects.equals(photoUrls, inlineResponse200.photoUrls); - } - - @Override - public int hashCode() { - return Objects.hash(tags, id, category, status, name, photoUrls); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InlineResponse200 {\n"); - - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java deleted file mode 100644 index a7ab3bb3df6..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelReturn.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class ModelReturn { - - private Integer _return = null; - - - /** - **/ - - @JsonProperty("return") - public Integer getReturn() { - return _return; - } - public void setReturn(Integer _return) { - this._return = _return; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelReturn _return = (ModelReturn) o; - return Objects.equals(_return, _return._return); - } - - @Override - public int hashCode() { - return Objects.hash(_return); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelReturn {\n"); - - sb.append(" _return: ").append(toIndentedString(_return)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java deleted file mode 100644 index ff879eeb209..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Name.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class Name { - - private Integer name = null; - - - /** - **/ - - @JsonProperty("name") - public Integer getName() { - return name; - } - public void setName(Integer name) { - this.name = name; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Name name = (Name) o; - return Objects.equals(name, name.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Name {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java index c26eb96f683..e8af2984ef9 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Order.java @@ -9,7 +9,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Order { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java index ea69764da9b..740ed352c9d 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Pet.java @@ -11,7 +11,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Pet { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java deleted file mode 100644 index f5c2edcb253..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/SpecialModelName.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-03-16T14:27:58.108+08:00") -public class SpecialModelName { - - private Long specialPropertyName = null; - - - /** - **/ - - @JsonProperty("$special[property.name]") - public Long getSpecialPropertyName() { - return specialPropertyName; - } - public void setSpecialPropertyName(Long specialPropertyName) { - this.specialPropertyName = specialPropertyName; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SpecialModelName specialModelName = (SpecialModelName) o; - return Objects.equals(specialPropertyName, specialModelName.specialPropertyName); - } - - @Override - public int hashCode() { - return Objects.hash(specialPropertyName); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SpecialModelName {\n"); - - sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java index 9efeecd5158..0a7e01df75b 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/Tag.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class Tag { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java index dc970c9f116..3c144892193 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/User.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonValue; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T16:59:08.714+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") public class User { private Long id = null; diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java deleted file mode 100644 index 42f4715fad4..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/factories/PettestingByteArraytrueApiServiceFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.swagger.api.factories; - -import io.swagger.api.PettestingByteArraytrueApiService; -import io.swagger.api.impl.PettestingByteArraytrueApiServiceImpl; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") -public class PettestingByteArraytrueApiServiceFactory { - - private final static PettestingByteArraytrueApiService service = new PettestingByteArraytrueApiServiceImpl(); - - public static PettestingByteArraytrueApiService getPettestingByteArraytrueApi() - { - return service; - } -} diff --git a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java b/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java deleted file mode 100644 index 5a3c2519b03..00000000000 --- a/samples/server/petstore/jaxrs-resteasy/src/main/java/io/swagger/api/impl/PettestingByteArraytrueApiServiceImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.swagger.api.impl; - -import io.swagger.api.*; -import io.swagger.model.*; - - - - -import java.util.List; -import io.swagger.api.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-02-04T01:58:20.368+07:00") - -public class PettestingByteArraytrueApiServiceImpl extends PettestingByteArraytrueApiService { - - @Override - public Response addPetUsingByteArray(byte[] body,SecurityContext securityContext) - throws NotFoundException { - // do some magic! - return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); - } - -} - diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java similarity index 67% rename from samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java rename to samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java index f67a16b28e6..5e3aa82bbee 100644 --- a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ApiResponse.java +++ b/samples/server/petstore/jaxrs/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -1,15 +1,16 @@ package io.swagger.model; import java.util.Objects; -import java.util.ArrayList; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-15T18:10:39.667+08:00") -public class ApiResponse { + + +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -17,7 +18,13 @@ public class ApiResponse { /** **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("code") public Integer getCode() { return code; @@ -28,7 +35,13 @@ public class ApiResponse { /** **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("type") public String getType() { return type; @@ -39,7 +52,13 @@ public class ApiResponse { /** **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("message") public String getMessage() { return message; @@ -57,10 +76,10 @@ public class ApiResponse { if (o == null || getClass() != o.getClass()) { return false; } - ApiResponse apiResponse = (ApiResponse) o; - return Objects.equals(code, apiResponse.code) && - Objects.equals(type, apiResponse.type) && - Objects.equals(message, apiResponse.message); + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); } @Override @@ -71,7 +90,7 @@ public class ApiResponse { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ApiResponse {\n"); + sb.append("class ModelApiResponse {\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); From ebab222c63c525b9840e69c4a5d1986423dbaea1 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 19:56:01 +0800 Subject: [PATCH 28/63] add new file for jaxrs resteasy --- .../io/swagger/model/ModelApiResponse.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java diff --git a/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..a46b64b8bbd --- /dev/null +++ b/samples/server/petstore/jaxrs-resteasy/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,94 @@ +package io.swagger.model; + +import java.util.Objects; +import java.util.ArrayList; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaResteasyServerCodegen", date = "2016-04-22T19:32:21.945+08:00") +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + + @JsonProperty("code") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + + @JsonProperty("type") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + + @JsonProperty("message") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + From 8c27f296fbb968df4d31ca49efb333af788db15a Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 22 Apr 2016 23:13:12 +0800 Subject: [PATCH 29/63] update maven and gradle version for java api client --- .../main/resources/Java/build.gradle.mustache | 8 +++--- .../libraries/feign/build.gradle.mustache | 10 ++++--- .../Java/libraries/feign/pom.mustache | 6 ++--- .../libraries/jersey2/build.gradle.mustache | 8 +++--- .../Java/libraries/jersey2/pom.mustache | 6 ++--- .../okhttp-gson/build.gradle.mustache | 8 +++--- .../libraries/okhttp-gson/build.sbt.mustache | 10 +++---- .../Java/libraries/okhttp-gson/pom.mustache | 4 +-- .../libraries/retrofit/build.gradle.mustache | 6 ++--- .../Java/libraries/retrofit/pom.mustache | 4 +-- .../libraries/retrofit2/build.gradle.mustache | 8 +++--- .../Java/libraries/retrofit2/pom.mustache | 4 +-- .../src/main/resources/Java/pom.mustache | 6 ++--- .../client/petstore/java/default/build.gradle | 8 +++--- .../client/petstore/java/default/docs/Name.md | 1 + samples/client/petstore/java/default/pom.xml | 6 ++--- .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/model/Name.java | 24 +++++++++++++++-- .../client/petstore/java/feign/build.gradle | 10 ++++--- samples/client/petstore/java/feign/pom.xml | 10 +++---- .../io/swagger/client/FormAwareEncoder.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 4 +-- .../java/io/swagger/client/api/StoreApi.java | 2 +- .../java/io/swagger/client/api/UserApi.java | 2 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 2 +- .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 26 ++++++++++++++++--- .../java/io/swagger/client/model/Order.java | 2 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../client/petstore/java/jersey2/build.gradle | 6 ++--- .../client/petstore/java/jersey2/docs/Name.md | 1 + samples/client/petstore/java/jersey2/pom.xml | 10 +++---- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/JSON.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 4 +-- .../java/io/swagger/client/api/StoreApi.java | 2 +- .../java/io/swagger/client/api/UserApi.java | 2 +- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/model/Animal.java | 2 +- .../java/io/swagger/client/model/Cat.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Dog.java | 2 +- .../io/swagger/client/model/FormatTest.java | 2 +- .../client/model/Model200Response.java | 2 +- .../client/model/ModelApiResponse.java | 2 +- .../io/swagger/client/model/ModelReturn.java | 2 +- .../java/io/swagger/client/model/Name.java | 26 ++++++++++++++++--- .../java/io/swagger/client/model/Order.java | 2 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../client/model/SpecialModelName.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../petstore/java/okhttp-gson/build.gradle | 8 +++--- .../petstore/java/okhttp-gson/build.sbt | 10 +++---- .../petstore/java/okhttp-gson/docs/Name.md | 1 + .../client/petstore/java/okhttp-gson/pom.xml | 4 +-- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/model/Name.java | 19 ++++++++++++-- .../petstore/java/retrofit/build.gradle | 6 ++--- samples/client/petstore/java/retrofit/pom.xml | 8 +++--- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/model/Name.java | 19 ++++++++++++-- .../petstore/java/retrofit2/build.gradle | 6 ++--- .../client/petstore/java/retrofit2/pom.xml | 6 ++--- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/model/Name.java | 19 ++++++++++++-- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/model/Name.java | 19 ++++++++++++-- 92 files changed, 292 insertions(+), 165 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache index 7dfb69db418..9920a371e5d 100644 --- a/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "1.18" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "1.19.1" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache index f644a9deda6..35d06f01019 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/build.gradle.mustache @@ -94,11 +94,12 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.6.3" - feign_version = "8.1.1" - jodatime_version = "2.5" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + feign_version = "8.16.0" + jodatime_version = "2.9.3" junit_version = "4.12" + oltu_version = "1.0.1" } dependencies { @@ -111,6 +112,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" compile "joda-time:joda-time:$jodatime_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" compile "com.brsanthu:migbase64:2.2" testCompile "junit:junit:$junit_version" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache index 5ff827ff40c..d75158d094b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache @@ -180,9 +180,9 @@ 1.5.8 - 8.1.1 - 2.6.3 - 2.5 + 8.16.0 + 2.7.0 + 2.9.3 4.12 1.0.0 1.0.0 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache index c533c34558d..aa0e6da3fb0 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "2.22" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "2.22.2" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache index 13fab8b0ed2..ea940cc0753 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -195,9 +195,9 @@ 1.5.8 - 2.22 - 2.4.2 - 2.3 + 2.22.2 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache index d033d9a1c68..4e7b0d1c395 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache @@ -94,9 +94,9 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.0' - compile 'com.squareup.okhttp:okhttp:2.7.2' - compile 'com.squareup.okhttp:logging-interceptor:2.7.2' - compile 'com.google.code.gson:gson:2.3.1' + compile 'io.swagger:swagger-annotations:1.5.8' + compile 'com.squareup.okhttp:okhttp:2.7.5' + compile 'com.squareup.okhttp:logging-interceptor:2.7.5' + compile 'com.google.code.gson:gson:2.6.2' testCompile 'junit:junit:4.12' } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache index 50e843248fb..bee8e03fa0e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/build.sbt.mustache @@ -9,10 +9,10 @@ lazy val root = (project in file(".")). publishArtifact in (Compile, packageDoc) := false, resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( - "io.swagger" % "swagger-annotations" % "1.5.0", - "com.squareup.okhttp" % "okhttp" % "2.7.2", - "com.squareup.okhttp" % "logging-interceptor" % "2.7.2", - "com.google.code.gson" % "gson" % "2.3.1", - "junit" % "junit" % "4.8.1" % "test" + "io.swagger" % "swagger-annotations" % "1.5.8", + "com.squareup.okhttp" % "okhttp" % "2.7.5", + "com.squareup.okhttp" % "logging-interceptor" % "2.7.5", + "com.google.code.gson" % "gson" % "2.6.2", + "junit" % "junit" % "4.12.0" % "test" ) ) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache index bbcbeca4367..01672549e8e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache @@ -160,8 +160,8 @@ 1.5.8 - 2.7.2 - 2.3.1 + 2.7.5 + 2.6.2 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache index 19b741034e7..6be9ba586f3 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/build.gradle.mustache @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - okhttp_version = "2.3.0" - oltu_version = "1.0.0" + okhttp_version = "2.7.5" + oltu_version = "1.0.1" retrofit_version = "1.9.0" - swagger_annotations_version = "1.5.0" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache index 2370cf4a211..2d416a57f24 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache @@ -139,8 +139,8 @@ 1.5.8 1.9.0 - 2.4.0 - 1.0.0 + 2.7.5 + 1.0.1 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 1bced5a0452..1be055c1fff 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -94,13 +94,13 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" + oltu_version = "1.0.1" retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + gson_version = "2.6.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" {{#useRxJava}} - rx_java_version = "1.0.16" + rx_java_version = "1.1.3" {{/useRxJava}} {{^useRxJava}}{{/useRxJava}} } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index a76fb3b9547..a6453d65201 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -155,8 +155,8 @@ 1.5.8 2.0.0-beta4{{#useRxJava}} - 1.0.16{{/useRxJava}} - 1.0.0 + 1.1.3{{/useRxJava}} + 1.0.1 1.0.0 4.12 diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 425b525cc55..604853e4b8a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -172,9 +172,9 @@ UTF-8 1.5.8 - 1.18 - 2.4.2 - 2.3 + 1.19.1 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/samples/client/petstore/java/default/build.gradle b/samples/client/petstore/java/default/build.gradle index bfba070e070..33ceee9bb95 100644 --- a/samples/client/petstore/java/default/build.gradle +++ b/samples/client/petstore/java/default/build.gradle @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "1.18" - jodatime_version = "2.3" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + jersey_version = "1.19.1" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/samples/client/petstore/java/default/docs/Name.md b/samples/client/petstore/java/default/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/default/docs/Name.md +++ b/samples/client/petstore/java/default/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/default/pom.xml b/samples/client/petstore/java/default/pom.xml index 803c7eab63a..2ea4060bc3a 100644 --- a/samples/client/petstore/java/default/pom.xml +++ b/samples/client/petstore/java/default/pom.xml @@ -172,9 +172,9 @@ UTF-8 1.5.8 - 1.18 - 2.4.2 - 2.3 + 1.19.1 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index 584c85aaae4..c4ff05ec24f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -8,8 +8,8 @@ import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java index 6446b547742..e93e3c3ee72 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java @@ -17,6 +17,7 @@ public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/feign/build.gradle b/samples/client/petstore/java/feign/build.gradle index 656d38a57eb..d1f56b19208 100644 --- a/samples/client/petstore/java/feign/build.gradle +++ b/samples/client/petstore/java/feign/build.gradle @@ -94,11 +94,12 @@ if(hasProperty('target') && target == 'android') { } ext { - swagger_annotations_version = "1.5.0" - jackson_version = "2.6.3" - feign_version = "8.1.1" - jodatime_version = "2.5" + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" + feign_version = "8.16.0" + jodatime_version = "2.9.3" junit_version = "4.12" + oltu_version = "1.0.1" } dependencies { @@ -111,6 +112,7 @@ dependencies { compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" compile "joda-time:joda-time:$jodatime_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" compile "com.brsanthu:migbase64:2.2" testCompile "junit:junit:$junit_version" } diff --git a/samples/client/petstore/java/feign/pom.xml b/samples/client/petstore/java/feign/pom.xml index d7ad6ee49b9..1d862a8ab9e 100644 --- a/samples/client/petstore/java/feign/pom.xml +++ b/samples/client/petstore/java/feign/pom.xml @@ -110,7 +110,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} @@ -179,10 +179,10 @@ - 1.5.0 - 8.1.1 - 2.6.3 - 2.5 + 1.5.8 + 8.16.0 + 2.7.0 + 2.9.3 4.12 1.0.0 1.0.0 diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java index 043861f4e53..2df11392ae9 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java @@ -14,7 +14,7 @@ import feign.codec.EncodeException; import feign.codec.Encoder; import feign.RequestTemplate; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class FormAwareEncoder implements Encoder { public static final String UTF_8 = "utf-8"; private static final String LINE_FEED = "\r\n"; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java index 6439885ed11..9f79c5f4128 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index e2e1ad0bee6..cfe2b473fb3 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -3,8 +3,8 @@ package io.swagger.client.api; import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; @@ -12,7 +12,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public interface PetApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 45c9610c5c0..d201859d262 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public interface StoreApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index ae731977c6b..82170bccbd7 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public interface UserApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 8e3eb2af935..506be041d21 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index 3d79c411824..f86b9592abf 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 66f4830bce0..a710f67fb82 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index 96d35603bf5..cc71eeb2d47 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 9c6b5e35de6..abf4168fd0d 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index 41b7842d606..4cb90f48e1a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java index 91fb6b5b939..c51aee204b2 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:32.462+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index 2994e48adaf..a50bb1dbda9 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index e51b32ff5a2..9e711509072 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -12,11 +12,12 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 3c0ea427c41..8b3f9df3f5e 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index ee4ce28371b..a77e69c1ac9 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index 786d75c976c..4c82bbb76f1 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 4e323812065..d1fdd1d0791 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 23e363a518e..2868b96d94a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:57.731+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle index 2daaf89454a..9c98d11c4cd 100644 --- a/samples/client/petstore/java/jersey2/build.gradle +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -95,9 +95,9 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.0" - jackson_version = "2.4.2" - jersey_version = "2.22" - jodatime_version = "2.3" + jackson_version = "2.7.0" + jersey_version = "2.22.2" + jodatime_version = "2.9.3" junit_version = "4.12" } diff --git a/samples/client/petstore/java/jersey2/docs/Name.md b/samples/client/petstore/java/jersey2/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/jersey2/docs/Name.md +++ b/samples/client/petstore/java/jersey2/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml index 216caa5675b..0f8853151ca 100644 --- a/samples/client/petstore/java/jersey2/pom.xml +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -131,7 +131,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} @@ -194,10 +194,10 @@ - 1.5.0 - 2.22 - 2.4.2 - 2.3 + 1.5.8 + 2.22.2 + 2.7.0 + 2.9.3 1.0.0 4.12 diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index f513e2165c7..0cfce27ebcb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index c6c4f0b1cd6..0044a09a1ff 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 8d447238daf..2407eb9bab2 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import javax.ws.rs.ext.ContextResolver; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class JSON implements ContextResolver { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index 6fb0888876f..0ae34f50daa 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index cd18a247928..3536660a310 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index d96bf5dcc0b..115a0ed2b98 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -8,15 +8,15 @@ import io.swagger.client.Pair; import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class PetApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 65d0ff6a615..38c23931dae 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 8a1cba219a6..83ec59e1983 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index acdcaa52fcd..bcc11dd03c9 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index fc96078e06e..12bf82a8921 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index e70241f1171..886832f5860 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index d56e70d7689..cdb406c892a 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index da8a3553b00..36d6ad93d9a 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index e8e19c2d32e..027e28cea8e 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index 0d620e5addd..b68ebd65395 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 1586ae89d6d..131cc5b9727 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 1db08de21f4..392d9510ba0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java index fe1bf3f483d..08634a24851 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-21T18:26:21.396+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 1f89198ddda..6e4fe9eff51 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index cc7dbe3dd6e..d1eb0b25a74 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -12,11 +12,12 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Name { private Integer name = null; private Integer snakeCase = null; + private String property = null; /** @@ -43,6 +44,23 @@ public class Name { } + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("property") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -53,12 +71,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -68,6 +87,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 136aa894eb4..61a3207bf2c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 859a1ce8c3c..1d906602ab5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index be6b9c3c92a..580088f4d1d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 276ff12d6eb..2adc2177fb3 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 646f9969f30..22fb4376359 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:29:55.995+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/okhttp-gson/build.gradle b/samples/client/petstore/java/okhttp-gson/build.gradle index 73518e39969..57812871f64 100644 --- a/samples/client/petstore/java/okhttp-gson/build.gradle +++ b/samples/client/petstore/java/okhttp-gson/build.gradle @@ -94,9 +94,9 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.0' - compile 'com.squareup.okhttp:okhttp:2.7.2' - compile 'com.squareup.okhttp:logging-interceptor:2.7.2' - compile 'com.google.code.gson:gson:2.3.1' + compile 'io.swagger:swagger-annotations:1.5.8' + compile 'com.squareup.okhttp:okhttp:2.7.5' + compile 'com.squareup.okhttp:logging-interceptor:2.7.5' + compile 'com.google.code.gson:gson:2.6.2' testCompile 'junit:junit:4.12' } diff --git a/samples/client/petstore/java/okhttp-gson/build.sbt b/samples/client/petstore/java/okhttp-gson/build.sbt index 873affa9604..1be5d0b6f4d 100644 --- a/samples/client/petstore/java/okhttp-gson/build.sbt +++ b/samples/client/petstore/java/okhttp-gson/build.sbt @@ -9,10 +9,10 @@ lazy val root = (project in file(".")). publishArtifact in (Compile, packageDoc) := false, resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( - "io.swagger" % "swagger-annotations" % "1.5.0", - "com.squareup.okhttp" % "okhttp" % "2.7.2", - "com.squareup.okhttp" % "logging-interceptor" % "2.7.2", - "com.google.code.gson" % "gson" % "2.3.1", - "junit" % "junit" % "4.8.1" % "test" + "io.swagger" % "swagger-annotations" % "1.5.8", + "com.squareup.okhttp" % "okhttp" % "2.7.5", + "com.squareup.okhttp" % "logging-interceptor" % "2.7.5", + "com.google.code.gson" % "gson" % "2.6.2", + "junit" % "junit" % "4.12.0" % "test" ) ) diff --git a/samples/client/petstore/java/okhttp-gson/docs/Name.md b/samples/client/petstore/java/okhttp-gson/docs/Name.md index a1adac1dd39..5390a15e9cd 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/Name.md +++ b/samples/client/petstore/java/okhttp-gson/docs/Name.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snakeCase** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/java/okhttp-gson/pom.xml b/samples/client/petstore/java/okhttp-gson/pom.xml index 520d234a769..f160c89d290 100644 --- a/samples/client/petstore/java/okhttp-gson/pom.xml +++ b/samples/client/petstore/java/okhttp-gson/pom.xml @@ -160,8 +160,8 @@ 1.5.8 - 2.7.2 - 2.3.1 + 2.7.5 + 2.6.2 1.0.0 4.12 diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 38c89d2d0fc..c1c25450bde 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index e879206d377..19d6c6574ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index e1b2c38f0a2..fb7ed7094d5 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 32556afd1b6..d358b605d4f 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index ac7ad688c56..75fb730c422 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -18,8 +18,8 @@ import com.squareup.okhttp.Response; import java.io.IOException; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.lang.reflect.Type; import java.util.ArrayList; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index fa2d5293018..6a4080efefa 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index 81d6fddf5b0..d9e49f905d8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T20:27:24.514+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java index cb65d370816..7ba516f17ec 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(this.name, name.name) && - Objects.equals(this.snakeCase, name.snakeCase); + Objects.equals(this.snakeCase, name.snakeCase) && + Objects.equals(this.property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit/build.gradle b/samples/client/petstore/java/retrofit/build.gradle index 7d0d52536eb..079d1240a39 100644 --- a/samples/client/petstore/java/retrofit/build.gradle +++ b/samples/client/petstore/java/retrofit/build.gradle @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - okhttp_version = "2.3.0" - oltu_version = "1.0.0" + okhttp_version = "2.7.5" + oltu_version = "1.0.1" retrofit_version = "1.9.0" - swagger_annotations_version = "1.5.0" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/samples/client/petstore/java/retrofit/pom.xml b/samples/client/petstore/java/retrofit/pom.xml index 6e2a7b76ac2..a0cb2d5873b 100644 --- a/samples/client/petstore/java/retrofit/pom.xml +++ b/samples/client/petstore/java/retrofit/pom.xml @@ -110,7 +110,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} com.squareup.retrofit @@ -137,10 +137,10 @@ - 1.5.0 + 1.5.8 1.9.0 - 2.4.0 - 1.0.0 + 2.7.5 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 1ec34d9e71d..2b49da0ce3a 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:01.525+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:01:11.351+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index a019a4bf886..66ed6aea981 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -7,8 +7,8 @@ import retrofit.http.*; import retrofit.mime.*; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2/build.gradle b/samples/client/petstore/java/retrofit2/build.gradle index a893deaa2ae..fb29db0475c 100644 --- a/samples/client/petstore/java/retrofit2/build.gradle +++ b/samples/client/petstore/java/retrofit2/build.gradle @@ -94,10 +94,10 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" + oltu_version = "1.0.1" retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + gson_version = "2.6.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" } diff --git a/samples/client/petstore/java/retrofit2/pom.xml b/samples/client/petstore/java/retrofit2/pom.xml index 2d8f0440161..c9ec80dacf4 100644 --- a/samples/client/petstore/java/retrofit2/pom.xml +++ b/samples/client/petstore/java/retrofit2/pom.xml @@ -111,7 +111,7 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} com.squareup.retrofit2 @@ -143,9 +143,9 @@ - 1.5.0 + 1.5.8 2.0.0-beta4 - 1.0.0 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index fd13370ea3a..c56ed86683a 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:03.337+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:08:50.551+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index ec9d67a7449..dd39a864f06 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java index 423a5762822..9b9c01b35b2 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-19T19:30:05.103+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:10:58.658+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 4a2e64b726e..304ea7a29a8 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java index fd90800298e..b24b87366a4 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/Name.java @@ -21,6 +21,9 @@ public class Name { @SerializedName("snake_case") private Integer snakeCase = null; + @SerializedName("property") + private String property = null; + /** **/ @ApiModelProperty(required = true, value = "") @@ -38,6 +41,16 @@ public class Name { return snakeCase; } + /** + **/ + @ApiModelProperty(value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + @Override public boolean equals(Object o) { @@ -49,12 +62,13 @@ public class Name { } Name name = (Name) o; return Objects.equals(name, name.name) && - Objects.equals(snakeCase, name.snakeCase); + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property); } @Override public int hashCode() { - return Objects.hash(name, snakeCase); + return Objects.hash(name, snakeCase, property); } @Override @@ -64,6 +78,7 @@ public class Name { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); sb.append("}"); return sb.toString(); } From bf35d57178ac57a3d94f4b896814128a6350546b Mon Sep 17 00:00:00 2001 From: Scott Kirkpatrick Date: Fri, 22 Apr 2016 11:47:34 -0700 Subject: [PATCH 30/63] Update Java version to 1.7 in generated pom This fixes #2607 and brings the Java version in the generated pom to match the version in the generated build.gradle. --- modules/swagger-codegen/src/main/resources/Java/pom.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 425b525cc55..1548c4ebf62 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -97,8 +97,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 From 1ca246c4c8a3894937e466f0d17167e5ce1c423b Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 23 Apr 2016 12:59:36 +0800 Subject: [PATCH 31/63] update java version in pom for java api client --- .../src/main/resources/Java/libraries/feign/pom.mustache | 6 +++--- .../src/main/resources/Java/libraries/jersey2/pom.mustache | 4 ++-- .../main/resources/Java/libraries/okhttp-gson/pom.mustache | 4 ++-- .../src/main/resources/Java/libraries/retrofit/pom.mustache | 4 ++-- .../main/resources/Java/libraries/retrofit2/pom.mustache | 3 +-- samples/client/petstore/java/feign/pom.xml | 2 +- .../src/main/java/io/swagger/client/FormAwareEncoder.java | 2 +- .../feign/src/main/java/io/swagger/client/StringUtil.java | 2 +- .../feign/src/main/java/io/swagger/client/api/PetApi.java | 2 +- .../feign/src/main/java/io/swagger/client/api/StoreApi.java | 2 +- .../feign/src/main/java/io/swagger/client/api/UserApi.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Animal.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Cat.java | 2 +- .../src/main/java/io/swagger/client/model/Category.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Dog.java | 2 +- .../src/main/java/io/swagger/client/model/FormatTest.java | 2 +- .../main/java/io/swagger/client/model/Model200Response.java | 2 +- .../main/java/io/swagger/client/model/ModelApiResponse.java | 2 +- .../src/main/java/io/swagger/client/model/ModelReturn.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Name.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Order.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Pet.java | 2 +- .../main/java/io/swagger/client/model/SpecialModelName.java | 2 +- .../feign/src/main/java/io/swagger/client/model/Tag.java | 2 +- .../feign/src/main/java/io/swagger/client/model/User.java | 2 +- samples/client/petstore/java/jersey2/pom.xml | 4 ++-- .../src/main/java/io/swagger/client/ApiException.java | 2 +- .../src/main/java/io/swagger/client/Configuration.java | 2 +- .../java/jersey2/src/main/java/io/swagger/client/JSON.java | 2 +- .../java/jersey2/src/main/java/io/swagger/client/Pair.java | 2 +- .../jersey2/src/main/java/io/swagger/client/StringUtil.java | 2 +- .../jersey2/src/main/java/io/swagger/client/api/PetApi.java | 2 +- .../src/main/java/io/swagger/client/api/StoreApi.java | 2 +- .../src/main/java/io/swagger/client/api/UserApi.java | 2 +- .../src/main/java/io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../src/main/java/io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../jersey2/src/main/java/io/swagger/client/auth/OAuth.java | 2 +- .../src/main/java/io/swagger/client/model/Animal.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/Cat.java | 2 +- .../src/main/java/io/swagger/client/model/Category.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/Dog.java | 2 +- .../src/main/java/io/swagger/client/model/FormatTest.java | 2 +- .../main/java/io/swagger/client/model/Model200Response.java | 2 +- .../main/java/io/swagger/client/model/ModelApiResponse.java | 2 +- .../src/main/java/io/swagger/client/model/ModelReturn.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/Name.java | 2 +- .../src/main/java/io/swagger/client/model/Order.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/Pet.java | 2 +- .../main/java/io/swagger/client/model/SpecialModelName.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/Tag.java | 2 +- .../jersey2/src/main/java/io/swagger/client/model/User.java | 2 +- samples/client/petstore/java/okhttp-gson/pom.xml | 4 ++-- .../src/main/java/io/swagger/client/ApiException.java | 2 +- .../src/main/java/io/swagger/client/Configuration.java | 2 +- .../okhttp-gson/src/main/java/io/swagger/client/Pair.java | 2 +- .../src/main/java/io/swagger/client/StringUtil.java | 2 +- .../src/main/java/io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../src/main/java/io/swagger/client/auth/OAuth.java | 2 +- samples/client/petstore/java/retrofit/pom.xml | 4 ++-- .../src/main/java/io/swagger/client/StringUtil.java | 2 +- 60 files changed, 68 insertions(+), 69 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache index d75158d094b..03323a65a03 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -185,6 +185,6 @@ 2.9.3 4.12 1.0.0 - 1.0.0 + 1.0.1 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache index ea940cc0753..472bbf9b9b8 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache index 01672549e8e..7f08e5afb58 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache index 2d416a57f24..9a917f19caf 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit/pom.mustache @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index a6453d65201..11bbae5797a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 diff --git a/samples/client/petstore/java/feign/pom.xml b/samples/client/petstore/java/feign/pom.xml index 1d862a8ab9e..164399be4a6 100644 --- a/samples/client/petstore/java/feign/pom.xml +++ b/samples/client/petstore/java/feign/pom.xml @@ -185,6 +185,6 @@ 2.9.3 4.12 1.0.0 - 1.0.0 + 1.0.1 diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java index 2df11392ae9..5d534251519 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/FormAwareEncoder.java @@ -14,7 +14,7 @@ import feign.codec.EncodeException; import feign.codec.Encoder; import feign.RequestTemplate; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class FormAwareEncoder implements Encoder { public static final String UTF_8 = "utf-8"; private static final String LINE_FEED = "\r\n"; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java index 9f79c5f4128..0a07276e65b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index cfe2b473fb3..e1a0e57b005 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface PetApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index d201859d262..6b124765369 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface StoreApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java index 82170bccbd7..281cf2df46a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/UserApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public interface UserApi extends ApiClient.Api { diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 506be041d21..6b79f42855b 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index f86b9592abf..09e48e27ad5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index a710f67fb82..6d4ffb945a0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index cc71eeb2d47..5ff3690685f 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index abf4168fd0d..ae470044a23 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index 4cb90f48e1a..e3d07e1b441 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java index c51aee204b2..a1ca4f7ef45 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index a50bb1dbda9..b8b35a72382 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index 9e711509072..d993ca02455 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 8b3f9df3f5e..9004aa13a10 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index a77e69c1ac9..f23c9124882 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index 4c82bbb76f1..b2b87fad3a4 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index d1fdd1d0791..55bef8324de 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 2868b96d94a..d8657dda7f5 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:57:42.363+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:48:24.088+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml index 0f8853151ca..c07ae01939a 100644 --- a/samples/client/petstore/java/jersey2/pom.xml +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java index 0cfce27ebcb..d5c0fa366bd 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java index 0044a09a1ff..91b18d8f79c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java index 2407eb9bab2..a6ffdc8fbe7 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java @@ -8,7 +8,7 @@ import java.text.DateFormat; import javax.ws.rs.ext.ContextResolver; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class JSON implements ContextResolver { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java index 0ae34f50daa..b3532990688 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java index 3536660a310..6409e1b1765 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index 115a0ed2b98..39b9775f39d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class PetApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 38c23931dae..d2a87ef01fa 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java index 83ec59e1983..b97e2357a4b 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class UserApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index bcc11dd03c9..62506180f53 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index 12bf82a8921..65681bc9aa5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -9,7 +9,7 @@ import java.util.List; import java.io.UnsupportedEncodingException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java index 886832f5860..dda7cae0a05 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java index cdb406c892a..a4dfdc3bc56 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java index 36d6ad93d9a..f150e8d3121 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Cat extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index 027e28cea8e..78f43782919 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Category { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java index b68ebd65395..45c85698089 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java @@ -10,7 +10,7 @@ import io.swagger.client.model.Animal; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Dog extends Animal { private String className = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java index 131cc5b9727..774ce0ebcfe 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class FormatTest { private Integer integer = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java index 392d9510ba0..cd6a37772e0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name starting with number") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Model200Response { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java index 08634a24851..5a3f9254bae 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ModelApiResponse { private Integer code = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java index 6e4fe9eff51..e6214862791 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing reserved words") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class ModelReturn { private Integer _return = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java index d1eb0b25a74..f710f6122e4 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java @@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModelProperty; **/ @ApiModel(description = "Model for testing model name same as property name") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Name { private Integer name = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 61a3207bf2c..c2fbdbcc9f9 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Order { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 1d906602ab5..100c8f265f0 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -14,7 +14,7 @@ import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Pet { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java index 580088f4d1d..fa2813e9c42 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class SpecialModelName { private Long specialPropertyName = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 2adc2177fb3..f82159f2111 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class Tag { private Long id = null; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 22fb4376359..56bfb774ccb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T22:05:03.730+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:58:40.273+08:00") public class User { private Long id = null; diff --git a/samples/client/petstore/java/okhttp-gson/pom.xml b/samples/client/petstore/java/okhttp-gson/pom.xml index f160c89d290..6b5fb468d62 100644 --- a/samples/client/petstore/java/okhttp-gson/pom.xml +++ b/samples/client/petstore/java/okhttp-gson/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index c1c25450bde..91d660ba2ac 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index 19d6c6574ac..cba4c9e4fde 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index fb7ed7094d5..d7d9f17cf3c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index d358b605d4f..bcd8b8115c8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 6a4080efefa..81c31c9f07d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index d9e49f905d8..b281311fa19 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T21:38:18.907+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:54:48.271+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/retrofit/pom.xml b/samples/client/petstore/java/retrofit/pom.xml index a0cb2d5873b..2fe5ddc8efc 100644 --- a/samples/client/petstore/java/retrofit/pom.xml +++ b/samples/client/petstore/java/retrofit/pom.xml @@ -100,8 +100,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java index 2b49da0ce3a..8adb42d4fb8 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:01:11.351+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-23T12:55:47.640+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). From f1d75f46cf67a12b915708f9dc75ee51a8ab5e85 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 23 Apr 2016 16:49:52 +0800 Subject: [PATCH 32/63] fix #2688 --- .../io/swagger/codegen/DefaultCodegen.java | 2 +- .../petstore/php/SwaggerClient-php/README.md | 14 +++---- .../php/SwaggerClient-php/docs/Name.md | 1 + .../php/SwaggerClient-php/lib/Model/Name.php | 38 +++++++++++++++++-- .../lib/ObjectSerializer.php | 2 +- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 25e95250762..1d485379588 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1889,7 +1889,7 @@ public class DefaultCodegen { // set the example value // if not specified in x-example, generate a default value if (p.vendorExtensions.containsKey("x-example")) { - p.example = (String) p.vendorExtensions.get("x-example"); + p.example = Objects.toString(p.vendorExtensions.get("x-example")); } else if (Boolean.TRUE.equals(p.isString)) { p.example = p.paramName + "_example"; } else if (Boolean.TRUE.equals(p.isBoolean)) { diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index ac92e7daa21..efc4130e160 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-19T21:31:44.449+02:00 +- Build date: 2016-04-23T16:49:49.572+08:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -122,6 +122,12 @@ Class | Method | HTTP request | Description ## Documentation For Authorization +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## petstore_auth - **Type**: OAuth @@ -131,12 +137,6 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## Author diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md index 905680a7d30..5f31a2cc7fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Name.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Name.md @@ -5,6 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **int** | | **snake_case** | **int** | | [optional] +**property** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php index c44cda7b709..9e1c4b92762 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -58,7 +58,8 @@ class Name implements ArrayAccess */ static $swaggerTypes = array( 'name' => 'int', - 'snake_case' => 'int' + 'snake_case' => 'int', + 'property' => 'string' ); static function swaggerTypes() { @@ -71,7 +72,8 @@ class Name implements ArrayAccess */ static $attributeMap = array( 'name' => 'name', - 'snake_case' => 'snake_case' + 'snake_case' => 'snake_case', + 'property' => 'property' ); static function attributeMap() { @@ -84,7 +86,8 @@ class Name implements ArrayAccess */ static $setters = array( 'name' => 'setName', - 'snake_case' => 'setSnakeCase' + 'snake_case' => 'setSnakeCase', + 'property' => 'setProperty' ); static function setters() { @@ -97,7 +100,8 @@ class Name implements ArrayAccess */ static $getters = array( 'name' => 'getName', - 'snake_case' => 'getSnakeCase' + 'snake_case' => 'getSnakeCase', + 'property' => 'getProperty' ); static function getters() { @@ -114,6 +118,11 @@ class Name implements ArrayAccess * @var int */ protected $snake_case; + /** + * $property + * @var string + */ + protected $property; /** * Constructor @@ -126,6 +135,7 @@ class Name implements ArrayAccess if ($data != null) { $this->name = $data["name"]; $this->snake_case = $data["snake_case"]; + $this->property = $data["property"]; } } /** @@ -168,6 +178,26 @@ class Name implements ArrayAccess $this->snake_case = $snake_case; return $this; } + /** + * Gets property + * @return string + */ + public function getProperty() + { + return $this->property; + } + + /** + * Sets property + * @param string $property + * @return $this + */ + public function setProperty($property) + { + + $this->property = $property; + return $this; + } /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index ac63c18fbd5..3adaa899f5f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -256,7 +256,7 @@ class ObjectSerializer } else { return null; } - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); return $data; } elseif ($class === '\SplFileObject') { From a281afaebfec699246a92298a7f948178ea8af36 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 23 Apr 2016 22:48:24 +0800 Subject: [PATCH 33/63] add requiredVars and optionalVars for codegen model --- .../src/main/java/io/swagger/codegen/CodegenModel.java | 2 ++ .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 6 ++++++ .../petstore-with-fake-endpoints-models-for-testing.yaml | 3 +++ samples/client/petstore/php/SwaggerClient-php/README.md | 2 +- .../petstore/php/SwaggerClient-php/docs/FormatTest.md | 6 +++--- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index a7866e5675a..62f5e27aa05 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -18,6 +18,8 @@ public class CodegenModel { public String discriminator; public String defaultValue; public List vars = new ArrayList(); + public List requiredVars = new ArrayList(); // a list of required properties + public List optionalVars = new ArrayList(); // a list of optional properties public List allVars; public List allowableValues; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 1d485379588..76729c8b38a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2307,6 +2307,12 @@ public class DefaultCodegen { addImport(m, cp.baseType); addImport(m, cp.complexType); vars.add(cp); + + if (Boolean.TRUE.equals(cp.required)) { // if required, add to the list "requiredVars" + m.requiredVars.add(cp); + } else { // else add to the list "optionalVars" for optional property + m.optionalVars.add(cp); + } } } } diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 01c0be8c9a3..2a90f5de066 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -755,6 +755,9 @@ definitions: type: object required: - number + - byte + - date + - password properties: integer: type: integer diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index efc4130e160..80e8d1bae7a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-23T16:49:49.572+08:00 +- Build date: 2016-04-23T22:48:00.795+08:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md b/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md index e0598317f5e..e043ee8d2b8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/FormatTest.md @@ -10,11 +10,11 @@ Name | Type | Description | Notes **float** | **float** | | [optional] **double** | **double** | | [optional] **string** | **string** | | [optional] -**byte** | **string** | | [optional] +**byte** | **string** | | **binary** | **string** | | [optional] -**date** | [**\DateTime**](Date.md) | | [optional] +**date** | [**\DateTime**](Date.md) | | **date_time** | [**\DateTime**](\DateTime.md) | | [optional] -**password** | **string** | | [optional] +**password** | **string** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) From e7df5f95515c55fb72040a800c8e8d91f19b6b4c Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sat, 23 Apr 2016 09:52:17 -0700 Subject: [PATCH 34/63] fixed multiple import mapping issue --- .../codegen/languages/GoClientCodegen.java | 39 ++++++++++++++++++- .../src/main/resources/go/api.mustache | 9 ----- .../client/petstore/go/go-petstore/pet_api.go | 2 +- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index b23ab32163e..37c485ea888 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -104,7 +104,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { importMapping = new HashMap(); importMapping.put("time.Time", "time"); importMapping.put("*os.File", "os"); - importMapping.put("ioutil", "io/ioutil"); + importMapping.put("os", "io/ioutil"); cliOptions.clear(); cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Go package name (convention: lowercase).") @@ -375,6 +375,23 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { iterator.remove(); } + // recursivly add import for mapping one type to multipe imports + List> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> listIterator = imports.listIterator(); + while (listIterator.hasNext()) { + String _import = listIterator.next().get("import"); + // if the import package happens to be found in the importMapping (key) + // add the corresponding import package to the list + if (importMapping.containsKey(_import)) { + Map newImportMap= new HashMap(); + newImportMap.put("import", importMapping.get(_import)); + listIterator.add(newImportMap); + } + } + return objs; } @@ -389,6 +406,24 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { if (_import.startsWith(prefix)) iterator.remove(); } + + // recursivly add import for mapping one type to multipe imports + List> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> listIterator = imports.listIterator(); + while (listIterator.hasNext()) { + String _import = listIterator.next().get("import"); + // if the import package happens to be found in the importMapping (key) + // add the corresponding import package to the list + if (importMapping.containsKey(_import)) { + Map newImportMap= new HashMap(); + newImportMap.put("import", importMapping.get(_import)); + listIterator.add(newImportMap); + } + } + return objs; } @@ -405,4 +440,4 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { public void setPackageVersion(String packageVersion) { this.packageVersion = packageVersion; } -} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 5b6b9d30ab6..d9302ae4126 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -6,15 +6,6 @@ import ( "fmt" "encoding/json" "errors" - {{#operation}} - {{#hasFormParams}} - {{#formParams}} - {{#isFile}} - "io/ioutil" - {{/isFile}} - {{/formParams}} - {{/hasFormParams}} - {{/operation}} {{#imports}} "{{import}}" {{/imports}} ) diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 22df273324c..49ca502151c 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -5,8 +5,8 @@ import ( "fmt" "encoding/json" "errors" - "io/ioutil" "os" + "io/ioutil" ) type PetApi struct { From 7df5c8ffbfeb6b2b0e7dd507b3e28978b1a4d704 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sat, 23 Apr 2016 16:41:14 -0700 Subject: [PATCH 35/63] added model ApiResponse, moved ApiResponse parameter --- .../codegen/languages/GoClientCodegen.java | 5 +- .../src/main/resources/go/api.mustache | 8 +-- .../client/petstore/go/go-petstore/README.md | 4 +- .../petstore/go/go-petstore/docs/PetApi.md | 4 +- .../client/petstore/go/go-petstore/pet_api.go | 68 +++++++++---------- .../petstore/go/go-petstore/store_api.go | 30 ++++---- .../petstore/go/go-petstore/user_api.go | 66 +++++++++--------- samples/client/petstore/go/pet_api_test.go | 14 ++-- 8 files changed, 100 insertions(+), 99 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 37c485ea888..ef0ea2e5142 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -51,7 +51,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", - "continue", "for", "import", "return", "var", "error") + "continue", "for", "import", "return", "var", "error", "ApiResponse") // Added "error" as it's used so frequently that it may as well be a keyword ); @@ -145,6 +145,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.go")); supportingFiles.add(new SupportingFile("api_client.mustache", "", "api_client.go")); + supportingFiles.add(new SupportingFile("api_response.mustache", "", "api_response.go")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); } @@ -324,7 +325,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { return swaggerType; } - return camelize(swaggerType, false); + return toModelName(swaggerType); } @Override diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index d9302ae4126..5313732906a 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -37,7 +37,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ {{#allParams}} * @param {{paramName}} {{description}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error, ApiResponse) { +func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}ApiResponse, error) { var httpMethod = "{{httpMethod}}" // create path and map variables @@ -49,7 +49,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#required}} // verify the required parameter '{{paramName}}' is set if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") } {{/required}} {{/allParams}} @@ -138,14 +138,14 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ if err != nil { - return {{#returnType}}*successPayload, {{/returnType}}err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err } {{#returnType}} err = json.Unmarshal(httpResponse.Body(), &successPayload) {{/returnType}} - return {{#returnType}}*successPayload, {{/returnType}}err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err } {{/operation}} {{/operations}} diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index f8e134982d8..c93a245e10e 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 date: 2016-04-17T23:42:10.705-07:00 +- Build date: 2016-04-23T15:46:19.755-07:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation @@ -46,8 +46,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ApiResponse](docs/ApiResponse.md) - [Category](docs/Category.md) + - [ModelApiResponse](docs/ModelApiResponse.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) - [Tag](docs/Tag.md) diff --git a/samples/client/petstore/go/go-petstore/docs/PetApi.md b/samples/client/petstore/go/go-petstore/docs/PetApi.md index 9caa3df6865..e96bdc1a15e 100644 --- a/samples/client/petstore/go/go-petstore/docs/PetApi.md +++ b/samples/client/petstore/go/go-petstore/docs/PetApi.md @@ -221,7 +221,7 @@ void (empty response body) [[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) # **UploadFile** -> ApiResponse UploadFile($petId, $additionalMetadata, $file) +> ModelApiResponse UploadFile($petId, $additionalMetadata, $file) uploads an image @@ -238,7 +238,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ApiResponse.md) ### Authorization diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 49ca502151c..25cd57a490c 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -35,7 +35,7 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) AddPet (body Pet) (error, ApiResponse) { +func (a PetApi) AddPet (body Pet) (ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -43,7 +43,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->AddPet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") } headerParams := make(map[string]string) @@ -95,10 +95,10 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Deletes a pet @@ -107,7 +107,7 @@ func (a PetApi) AddPet (body Pet) (error, ApiResponse) { * @param apiKey * @return void */ -func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { +func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -116,7 +116,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { // verify the required parameter 'petId' is set if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") } headerParams := make(map[string]string) @@ -166,10 +166,10 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Finds Pets by status @@ -177,7 +177,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error, ApiResponse) { * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { +func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -185,7 +185,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { // verify the required parameter 'status' is set if &status == nil { - return *new([]Pet), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") } headerParams := make(map[string]string) @@ -234,12 +234,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Finds Pets by tags @@ -247,7 +247,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error, ApiResponse) { * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { +func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -255,7 +255,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { // verify the required parameter 'tags' is set if &tags == nil { - return *new([]Pet), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") } headerParams := make(map[string]string) @@ -304,12 +304,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Find pet by ID @@ -317,7 +317,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error, ApiResponse) { * @param petId ID of pet to return * @return Pet */ -func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { +func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -326,7 +326,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { // verify the required parameter 'petId' is set if &petId == nil { - return *new(Pet), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") } headerParams := make(map[string]string) @@ -373,12 +373,12 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Update an existing pet @@ -386,7 +386,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error, ApiResponse) { * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { +func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { var httpMethod = "Put" // create path and map variables @@ -394,7 +394,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") } headerParams := make(map[string]string) @@ -446,10 +446,10 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Updates a pet in the store with form data @@ -459,7 +459,7 @@ func (a PetApi) UpdatePet (body Pet) (error, ApiResponse) { * @param status Updated status of the pet * @return void */ -func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error, ApiResponse) { +func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -468,7 +468,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err // verify the required parameter 'petId' is set if &petId == nil { - return errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") } headerParams := make(map[string]string) @@ -519,10 +519,10 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * uploads an image @@ -530,9 +530,9 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @return ApiResponse + * @return ModelApiResponse */ -func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error, ApiResponse) { +func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -541,7 +541,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil // verify the required parameter 'petId' is set if &petId == nil { - return *new(ApiResponse), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(ModelApiResponse), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") } headerParams := make(map[string]string) @@ -588,15 +588,15 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil fileBytes = fbs fileName = file.Name() - var successPayload = new(ApiResponse) + var successPayload = new(ModelApiResponse) httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index c1904d3dc6b..e70886e1984 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -33,7 +33,7 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ * @param orderId ID of the order that needs to be deleted * @return void */ -func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { +func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -42,7 +42,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { // verify the required parameter 'orderId' is set if &orderId == nil { - return errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") } headerParams := make(map[string]string) @@ -84,17 +84,17 @@ func (a StoreApi) DeleteOrder (orderId string) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Returns pet inventories by status * Returns a map of status codes to quantities * @return map[string]int32 */ -func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { +func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -144,12 +144,12 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Find purchase order by ID @@ -157,7 +157,7 @@ func (a StoreApi) GetInventory () (map[string]int32, error, ApiResponse) { * @param orderId ID of pet that needs to be fetched * @return Order */ -func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { +func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -166,7 +166,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { // verify the required parameter 'orderId' is set if &orderId == nil { - return *new(Order), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") } headerParams := make(map[string]string) @@ -208,12 +208,12 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Place an order for a pet @@ -221,7 +221,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error, ApiResponse) { * @param body order placed for purchasing the pet * @return Order */ -func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { +func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -229,7 +229,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return *new(Order), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") } headerParams := make(map[string]string) @@ -273,10 +273,10 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 4e3cf387bc0..810756df9f1 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -33,7 +33,7 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ * @param body Created user object * @return void */ -func (a UserApi) CreateUser (body User) (error, ApiResponse) { +func (a UserApi) CreateUser (body User) (ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -41,7 +41,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") } headerParams := make(map[string]string) @@ -85,10 +85,10 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Creates list of users with given input array @@ -96,7 +96,7 @@ func (a UserApi) CreateUser (body User) (error, ApiResponse) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { +func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -104,7 +104,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") } headerParams := make(map[string]string) @@ -148,10 +148,10 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Creates list of users with given input array @@ -159,7 +159,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error, ApiResponse) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { +func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { var httpMethod = "Post" // create path and map variables @@ -167,7 +167,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") } headerParams := make(map[string]string) @@ -211,10 +211,10 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Delete user @@ -222,7 +222,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error, ApiResponse) { * @param username The name that needs to be deleted * @return void */ -func (a UserApi) DeleteUser (username string) (error, ApiResponse) { +func (a UserApi) DeleteUser (username string) (ApiResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -231,7 +231,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { // verify the required parameter 'username' is set if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") } headerParams := make(map[string]string) @@ -273,10 +273,10 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Get user by user name @@ -284,7 +284,7 @@ func (a UserApi) DeleteUser (username string) (error, ApiResponse) { * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ -func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { +func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -293,7 +293,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { // verify the required parameter 'username' is set if &username == nil { - return *new(User), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(User), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") } headerParams := make(map[string]string) @@ -335,12 +335,12 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Logs user into the system @@ -349,7 +349,7 @@ func (a UserApi) GetUserByName (username string) (User, error, ApiResponse) { * @param password The password for login in clear text * @return string */ -func (a UserApi) LoginUser (username string, password string) (string, error, ApiResponse) { +func (a UserApi) LoginUser (username string, password string) (string, ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -357,11 +357,11 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap // verify the required parameter 'username' is set if &username == nil { - return *new(string), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(string), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") } // verify the required parameter 'password' is set if &password == nil { - return *new(string), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *new(string), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") } headerParams := make(map[string]string) @@ -405,19 +405,19 @@ func (a UserApi) LoginUser (username string, password string) (string, error, Ap if err != nil { - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Logs out current logged in user session * * @return void */ -func (a UserApi) LogoutUser () (error, ApiResponse) { +func (a UserApi) LogoutUser () (ApiResponse, error) { var httpMethod = "Get" // create path and map variables @@ -463,10 +463,10 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } /** * Updated user @@ -475,7 +475,7 @@ func (a UserApi) LogoutUser () (error, ApiResponse) { * @param body Updated user object * @return void */ -func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { +func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { var httpMethod = "Put" // create path and map variables @@ -484,11 +484,11 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { // verify the required parameter 'username' is set if &username == nil { - return errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") } // verify the required parameter 'body' is set if &body == nil { - return errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser"), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request") + return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") } headerParams := make(map[string]string) @@ -532,8 +532,8 @@ func (a UserApi) UpdateUser (username string, body User) (error, ApiResponse) { if err != nil { - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } - return err, *a.Configuration.ApiClient.GetApiResponse(httpResponse) + return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err } diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 2b831f58588..4174ff2de4b 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -12,7 +12,7 @@ func TestAddPet(t *testing.T) { newPet := (sw.Pet{Id: 12830, Name: "gopher", PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"}) - err, apiResponse := s.AddPet(newPet) + apiResponse, err := s.AddPet(newPet) if err != nil { t.Errorf("Error while adding pet") @@ -27,7 +27,7 @@ func TestGetPetById(t *testing.T) { assert := assert.New(t) s := sw.NewPetApi() - resp, err, apiResponse := s.GetPetById(12830) + resp, apiResponse, err := s.GetPetById(12830) if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) @@ -45,7 +45,7 @@ func TestGetPetById(t *testing.T) { func TestGetPetByIdWithInvalidID(t *testing.T) { s := sw.NewPetApi() - resp, err, apiResponse := s.GetPetById(999999999) + resp, apiResponse, err := s.GetPetById(999999999) if err != nil { t.Errorf("Error while getting pet by invalid id") t.Log(err) @@ -61,7 +61,7 @@ func TestGetPetByIdWithInvalidID(t *testing.T) { func TestUpdatePetWithForm(t *testing.T) { s := sw.NewPetApi() - err, apiResponse := s.UpdatePetWithForm(12830, "golang", "available") + apiResponse, err := s.UpdatePetWithForm(12830, "golang", "available") if err != nil { t.Errorf("Error while updating pet by id") @@ -75,7 +75,7 @@ func TestUpdatePetWithForm(t *testing.T) { func TestFindPetsByStatus(t *testing.T) { s := sw.NewPetApi() - resp, err, apiResponse := s.FindPetsByStatus([]string {"pending"}) + resp, apiResponse, err := s.FindPetsByStatus([]string {"pending"}) if err != nil { t.Errorf("Error while getting pet by id") t.Log(err) @@ -96,7 +96,7 @@ func TestUploadFile(t *testing.T) { s := sw.NewPetApi() file, _ := os.Open("../python/testfiles/foo.png") - _, err, apiResponse := s.UploadFile(12830, "golang", file) + _, apiResponse, err := s.UploadFile(12830, "golang", file) if err != nil { t.Errorf("Error while uploading file") @@ -109,7 +109,7 @@ func TestUploadFile(t *testing.T) { func TestDeletePet(t *testing.T) { s := sw.NewPetApi() - err, apiResponse := s.DeletePet(12830, "") + apiResponse, err := s.DeletePet(12830, "") if err != nil { t.Errorf("Error while deleting pet by id") From 1de18eb074b0240c85aec4df626c55e4bb004469 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sat, 23 Apr 2016 17:50:17 -0700 Subject: [PATCH 36/63] added implementation of the new ApiResponse struct --- .../src/main/resources/go/api.mustache | 6 +-- .../src/main/resources/go/api_client.mustache | 18 ------- .../client/petstore/go/go-petstore/README.md | 2 +- .../petstore/go/go-petstore/api_client.go | 18 ------- .../petstore/go/go-petstore/api_response.go | 22 +++++--- .../client/petstore/go/go-petstore/pet_api.go | 48 +++++++++--------- .../petstore/go/go-petstore/store_api.go | 22 ++++---- .../petstore/go/go-petstore/user_api.go | 50 +++++++++---------- samples/client/petstore/go/pet_api_test.go | 41 +++++++++------ 9 files changed, 107 insertions(+), 120 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 5313732906a..852e70bd447 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -49,7 +49,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#required}} // verify the required parameter '{{paramName}}' is set if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") } {{/required}} {{/allParams}} @@ -138,14 +138,14 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ if err != nil { - return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err } {{#returnType}} err = json.Unmarshal(httpResponse.Body(), &successPayload) {{/returnType}} - return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err } {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 9143f33b504..91a84551700 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -89,24 +89,6 @@ func (c *ApiClient) ParameterToString(obj interface{}) string { } } -func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ - httpResponse := httpResp.(*resty.Response) - apiResponse := new(ApiResponse) - apiResponse.Code = int32(httpResponse.StatusCode()) - apiResponse.Message = httpResponse.Status() - - return apiResponse -} - -func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ - - apiResponse := new(ApiResponse) - apiResponse.Code = int32(400) - apiResponse.Message = errorMessage - - return apiResponse -} - func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index c93a245e10e..910888030a1 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 date: 2016-04-23T15:46:19.755-07:00 +- Build date: 2016-04-23T17:00:49.475-07:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 33451139a97..1c04e52fdc4 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -89,24 +89,6 @@ func (c *ApiClient) ParameterToString(obj interface{}) string { } } -func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{ - httpResponse := httpResp.(*resty.Response) - apiResponse := new(ApiResponse) - apiResponse.Code = int32(httpResponse.StatusCode()) - apiResponse.Message = httpResponse.Status() - - return apiResponse -} - -func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{ - - apiResponse := new(ApiResponse) - apiResponse.Code = int32(400) - apiResponse.Message = errorMessage - - return apiResponse -} - func prepareRequest(postBody interface{}, headerParams map[string]string, queryParams map[string]string, diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go index abb7971189d..b9110bd9eda 100644 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ b/samples/client/petstore/go/go-petstore/api_response.go @@ -1,14 +1,24 @@ package swagger import ( + "net/http" ) type ApiResponse struct { - - Code int32 `json:"code,omitempty"` - - Type_ string `json:"type,omitempty"` - - Message string `json:"message,omitempty"` + *http.Response + + Message string `json:"message,omitempty"` } + +func NewApiResponse(r *http.Response) *ApiResponse { + response := &ApiResponse{Response: r} + + return response +} + +func NewApiResponseWithError(errorMessage string) *ApiResponse { + response := &ApiResponse{Message: errorMessage} + + return response +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index 25cd57a490c..e9ebdf44de4 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -43,7 +43,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") } headerParams := make(map[string]string) @@ -95,10 +95,10 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Deletes a pet @@ -116,7 +116,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { // verify the required parameter 'petId' is set if &petId == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") } headerParams := make(map[string]string) @@ -166,10 +166,10 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Finds Pets by status @@ -185,7 +185,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { // verify the required parameter 'status' is set if &status == nil { - return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") + return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") } headerParams := make(map[string]string) @@ -234,12 +234,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Finds Pets by tags @@ -255,7 +255,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { // verify the required parameter 'tags' is set if &tags == nil { - return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") + return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") } headerParams := make(map[string]string) @@ -304,12 +304,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Find pet by ID @@ -326,7 +326,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { // verify the required parameter 'petId' is set if &petId == nil { - return *new(Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") + return *new(Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") } headerParams := make(map[string]string) @@ -373,12 +373,12 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Update an existing pet @@ -394,7 +394,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") } headerParams := make(map[string]string) @@ -446,10 +446,10 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Updates a pet in the store with form data @@ -468,7 +468,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api // verify the required parameter 'petId' is set if &petId == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") } headerParams := make(map[string]string) @@ -519,10 +519,10 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * uploads an image @@ -541,7 +541,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil // verify the required parameter 'petId' is set if &petId == nil { - return *new(ModelApiResponse), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") + return *new(ModelApiResponse), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") } headerParams := make(map[string]string) @@ -593,10 +593,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index e70886e1984..5da713a7d95 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -42,7 +42,7 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { // verify the required parameter 'orderId' is set if &orderId == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") } headerParams := make(map[string]string) @@ -84,10 +84,10 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Returns pet inventories by status @@ -144,12 +144,12 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Find purchase order by ID @@ -166,7 +166,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { // verify the required parameter 'orderId' is set if &orderId == nil { - return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") + return *new(Order), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") } headerParams := make(map[string]string) @@ -208,12 +208,12 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Place an order for a pet @@ -229,7 +229,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") + return *new(Order), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") } headerParams := make(map[string]string) @@ -273,10 +273,10 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 810756df9f1..6a6188074b3 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -41,7 +41,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") } headerParams := make(map[string]string) @@ -85,10 +85,10 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -104,7 +104,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") } headerParams := make(map[string]string) @@ -148,10 +148,10 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -167,7 +167,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") } headerParams := make(map[string]string) @@ -211,10 +211,10 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Delete user @@ -231,7 +231,7 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") } headerParams := make(map[string]string) @@ -273,10 +273,10 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Get user by user name @@ -293,7 +293,7 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *new(User), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") + return *new(User), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") } headerParams := make(map[string]string) @@ -335,12 +335,12 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Logs user into the system @@ -357,11 +357,11 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon // verify the required parameter 'username' is set if &username == nil { - return *new(string), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") + return *new(string), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") } // verify the required parameter 'password' is set if &password == nil { - return *new(string), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") + return *new(string), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") } headerParams := make(map[string]string) @@ -405,12 +405,12 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon if err != nil { - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *successPayload, *NewApiResponse(httpResponse.RawResponse), err } /** * Logs out current logged in user session @@ -463,10 +463,10 @@ func (a UserApi) LogoutUser () (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } /** * Updated user @@ -484,11 +484,11 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") } // verify the required parameter 'body' is set if &body == nil { - return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") + return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") } headerParams := make(map[string]string) @@ -532,8 +532,8 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { if err != nil { - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } - return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err + return *NewApiResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/pet_api_test.go b/samples/client/petstore/go/pet_api_test.go index 4174ff2de4b..5b18e3a7675 100644 --- a/samples/client/petstore/go/pet_api_test.go +++ b/samples/client/petstore/go/pet_api_test.go @@ -18,7 +18,21 @@ func TestAddPet(t *testing.T) { t.Errorf("Error while adding pet") t.Log(err) } - if apiResponse.Code != 200 { + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) + } +} + +func TestFindPetsByStatusWithMissingParam(t *testing.T) { + s := sw.NewPetApi() + + _, apiResponse, err := s.FindPetsByStatus(nil) + + if err != nil { + t.Errorf("Error while testing TestFindPetsByStatusWithMissingParam") + t.Log(err) + } + if apiResponse.Response.StatusCode != 200 { t.Log(apiResponse) } } @@ -38,8 +52,8 @@ func TestGetPetById(t *testing.T) { //t.Log(resp) } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -51,11 +65,10 @@ func TestGetPetByIdWithInvalidID(t *testing.T) { t.Log(err) t.Log(apiResponse) } else { - t.Log(resp) } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -68,8 +81,8 @@ func TestUpdatePetWithForm(t *testing.T) { t.Log(err) t.Log(apiResponse) } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -86,8 +99,8 @@ func TestFindPetsByStatus(t *testing.T) { t.Errorf("Error no pets returned") } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } } @@ -102,8 +115,8 @@ func TestUploadFile(t *testing.T) { t.Errorf("Error while uploading file") t.Log(err) } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } @@ -115,7 +128,7 @@ func TestDeletePet(t *testing.T) { t.Errorf("Error while deleting pet by id") t.Log(err) } - if apiResponse.Code != 200 { - t.Log(apiResponse) + if apiResponse.Response.StatusCode != 200 { + t.Log(apiResponse.Response) } } From fb883e5f035ed46fbc3ff9c18599a6beac8352cb Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 24 Apr 2016 16:33:15 +0800 Subject: [PATCH 37/63] add back groovy code generator --- .../languages/GroovyClientCodegen.java | 93 ++++++++ .../src/main/resources/Groovy/api.mustache | 56 +++-- .../resources/Groovy/build.gradle.mustache | 23 +- .../services/io.swagger.codegen.CodegenConfig | 3 +- samples/client/petstore/groovy/build.gradle | 42 ++++ .../groovy/io/swagger/api/ApiUtils.groovy | 50 ++++ .../main/groovy/io/swagger/api/PetApi.groovy | 184 +++++++++++++++ .../groovy/io/swagger/api/StoreApi.groovy | 93 ++++++++ .../main/groovy/io/swagger/api/UserApi.groovy | 185 +++++++++++++++ .../groovy/io/swagger/model/Category.groovy | 16 ++ .../io/swagger/model/ModelApiResponse.groovy | 18 ++ .../main/groovy/io/swagger/model/Order.groovy | 27 +++ .../main/groovy/io/swagger/model/Pet.groovy | 30 +++ .../main/groovy/io/swagger/model/Tag.groovy | 16 ++ .../main/groovy/io/swagger/model/User.groovy | 29 +++ .../main/java/io/swagger/api/ApiUtils.groovy | 50 ++++ .../main/java/io/swagger/api/PetApi.groovy | 218 ++++++++++++++++++ .../main/java/io/swagger/api/StoreApi.groovy | 104 +++++++++ .../main/java/io/swagger/api/UserApi.groovy | 200 ++++++++++++++++ .../java/io/swagger/model/Category.groovy | 16 ++ .../io/swagger/model/ModelApiResponse.groovy | 18 ++ .../main/java/io/swagger/model/Order.groovy | 27 +++ .../src/main/java/io/swagger/model/Pet.groovy | 30 +++ .../src/main/java/io/swagger/model/Tag.groovy | 16 ++ .../main/java/io/swagger/model/User.groovy | 29 +++ 25 files changed, 1536 insertions(+), 37 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java create mode 100644 samples/client/petstore/groovy/build.gradle create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy create mode 100644 samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy create mode 100644 samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java new file mode 100644 index 00000000000..2812d2a301b --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GroovyClientCodegen.java @@ -0,0 +1,93 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.models.Operation; + +import java.io.File; +import java.util.*; + +public class GroovyClientCodegen extends JavaClientCodegen { + public static final String CONFIG_PACKAGE = "configPackage"; + protected String title = "Petstore Server"; + protected String configPackage = ""; + protected String templateFileName = "api.mustache"; + + public GroovyClientCodegen() { + super(); + + sourceFolder = projectFolder + File.separator + "groovy"; + outputFolder = "generated-code/groovy"; + modelTemplateFiles.put("model.mustache", ".groovy"); + apiTemplateFiles.put(templateFileName, ".groovy"); + embeddedTemplateDir = templateDir = "Groovy"; + + apiPackage = "io.swagger.api"; + modelPackage = "io.swagger.model"; + configPackage = "io.swagger.configuration"; + invokerPackage = "io.swagger.api"; + artifactId = "swagger-spring-mvc-server"; + + additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); + additionalProperties.put(CodegenConstants.GROUP_ID, groupId); + additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId); + additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion); + additionalProperties.put("title", title); + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); + additionalProperties.put(CONFIG_PACKAGE, configPackage); + + cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code")); + + supportedLibraries.clear(); + } + + @Override + public CodegenType getTag() { + return CodegenType.CLIENT; + } + + @Override + public String getName() { + return "groovy"; + } + + @Override + public String getHelp() { + return "Generates a Groovy API client (beta)."; + } + + @Override + public void processOpts() { + super.processOpts(); + + // clear model and api doc template as this codegen + // does not support auto-generated markdown doc at the moment + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + + if (additionalProperties.containsKey(CONFIG_PACKAGE)) { + this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE)); + } + + supportingFiles.clear(); + supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle")); + // TODO readme to be added later + //supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("ApiUtils.mustache", + (sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtils.groovy")); + + } + + @Override + public String toApiName(String name) { + if (name.length() == 0) { + return "DefaultApi"; + } + name = sanitizeName(name); + return camelize(name) + "Api"; + } + + public void setConfigPackage(String configPackage) { + this.configPackage = configPackage; + } + +} diff --git a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache index 0d60fa2a96f..c952718b6ec 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache @@ -1,14 +1,9 @@ package {{package}}; - - - - import groovyx.net.http.* import static groovyx.net.http.ContentType.* import static groovyx.net.http.Method.* import {{invokerPackage}}.ApiUtils -//------------- {{#imports}}import {{import}} {{/imports}} @@ -21,36 +16,37 @@ class {{classname}} { String basePath = "{{basePath}}" String versionPath = "/api/v1" + {{#operation}} + def {{operationId}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "{{path}}" - {{#operation}} - def {{nickname}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { - // create path and map variables - String resourcePath = "{{path}}" + // query params + def queryParams = [:] + def headerParams = [:] + + {{#allParams}} + {{#required}} + // verify required params are set + if ({{paramName}} == null) { + throw new RuntimeException("missing required params {{paramName}}") + } + {{/required}} + {{/allParams}} + {{#queryParams}}if (!"null".equals(String.valueOf({{paramName}}))) + queryParams.put("{{paramName}}", String.valueOf({{paramName}})) + {{/queryParams}} - // query params - def queryParams = [:] - def headerParams = [:] + {{#headerParams}} + headerParams.put("{{paramName}}", {{paramName}}) + {{/headerParams}} - {{#allParams}} - // verify required params are set - if({{/allParams}}{{#required}} {{paramName}} == null {{#hasMore}}|| {{/hasMore}}{{/required}}{{#allParams}}) { - throw new RuntimeException("missing required params") - } - {{/allParams}} - - {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) - queryParams.put("{{paramName}}", String.valueOf({{paramName}})) - {{/queryParams}} - - {{#headerParams}}headerParams.put("{{paramName}}", {{paramName}}) - {{/headerParams}} - - invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "{{httpMethod}}", "{{returnContainer}}", {{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}}) - - } - {{/operation}} + + } + {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache index 49edec87133..238f5e6e09f 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/build.gradle.mustache @@ -17,15 +17,26 @@ buildscript { } repositories { - mavenCentral() - mavenLocal() - mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) - maven { url "http://$artifactory:8080/artifactory/repo" } + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" } dependencies { - groovy "org.codehaus.groovy:groovy-all:2.0.5" - compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6' + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' } task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 21a75b23d5c..22823c95626 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -6,6 +6,7 @@ io.swagger.codegen.languages.DartClientCodegen io.swagger.codegen.languages.FlashClientCodegen io.swagger.codegen.languages.FlaskConnexionCodegen io.swagger.codegen.languages.GoClientCodegen +io.swagger.codegen.languages.GroovyClientCodegen io.swagger.codegen.languages.JavaClientCodegen io.swagger.codegen.languages.JavaJerseyServerCodegen io.swagger.codegen.languages.JavaCXFServerCodegen @@ -41,4 +42,4 @@ io.swagger.codegen.languages.AkkaScalaClientCodegen io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.ClojureClientCodegen io.swagger.codegen.languages.HaskellServantCodegen -io.swagger.codegen.languages.LumenServerCodegen \ No newline at end of file +io.swagger.codegen.languages.LumenServerCodegen diff --git a/samples/client/petstore/groovy/build.gradle b/samples/client/petstore/groovy/build.gradle new file mode 100644 index 00000000000..238f5e6e09f --- /dev/null +++ b/samples/client/petstore/groovy/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'groovy' +apply plugin: 'idea' +apply plugin: 'eclipse' + +def artifactory = 'buildserver.supportspace.com' +group = 'com.supportspace' +archivesBaseName = 'swagger-gen-groovy' +version = '0.1' + +buildscript { + repositories { + maven { url 'http://repo.jfrog.org/artifactory/gradle-plugins' } + } + dependencies { + classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.16') + } +} + +repositories { + mavenCentral() + mavenLocal() + mavenCentral(artifactUrls: ['http://maven.springframework.org/milestone']) + maven { url "http://$artifactory:8080/artifactory/repo" } +} + +ext { + swagger_annotations_version = "1.5.8" + jackson_version = "2.7.0" +} + +dependencies { + compile 'org.codehaus.groovy:groovy-all:2.4.6' + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.1.5" + compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1' +} + +task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..5aae4924239 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy @@ -0,0 +1,184 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByStatus" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (status == null) { + throw new RuntimeException("missing required params status") + } + + if (!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/findByTags" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (tags == null) { + throw new RuntimeException("missing required params tags") + } + + if (!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "array", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/pet/{petId}/uploadImage" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (petId == null) { + throw new RuntimeException("missing required params petId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..0cf30090200 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy @@ -0,0 +1,93 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/inventory" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order/{orderId}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (orderId == null) { + throw new RuntimeException("missing required params orderId") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/store/order" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..5a8a4b2eea8 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy @@ -0,0 +1,185 @@ +package io.swagger.api; + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils + +import io.swagger.model.User + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithArray" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/createWithList" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/login" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (password == null) { + throw new RuntimeException("missing required params password") + } + + if (!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if (!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/logout" + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/user/{username}" + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if (username == null) { + throw new RuntimeException("missing required params username") + } + // verify required params are set + if (body == null) { + throw new RuntimeException("missing required params body") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy new file mode 100644 index 00000000000..877ed4e4647 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/ApiUtils.groovy @@ -0,0 +1,50 @@ +package io.swagger.api; + +import groovyx.net.http.HTTPBuilder +import groovyx.net.http.Method + +import static groovyx.net.http.ContentType.JSON +import static java.net.URI.create; + +class ApiUtils { + + def invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, method, container, type) { + def (url, uriPath) = buildUrlAndUriPath(basePath, versionPath, resourcePath) + println "url=$url uriPath=$uriPath" + def http = new HTTPBuilder(url) + http.request( Method.valueOf(method), JSON ) { + uri.path = uriPath + uri.query = queryParams + response.success = { resp, json -> + if (type != null) { + onSuccess(parse(json, container, type)) + } + } + response.failure = { resp -> + onFailure(resp.status, resp.statusLine.reasonPhrase) + } + } + } + + + def buildUrlAndUriPath(basePath, versionPath, resourcePath) { + // HTTPBuilder expects to get as its constructor parameter an URL, + // without any other additions like path, therefore we need to cut the path + // from the basePath as it is represented by swagger APIs + // we use java.net.URI to manipulate the basePath + // then the uriPath will hold the rest of the path + URI baseUri = create(basePath) + def pathOnly = baseUri.getPath() + [basePath-pathOnly, pathOnly+versionPath+resourcePath] + } + + + def parse(object, container, clazz) { + if (container == "List") { + return object.collect {parse(it, "", clazz)} + } else { + return clazz.newInstance(object) + } + } + +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy new file mode 100644 index 00000000000..a8b0bebeedc --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/PetApi.groovy @@ -0,0 +1,218 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.Pet +import java.io.File +import io.swagger.model.ModelApiResponse + +import java.util.*; + +@Mixin(ApiUtils) +class PetApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + headerParams.put("apiKey", apiKey) + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByStatus" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(status))) + queryParams.put("status", String.valueOf(status)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/findByTags" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(tags))) + queryParams.put("tags", String.valueOf(tags)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "List", + Pet.class ) + + } + def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Pet.class ) + + } + def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } + def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{petId}/uploadImage" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + ModelApiResponse.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy new file mode 100644 index 00000000000..681000fbcdb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/StoreApi.groovy @@ -0,0 +1,104 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import java.util.Map +import io.swagger.model.Order + +import java.util.*; + +@Mixin(ApiUtils) +class StoreApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getInventory ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/inventory" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "Map", + Map.class ) + + } + def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order/{orderId}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + Order.class ) + + } + def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/order" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + Order.class ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy new file mode 100644 index 00000000000..033057a08eb --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/api/UserApi.groovy @@ -0,0 +1,200 @@ +package io.swagger.api; + + + + + +import groovyx.net.http.* +import static groovyx.net.http.ContentType.* +import static groovyx.net.http.Method.* +import io.swagger.api.ApiUtils +//------------- + +import io.swagger.model.User +import java.util.List + +import java.util.*; + +@Mixin(ApiUtils) +class UserApi { + String basePath = "http://petstore.swagger.io/v2" + String versionPath = "/api/v1" + + + def createUser ( User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithArray" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/createWithList" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "POST", "", + null ) + + } + def deleteUser ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "DELETE", "", + null ) + + } + def getUserByName ( String username, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if() { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + User.class ) + + } + def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/login" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + if(!"null".equals(String.valueOf(username))) + queryParams.put("username", String.valueOf(username)) +if(!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)) + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + String.class ) + + } + def logoutUser ( Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/logout" + + + // query params + def queryParams = [:] + def headerParams = [:] + + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "GET", "", + null ) + + } + def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + // create path and map variables + String resourcePath = "/{username}" + + + // query params + def queryParams = [:] + def headerParams = [:] + + // verify required params are set + if( // verify required params are set + if() { + throw new RuntimeException("missing required params") + } +) { + throw new RuntimeException("missing required params") + } + + + + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, + "PUT", "", + null ) + + } +} diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy new file mode 100644 index 00000000000..29509e64e54 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Category.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Category { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy new file mode 100644 index 00000000000..505752a6dc3 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/ModelApiResponse.groovy @@ -0,0 +1,18 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class ModelApiResponse { + + Integer code = null + + String type = null + + String message = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy new file mode 100644 index 00000000000..815c72846d9 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Order.groovy @@ -0,0 +1,27 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +@Canonical +class Order { + + Long id = null + + Long petId = null + + Integer quantity = null + + Date shipDate = null + + /* Order Status */ + String status = null + + Boolean complete = false + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy new file mode 100644 index 00000000000..667ce9430f4 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Pet.groovy @@ -0,0 +1,30 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import java.util.ArrayList; +import java.util.List; +@Canonical +class Pet { + + Long id = null + + Category category = null + + String name = null + + List photoUrls = new ArrayList() + + List tags = new ArrayList() + + /* pet status in the store */ + String status = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy new file mode 100644 index 00000000000..5c30c04a5ff --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/Tag.groovy @@ -0,0 +1,16 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class Tag { + + Long id = null + + String name = null + + +} + diff --git a/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy new file mode 100644 index 00000000000..6889661e9e5 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/java/io/swagger/model/User.groovy @@ -0,0 +1,29 @@ +package io.swagger.model; + +import groovy.transform.Canonical +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +@Canonical +class User { + + Long id = null + + String username = null + + String firstName = null + + String lastName = null + + String email = null + + String password = null + + String phone = null + + /* User Status */ + Integer userStatus = null + + +} + From ea445c1e2884a7acff014254dd9bbe2e784f86b1 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sun, 24 Apr 2016 15:44:52 -0700 Subject: [PATCH 38/63] added missing file --- .../main/resources/go/api_response.mustache | 24 +++++++++++++++++++ .../go/go-petstore/model_api_response.go | 14 +++++++++++ 2 files changed, 38 insertions(+) create mode 100644 modules/swagger-codegen/src/main/resources/go/api_response.mustache create mode 100644 samples/client/petstore/go/go-petstore/model_api_response.go diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache new file mode 100644 index 00000000000..b9110bd9eda --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -0,0 +1,24 @@ +package swagger + +import ( + "net/http" +) + + +type ApiResponse struct { + *http.Response + + Message string `json:"message,omitempty"` +} + +func NewApiResponse(r *http.Response) *ApiResponse { + response := &ApiResponse{Response: r} + + return response +} + +func NewApiResponseWithError(errorMessage string) *ApiResponse { + response := &ApiResponse{Message: errorMessage} + + return response +} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go new file mode 100644 index 00000000000..0905f55cf01 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/model_api_response.go @@ -0,0 +1,14 @@ +package swagger + +import ( +) + + +type ModelApiResponse struct { + + Code int32 `json:"code,omitempty"` + + Type_ string `json:"type,omitempty"` + + Message string `json:"message,omitempty"` +} From 9f0ac5df82492004fcbeb51007cb935a61a3a430 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sun, 24 Apr 2016 15:52:26 -0700 Subject: [PATCH 39/63] added missing model api response md --- .../petstore/go/go-petstore/docs/ModelApiResponse.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md diff --git a/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md b/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md new file mode 100644 index 00000000000..f4af2146829 --- /dev/null +++ b/samples/client/petstore/go/go-petstore/docs/ModelApiResponse.md @@ -0,0 +1,12 @@ +# ModelApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **int32** | | [optional] [default to null] +**Type_** | **string** | | [optional] [default to null] +**Message** | **string** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + From 7599dcb112cfa3bfe66fe2ef8e825d7b094d585a Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Sun, 24 Apr 2016 21:10:32 -0700 Subject: [PATCH 40/63] changed Api to API based on golang's convention --- .../src/main/resources/go/api.mustache | 20 +-- .../src/main/resources/go/api_client.mustache | 14 +-- .../main/resources/go/api_response.mustache | 10 +- .../main/resources/go/configuration.mustache | 18 +-- .../petstore/go/go-petstore/api_client.go | 14 +-- .../petstore/go/go-petstore/api_response.go | 10 +- .../petstore/go/go-petstore/configuration.go | 18 +-- .../client/petstore/go/go-petstore/pet_api.go | 118 +++++++++--------- .../petstore/go/go-petstore/store_api.go | 56 ++++----- .../petstore/go/go-petstore/user_api.go | 118 +++++++++--------- 10 files changed, 198 insertions(+), 198 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 852e70bd447..6e540d3f876 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -37,7 +37,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ {{#allParams}} * @param {{paramName}} {{description}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}ApiResponse, error) { +func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) { var httpMethod = "{{httpMethod}}" // create path and map variables @@ -49,7 +49,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#required}} // verify the required parameter '{{paramName}}' is set if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") } {{/required}} {{/allParams}} @@ -64,11 +64,11 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#authMethods}}// authentication ({{name}}) required {{#isApiKey}}{{#isKeyInHeader}} // set key with prefix in header - headerParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") + headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") {{/isKeyInHeader}}{{#isKeyInQuery}} // set key with prefix in querystring {{#hasKeyParamName}} - queryParams["{{keyParamName}}"] = a.Configuration.GetApiKeyWithPrefix("{{keyParamName}}") + queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") {{/hasKeyParamName}} {{/isKeyInQuery}}{{/isApiKey}} {{#isBasic}} @@ -92,7 +92,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{#hasQueryParams}} {{#queryParams}} - queryParams["{{paramName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}}) + queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}}) {{/queryParams}} {{/hasQueryParams}} @@ -103,7 +103,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/consumes}} } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -114,7 +114,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ {{/produces}} } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -134,18 +134,18 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err } {{#returnType}} err = json.Unmarshal(httpResponse.Body(), &successPayload) {{/returnType}} - return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err } {{/operation}} {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index 91a84551700..a88445656d7 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -3,17 +3,17 @@ package {{packageName}} import ( "strings" "github.com/go-resty/resty" - "errors" + "fmt" "reflect" "bytes" "path/filepath" ) -type ApiClient struct { +type APIClient struct { } -func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { +func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { if (len(contentTypes) == 0){ return "" } @@ -24,7 +24,7 @@ func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *ApiClient) SelectHeaderAccept(accepts []string) string { +func (c *APIClient) SelectHeaderAccept(accepts []string) string { if (len(accepts) == 0){ return "" } @@ -46,7 +46,7 @@ func contains(source []string, containvalue string) bool { } -func (c *ApiClient) CallApi(path string, method string, +func (c *APIClient) CallAPI(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, @@ -78,10 +78,10 @@ func (c *ApiClient) CallApi(path string, method string, return response, err } - return nil, errors.New("Invalid method " + method) + return nil, fmt.Errorf("invalid method %v", method) } -func (c *ApiClient) ParameterToString(obj interface{}) string { +func (c *APIClient) ParameterToString(obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else { diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache index b9110bd9eda..2a34a8cf35a 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_response.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -5,20 +5,20 @@ import ( ) -type ApiResponse struct { +type APIResponse struct { *http.Response Message string `json:"message,omitempty"` } -func NewApiResponse(r *http.Response) *ApiResponse { - response := &ApiResponse{Response: r} +func NewAPIResponse(r *http.Response) *APIResponse { + response := &APIResponse{Response: r} return response } -func NewApiResponseWithError(errorMessage string) *ApiResponse { - response := &ApiResponse{Message: errorMessage} +func NewAPIResponseWithError(errorMessage string) *APIResponse { + response := &APIResponse{Message: errorMessage} return response } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index e5f05a63c12..d971bf0373b 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -7,8 +7,8 @@ import ( type Configuration struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` - ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` - ApiKey map[string] string `json:"apiKey,omitempty"` + APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` + APIKey map[string] string `json:"APIKey,omitempty"` debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` @@ -19,7 +19,7 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` - ApiClient ApiClient `json:"apiClient,omitempty"` + APIClient APIClient `json:"APIClient,omitempty"` } func NewConfiguration() *Configuration { @@ -28,8 +28,8 @@ func NewConfiguration() *Configuration { UserName: "", debug: false, DefaultHeader: make(map[string]string), - ApiKey: make(map[string]string), - ApiKeyPrefix: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}", } } @@ -42,12 +42,12 @@ func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } -func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { - if c.ApiKeyPrefix[apiKeyIdentifier] != ""{ - return c.ApiKeyPrefix[apiKeyIdentifier] + " " + c.ApiKey[apiKeyIdentifier] +func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { + if c.APIKeyPrefix[APIKeyIdentifier] != ""{ + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] } - return c.ApiKey[apiKeyIdentifier] + return c.APIKey[APIKeyIdentifier] } func (c *Configuration) SetDebug(enable bool){ diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 1c04e52fdc4..d4b53512c68 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -3,17 +3,17 @@ package swagger import ( "strings" "github.com/go-resty/resty" - "errors" + "fmt" "reflect" "bytes" "path/filepath" ) -type ApiClient struct { +type APIClient struct { } -func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { +func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { if (len(contentTypes) == 0){ return "" } @@ -24,7 +24,7 @@ func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { return contentTypes[0] // use the first content type specified in 'consumes' } -func (c *ApiClient) SelectHeaderAccept(accepts []string) string { +func (c *APIClient) SelectHeaderAccept(accepts []string) string { if (len(accepts) == 0){ return "" } @@ -46,7 +46,7 @@ func contains(source []string, containvalue string) bool { } -func (c *ApiClient) CallApi(path string, method string, +func (c *APIClient) CallAPI(path string, method string, postBody interface{}, headerParams map[string]string, queryParams map[string]string, @@ -78,10 +78,10 @@ func (c *ApiClient) CallApi(path string, method string, return response, err } - return nil, errors.New("Invalid method " + method) + return nil, fmt.Errorf("invalid method %v", method) } -func (c *ApiClient) ParameterToString(obj interface{}) string { +func (c *APIClient) ParameterToString(obj interface{}) string { if reflect.TypeOf(obj).String() == "[]string" { return strings.Join(obj.([]string), ",") } else { diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go index b9110bd9eda..2a34a8cf35a 100644 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ b/samples/client/petstore/go/go-petstore/api_response.go @@ -5,20 +5,20 @@ import ( ) -type ApiResponse struct { +type APIResponse struct { *http.Response Message string `json:"message,omitempty"` } -func NewApiResponse(r *http.Response) *ApiResponse { - response := &ApiResponse{Response: r} +func NewAPIResponse(r *http.Response) *APIResponse { + response := &APIResponse{Response: r} return response } -func NewApiResponseWithError(errorMessage string) *ApiResponse { - response := &ApiResponse{Message: errorMessage} +func NewAPIResponseWithError(errorMessage string) *APIResponse { + response := &APIResponse{Message: errorMessage} return response } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index 3fe94d36c26..2a1b4096399 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -7,8 +7,8 @@ import ( type Configuration struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` - ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` - ApiKey map[string] string `json:"apiKey,omitempty"` + APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` + APIKey map[string] string `json:"APIKey,omitempty"` debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` @@ -19,7 +19,7 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` - ApiClient ApiClient `json:"apiClient,omitempty"` + APIClient APIClient `json:"APIClient,omitempty"` } func NewConfiguration() *Configuration { @@ -28,8 +28,8 @@ func NewConfiguration() *Configuration { UserName: "", debug: false, DefaultHeader: make(map[string]string), - ApiKey: make(map[string]string), - ApiKeyPrefix: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } } @@ -42,12 +42,12 @@ func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } -func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { - if c.ApiKeyPrefix[apiKeyIdentifier] != ""{ - return c.ApiKeyPrefix[apiKeyIdentifier] + " " + c.ApiKey[apiKeyIdentifier] +func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { + if c.APIKeyPrefix[APIKeyIdentifier] != ""{ + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] } - return c.ApiKey[apiKeyIdentifier] + return c.APIKey[APIKeyIdentifier] } func (c *Configuration) SetDebug(enable bool){ diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index e9ebdf44de4..423e8a795a7 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -35,7 +35,7 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) AddPet (body Pet) (ApiResponse, error) { +func (a PetApi) AddPet (body Pet) (APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -43,7 +43,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") } headerParams := make(map[string]string) @@ -72,7 +72,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { "application/xml", } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -82,7 +82,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -91,14 +91,14 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Deletes a pet @@ -107,7 +107,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) { * @param apiKey * @return void */ -func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { +func (a PetApi) DeletePet (petId int64, apiKey string) (APIResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -116,7 +116,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { // verify the required parameter 'petId' is set if &petId == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") } headerParams := make(map[string]string) @@ -143,7 +143,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -153,7 +153,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -162,14 +162,14 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Finds Pets by status @@ -177,7 +177,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) { * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { +func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -185,7 +185,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { // verify the required parameter 'status' is set if &status == nil { - return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") } headerParams := make(map[string]string) @@ -207,13 +207,13 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["status"] = a.Configuration.ApiClient.ParameterToString(status) + queryParams["status"] = a.Configuration.APIClient.ParameterToString(status) // to determine the Content-Type header localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -223,23 +223,23 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Finds Pets by tags @@ -247,7 +247,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) { * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { +func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -255,7 +255,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { // verify the required parameter 'tags' is set if &tags == nil { - return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") } headerParams := make(map[string]string) @@ -277,13 +277,13 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["tags"] = a.Configuration.ApiClient.ParameterToString(tags) + queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags) // to determine the Content-Type header localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -293,23 +293,23 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new([]Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Find pet by ID @@ -317,7 +317,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) { * @param petId ID of pet to return * @return Pet */ -func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { +func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -326,7 +326,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { // verify the required parameter 'petId' is set if &petId == nil { - return *new(Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") + return *new(Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") } headerParams := make(map[string]string) @@ -339,7 +339,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { // authentication (api_key) required // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") // add default headers if any @@ -352,7 +352,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -362,23 +362,23 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new(Pet) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Update an existing pet @@ -386,7 +386,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) { * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { +func (a PetApi) UpdatePet (body Pet) (APIResponse, error) { var httpMethod = "Put" // create path and map variables @@ -394,7 +394,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") } headerParams := make(map[string]string) @@ -423,7 +423,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { "application/xml", } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -433,7 +433,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -442,14 +442,14 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Updates a pet in the store with form data @@ -459,7 +459,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) { * @param status Updated status of the pet * @return void */ -func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (ApiResponse, error) { +func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -468,7 +468,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api // verify the required parameter 'petId' is set if &petId == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") } headerParams := make(map[string]string) @@ -496,7 +496,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api "application/x-www-form-urlencoded", } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -506,7 +506,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -515,14 +515,14 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api formParams["status"] = status - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * uploads an image @@ -532,7 +532,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api * @param file file to upload * @return ModelApiResponse */ -func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, ApiResponse, error) { +func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -541,7 +541,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil // verify the required parameter 'petId' is set if &petId == nil { - return *new(ModelApiResponse), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") + return *new(ModelApiResponse), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") } headerParams := make(map[string]string) @@ -569,7 +569,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil "multipart/form-data", } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -578,7 +578,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -589,14 +589,14 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil fileName = file.Name() var successPayload = new(ModelApiResponse) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index 5da713a7d95..a8b48f63b39 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -33,7 +33,7 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ * @param orderId ID of the order that needs to be deleted * @return void */ -func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { +func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -42,7 +42,7 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { // verify the required parameter 'orderId' is set if &orderId == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") } headerParams := make(map[string]string) @@ -63,7 +63,7 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -73,28 +73,28 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Returns pet inventories by status * Returns a map of status codes to quantities * @return map[string]int32 */ -func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { +func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -111,7 +111,7 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { // authentication (api_key) required // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetApiKeyWithPrefix("api_key") + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") // add default headers if any @@ -124,7 +124,7 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -133,23 +133,23 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new(map[string]int32) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Find purchase order by ID @@ -157,7 +157,7 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) { * @param orderId ID of pet that needs to be fetched * @return Order */ -func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { +func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -166,7 +166,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { // verify the required parameter 'orderId' is set if &orderId == nil { - return *new(Order), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") } headerParams := make(map[string]string) @@ -187,7 +187,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -197,23 +197,23 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Place an order for a pet @@ -221,7 +221,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) { * @param body order placed for purchasing the pet * @return Order */ -func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { +func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -229,7 +229,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *new(Order), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") } headerParams := make(map[string]string) @@ -250,7 +250,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -260,7 +260,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -269,14 +269,14 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) { postBody = &body var successPayload = new(Order) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 6a6188074b3..228c8d3f9bd 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -33,7 +33,7 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ * @param body Created user object * @return void */ -func (a UserApi) CreateUser (body User) (ApiResponse, error) { +func (a UserApi) CreateUser (body User) (APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -41,7 +41,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") } headerParams := make(map[string]string) @@ -62,7 +62,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -72,7 +72,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -81,14 +81,14 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -96,7 +96,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { +func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -104,7 +104,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") } headerParams := make(map[string]string) @@ -125,7 +125,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -135,7 +135,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -144,14 +144,14 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Creates list of users with given input array @@ -159,7 +159,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) { * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { +func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) { var httpMethod = "Post" // create path and map variables @@ -167,7 +167,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") } headerParams := make(map[string]string) @@ -188,7 +188,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -198,7 +198,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -207,14 +207,14 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Delete user @@ -222,7 +222,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) { * @param username The name that needs to be deleted * @return void */ -func (a UserApi) DeleteUser (username string) (ApiResponse, error) { +func (a UserApi) DeleteUser (username string) (APIResponse, error) { var httpMethod = "Delete" // create path and map variables @@ -231,7 +231,7 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") } headerParams := make(map[string]string) @@ -252,7 +252,7 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -262,21 +262,21 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Get user by user name @@ -284,7 +284,7 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) { * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ -func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { +func (a UserApi) GetUserByName (username string) (User, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -293,7 +293,7 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *new(User), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") + return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") } headerParams := make(map[string]string) @@ -314,7 +314,7 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -324,23 +324,23 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new(User) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Logs user into the system @@ -349,7 +349,7 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) { * @param password The password for login in clear text * @return string */ -func (a UserApi) LoginUser (username string, password string) (string, ApiResponse, error) { +func (a UserApi) LoginUser (username string, password string) (string, APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -357,11 +357,11 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon // verify the required parameter 'username' is set if &username == nil { - return *new(string), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") } // verify the required parameter 'password' is set if &password == nil { - return *new(string), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") } headerParams := make(map[string]string) @@ -377,14 +377,14 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon headerParams[key] = a.Configuration.DefaultHeader[key] } - queryParams["username"] = a.Configuration.ApiClient.ParameterToString(username) - queryParams["password"] = a.Configuration.ApiClient.ParameterToString(password) + queryParams["username"] = a.Configuration.APIClient.ParameterToString(username) + queryParams["password"] = a.Configuration.APIClient.ParameterToString(password) // to determine the Content-Type header localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -394,30 +394,30 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } var successPayload = new(string) - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } err = json.Unmarshal(httpResponse.Body(), &successPayload) - return *successPayload, *NewApiResponse(httpResponse.RawResponse), err + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } /** * Logs out current logged in user session * * @return void */ -func (a UserApi) LogoutUser () (ApiResponse, error) { +func (a UserApi) LogoutUser () (APIResponse, error) { var httpMethod = "Get" // create path and map variables @@ -442,7 +442,7 @@ func (a UserApi) LogoutUser () (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -452,21 +452,21 @@ func (a UserApi) LogoutUser () (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } /** * Updated user @@ -475,7 +475,7 @@ func (a UserApi) LogoutUser () (ApiResponse, error) { * @param body Updated user object * @return void */ -func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { +func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) { var httpMethod = "Put" // create path and map variables @@ -484,11 +484,11 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { // verify the required parameter 'username' is set if &username == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") } // verify the required parameter 'body' is set if &body == nil { - return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") } headerParams := make(map[string]string) @@ -509,7 +509,7 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { localVarHttpContentTypes := []string { } //set Content-Type header - localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { headerParams["Content-Type"] = localVarHttpContentType } @@ -519,7 +519,7 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { "application/json", } //set Accept header - localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { headerParams["Accept"] = localVarHttpHeaderAccept } @@ -528,12 +528,12 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) { postBody = &body - httpResponse, err := a.Configuration.ApiClient.CallApi(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) if err != nil { - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } - return *NewApiResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } From e143c6cd2f2b1ff73f6a67fc3224ecbf6f05853e Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 17:07:42 +0800 Subject: [PATCH 41/63] add validation to ruby model --- .../io/swagger/codegen/CodegenProperty.java | 1 + .../io/swagger/codegen/DefaultCodegen.java | 26 ++++++-- .../src/main/resources/ruby/README.mustache | 1 + .../src/main/resources/ruby/model.mustache | 28 +++++++- ...ith-fake-endpoints-models-for-testing.yaml | 11 ++++ samples/client/petstore/ruby/Gemfile.lock | 34 +++++----- samples/client/petstore/ruby/README.md | 3 +- .../client/petstore/ruby/docs/FormatTest.md | 6 +- samples/client/petstore/ruby/docs/Name.md | 1 + .../ruby/lib/petstore/models/format_test.rb | 66 +++++++++++++++++++ .../petstore/ruby/lib/petstore/models/name.rb | 16 +++-- .../petstore/ruby/spec/models/name_spec.rb | 10 +++ 12 files changed, 172 insertions(+), 31 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index a7045738cc3..42f9d304a3c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -42,6 +42,7 @@ public class CodegenProperty { public Map allowableValues; public CodegenProperty items; public Map vendorExtensions; + public Boolean needValidation; // true if pattern, maximum, etc are set (only used in the mustache template) @Override public int hashCode() diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 76729c8b38a..3e59dad1d4f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -327,6 +327,16 @@ public class DefaultCodegen { this.ensureUniqueParams = ensureUniqueParams; } + /** + * Return the JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33) + * + * @param pattern the pattern (regular expression) + * @return properly-escaped pattern + */ + public String toJSONSchemaPattern(String pattern) { + return escapeText(pattern); + } + /** * Return the file name of the Api Test * @@ -1094,6 +1104,10 @@ public class DefaultCodegen { property.exclusiveMinimum = np.getExclusiveMinimum(); property.exclusiveMaximum = np.getExclusiveMaximum(); + // check if any validation rule defined + if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null) + property.needValidation = true; + // legacy support Map allowableValues = new HashMap(); if (np.getMinimum() != null) { @@ -1111,7 +1125,12 @@ public class DefaultCodegen { StringProperty sp = (StringProperty) p; property.maxLength = sp.getMaxLength(); property.minLength = sp.getMinLength(); - property.pattern = sp.getPattern(); + property.pattern = toJSONSchemaPattern(sp.getPattern()); + + // check if any validation rule defined + if (property.pattern != null || property.minLength != null || property.maxLength != null) + property.needValidation = true; + property.isString = true; if (sp.getEnum() != null) { List _enum = sp.getEnum(); @@ -1802,9 +1821,6 @@ public class DefaultCodegen { if (model.complexType != null) { imports.add(model.complexType); } - p.maxLength = qp.getMaxLength(); - p.minLength = qp.getMinLength(); - p.pattern = qp.getPattern(); p.maximum = qp.getMaximum(); p.exclusiveMaximum = qp.isExclusiveMaximum(); @@ -1812,7 +1828,7 @@ public class DefaultCodegen { p.exclusiveMinimum = qp.isExclusiveMinimum(); p.maxLength = qp.getMaxLength(); p.minLength = qp.getMinLength(); - p.pattern = qp.getPattern(); + p.pattern = toJSONSchemaPattern(qp.getPattern()); p.maxItems = qp.getMaxItems(); p.minItems = qp.getMinItems(); p.uniqueItems = qp.isUniqueItems(); diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache index 7f54eef9e69..f4bafd9b0ea 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache @@ -31,6 +31,7 @@ Then either install the gem locally: ```shell gem install ./{{{gemName}}}-{{{gemVersion}}}.gem ``` +(for development, run `gem install --dev ./{{{gemName}}}-{{{gemVersion}}}.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 5b7b617481f..df23db195f3 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -47,7 +47,9 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end {{/vars}} end -{{#vars}}{{#isEnum}} + + {{#vars}} + {{#isEnum}} # Custom attribute writer method checking allowed values (enum). # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) @@ -57,7 +59,29 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end @{{{name}}} = {{{name}}} end -{{/isEnum}}{{/vars}} + + {{/isEnum}} + {{^isEnum}} + {{#needValidation}} + # Custom attribute writer method with validation + # @param [Object] {{{name}}} Value to be assigned + def {{{name}}}=({{{name}}}) + {{#maximum}} + if {{{name}}} > {{{maximum}}} + fail "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}" + end + {{/maximum}} + {{#minimum}} + if {{{name}}} < {{{minimum}}} + fail "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}" + end + {{/minimum}} + @{{{name}}} = {{{name}}} + end + + {{/needValidation}} + {{/isEnum}} + {{/vars}} # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 2a90f5de066..985b365802b 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -761,22 +761,33 @@ definitions: properties: integer: type: integer + maximum: 100 + minimum: 10 int32: type: integer format: int32 + maximum: 200 + minimum: 20 int64: type: integer format: int64 number: + maximum: 543.2 + minimum: 32.1 type: number float: type: number format: float + maximum: 987.6 + minimum: 54.3 double: type: number format: double + maximum: 123.4 + minimum: 67.8 string: type: string + pattern: /[a‑z]/i byte: type: string format: byte diff --git a/samples/client/petstore/ruby/Gemfile.lock b/samples/client/petstore/ruby/Gemfile.lock index 98c02ee9163..cb8128052ab 100644 --- a/samples/client/petstore/ruby/Gemfile.lock +++ b/samples/client/petstore/ruby/Gemfile.lock @@ -22,29 +22,31 @@ GEM ethon (0.8.1) ffi (>= 1.3.0) ffi (1.9.8) + hashdiff (0.3.0) json (1.8.3) - rspec (3.2.0) - rspec-core (~> 3.2.0) - rspec-expectations (~> 3.2.0) - rspec-mocks (~> 3.2.0) - rspec-core (3.2.2) - rspec-support (~> 3.2.0) - rspec-expectations (3.2.0) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.4) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-mocks (3.2.1) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.2.0) - rspec-support (3.2.2) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) safe_yaml (1.0.4) sys-uname (0.9.2) ffi (>= 1.0.0) typhoeus (1.0.1) ethon (>= 0.8.0) - vcr (2.9.3) - webmock (1.21.0) + vcr (3.0.1) + webmock (1.24.5) addressable (>= 2.3.6) crack (>= 0.3.2) + hashdiff PLATFORMS ruby @@ -55,6 +57,6 @@ DEPENDENCIES autotest-growl (~> 0.2, >= 0.2.16) autotest-rails-pure (~> 4.1, >= 4.1.2) petstore! - rspec (~> 3.2, >= 3.2.0) - vcr (~> 2.9, >= 2.9.3) - webmock (~> 1.6, >= 1.6.2) + rspec (~> 3.4, >= 3.4.0) + vcr (~> 3.0, >= 3.0.1) + webmock (~> 1.24, >= 1.24.3) diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 4dc28289fa3..0d53e95030a 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-20T18:46:00.664+08:00 +- Build date: 2016-04-25T16:31:40.260+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -26,6 +26,7 @@ Then either install the gem locally: ```shell gem install ./petstore-1.0.0.gem ``` +(for development, run `gem install --dev ./petstore-1.0.0.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). diff --git a/samples/client/petstore/ruby/docs/FormatTest.md b/samples/client/petstore/ruby/docs/FormatTest.md index 2b64ed317b2..7197a7a6584 100644 --- a/samples/client/petstore/ruby/docs/FormatTest.md +++ b/samples/client/petstore/ruby/docs/FormatTest.md @@ -10,10 +10,10 @@ Name | Type | Description | Notes **float** | **Float** | | [optional] **double** | **Float** | | [optional] **string** | **String** | | [optional] -**byte** | **String** | | [optional] +**byte** | **String** | | **binary** | **String** | | [optional] -**date** | **Date** | | [optional] +**date** | **Date** | | **date_time** | **DateTime** | | [optional] -**password** | **String** | | [optional] +**password** | **String** | | diff --git a/samples/client/petstore/ruby/docs/Name.md b/samples/client/petstore/ruby/docs/Name.md index 2864a67fbd3..4858862c725 100644 --- a/samples/client/petstore/ruby/docs/Name.md +++ b/samples/client/petstore/ruby/docs/Name.md @@ -5,5 +5,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **Integer** | | **snake_case** | **Integer** | | [optional] +**property** | **String** | | [optional] diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 87b6d4e4695..9a6f8c19c9c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -124,6 +124,72 @@ module Petstore end end + # Custom attribute writer method with validation + # @param [Object] integer Value to be assigned + def integer=(integer) + if integer > 100.0 + fail "invalid value for 'integer', must be smaller than or equal to 100.0" + end + if integer < 10.0 + fail "invalid value for 'integer', must be greater than or equal to 10.0" + end + @integer = integer + end + + # Custom attribute writer method with validation + # @param [Object] int32 Value to be assigned + def int32=(int32) + if int32 > 200.0 + fail "invalid value for 'int32', must be smaller than or equal to 200.0" + end + if int32 < 20.0 + fail "invalid value for 'int32', must be greater than or equal to 20.0" + end + @int32 = int32 + end + + # Custom attribute writer method with validation + # @param [Object] number Value to be assigned + def number=(number) + if number > 543.2 + fail "invalid value for 'number', must be smaller than or equal to 543.2" + end + if number < 32.1 + fail "invalid value for 'number', must be greater than or equal to 32.1" + end + @number = number + end + + # Custom attribute writer method with validation + # @param [Object] float Value to be assigned + def float=(float) + if float > 987.6 + fail "invalid value for 'float', must be smaller than or equal to 987.6" + end + if float < 54.3 + fail "invalid value for 'float', must be greater than or equal to 54.3" + end + @float = float + end + + # Custom attribute writer method with validation + # @param [Object] double Value to be assigned + def double=(double) + if double > 123.4 + fail "invalid value for 'double', must be smaller than or equal to 123.4" + end + if double < 67.8 + fail "invalid value for 'double', must be greater than or equal to 67.8" + end + @double = double + end + + # Custom attribute writer method with validation + # @param [Object] string Value to be assigned + def string=(string) + @string = string + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 9818aa41cc4..c19beea86cb 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -23,11 +23,14 @@ module Petstore attr_accessor :snake_case + attr_accessor :property + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'name' => :'name', - :'snake_case' => :'snake_case' + :'snake_case' => :'snake_case', + :'property' => :'property' } end @@ -35,7 +38,8 @@ module Petstore def self.swagger_types { :'name' => :'Integer', - :'snake_case' => :'Integer' + :'snake_case' => :'Integer', + :'property' => :'String' } end @@ -53,6 +57,9 @@ module Petstore if attributes[:'snake_case'] self.snake_case = attributes[:'snake_case'] end + if attributes[:'property'] + self.property = attributes[:'property'] + end end # Checks equality by comparing each attribute. @@ -61,7 +68,8 @@ module Petstore return true if self.equal?(o) self.class == o.class && name == o.name && - snake_case == o.snake_case + snake_case == o.snake_case && + property == o.property end # @see the `==` method @@ -73,7 +81,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [name, snake_case].hash + [name, snake_case, property].hash end # Builds the object from hash diff --git a/samples/client/petstore/ruby/spec/models/name_spec.rb b/samples/client/petstore/ruby/spec/models/name_spec.rb index 9eef65de2fa..e4942b173b9 100644 --- a/samples/client/petstore/ruby/spec/models/name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/name_spec.rb @@ -56,5 +56,15 @@ describe 'Name' do end end + describe 'test attribute "property"' do + it 'should work' do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + end From ab986a72286d8a6c0057811d67db6c311f9a455b Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 17:36:32 +0800 Subject: [PATCH 42/63] add more validation test for ruby model --- .../src/main/resources/ruby/model.mustache | 18 +++++++ ...ith-fake-endpoints-models-for-testing.yaml | 2 + samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/format_test.rb | 52 +++++++++++++++++++ .../petstore/ruby/spec/api_client_spec.rb | 2 +- 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index df23db195f3..681f0534100 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -66,15 +66,33 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} # Custom attribute writer method with validation # @param [Object] {{{name}}} Value to be assigned def {{{name}}}=({{{name}}}) + if {{{name}}}.nil? + fail "{{{name}}} cannot be nil" + end + + {{#minLength}} + if {{{name}}}.to_s.length > {{{maxLength}}} + fail "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}" + end + + {{/minLength}} + {{#maxLength}} + if {{{name}}}.to_s.length < {{{minLength}}} + fail "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}" + end + + {{/maxLength}} {{#maximum}} if {{{name}}} > {{{maximum}}} fail "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}" end + {{/maximum}} {{#minimum}} if {{{name}}} < {{{minimum}}} fail "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}" end + {{/minimum}} @{{{name}}} = {{{name}}} end diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 985b365802b..b5df273cfdb 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -803,6 +803,8 @@ definitions: password: type: string format: password + maxLength: 64 + minLength: 10 externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 0d53e95030a..eaaf6890616 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T16:31:40.260+08:00 +- Build date: 2016-04-25T17:21:35.959+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 9a6f8c19c9c..6019d5a7996 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -127,69 +127,121 @@ module Petstore # Custom attribute writer method with validation # @param [Object] integer Value to be assigned def integer=(integer) + if integer.nil? + fail "integer cannot be nil" + end + if integer > 100.0 fail "invalid value for 'integer', must be smaller than or equal to 100.0" end + if integer < 10.0 fail "invalid value for 'integer', must be greater than or equal to 10.0" end + @integer = integer end # Custom attribute writer method with validation # @param [Object] int32 Value to be assigned def int32=(int32) + if int32.nil? + fail "int32 cannot be nil" + end + if int32 > 200.0 fail "invalid value for 'int32', must be smaller than or equal to 200.0" end + if int32 < 20.0 fail "invalid value for 'int32', must be greater than or equal to 20.0" end + @int32 = int32 end # Custom attribute writer method with validation # @param [Object] number Value to be assigned def number=(number) + if number.nil? + fail "number cannot be nil" + end + if number > 543.2 fail "invalid value for 'number', must be smaller than or equal to 543.2" end + if number < 32.1 fail "invalid value for 'number', must be greater than or equal to 32.1" end + @number = number end # Custom attribute writer method with validation # @param [Object] float Value to be assigned def float=(float) + if float.nil? + fail "float cannot be nil" + end + if float > 987.6 fail "invalid value for 'float', must be smaller than or equal to 987.6" end + if float < 54.3 fail "invalid value for 'float', must be greater than or equal to 54.3" end + @float = float end # Custom attribute writer method with validation # @param [Object] double Value to be assigned def double=(double) + if double.nil? + fail "double cannot be nil" + end + if double > 123.4 fail "invalid value for 'double', must be smaller than or equal to 123.4" end + if double < 67.8 fail "invalid value for 'double', must be greater than or equal to 67.8" end + @double = double end # Custom attribute writer method with validation # @param [Object] string Value to be assigned def string=(string) + if string.nil? + fail "string cannot be nil" + end + @string = string end + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if password.nil? + fail "password cannot be nil" + end + + if password.to_s.length > 64 + fail "invalid value for 'password', the character length must be smaller than or equal to 64" + end + + if password.to_s.length < 10 + fail "invalid value for 'password', the character length must be great than or equal to 10" + end + + @password = password + end + # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) diff --git a/samples/client/petstore/ruby/spec/api_client_spec.rb b/samples/client/petstore/ruby/spec/api_client_spec.rb index a02d4a2d760..3e57a432391 100644 --- a/samples/client/petstore/ruby/spec/api_client_spec.rb +++ b/samples/client/petstore/ruby/spec/api_client_spec.rb @@ -206,7 +206,7 @@ describe Petstore::ApiClient do end it "fails for invalid collection format" do - proc { api_client.build_collection_param(param, :INVALID) }.should raise_error + proc { api_client.build_collection_param(param, :INVALID) }.should raise_error(RuntimeError, 'unknown collection format: :INVALID') end end From 3c36f1df379154a6e4d7e4a5eb4d53a4ac2d9ad0 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 17:45:32 +0800 Subject: [PATCH 43/63] use ArgumentError in ruby model --- .../src/main/resources/ruby/model.mustache | 12 +++--- samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/format_test.rb | 38 +++++++++---------- .../ruby/lib/petstore/models/order.rb | 2 +- .../petstore/ruby/lib/petstore/models/pet.rb | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 681f0534100..df3dba8cf47 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -55,7 +55,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] if {{{name}}} && !allowed_values.include?({{{name}}}) - fail "invalid value for '{{{name}}}', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}" end @{{{name}}} = {{{name}}} end @@ -67,30 +67,30 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} # @param [Object] {{{name}}} Value to be assigned def {{{name}}}=({{{name}}}) if {{{name}}}.nil? - fail "{{{name}}} cannot be nil" + fail ArgumentError, "{{{name}}} cannot be nil" end {{#minLength}} if {{{name}}}.to_s.length > {{{maxLength}}} - fail "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}" + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}" end {{/minLength}} {{#maxLength}} if {{{name}}}.to_s.length < {{{minLength}}} - fail "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}" + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}" end {{/maxLength}} {{#maximum}} if {{{name}}} > {{{maximum}}} - fail "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}" + fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}" end {{/maximum}} {{#minimum}} if {{{name}}} < {{{minimum}}} - fail "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}" + fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}" end {{/minimum}} diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index eaaf6890616..15ba952dc79 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T17:21:35.959+08:00 +- Build date: 2016-04-25T17:38:59.414+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 6019d5a7996..f15a8abab03 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -128,15 +128,15 @@ module Petstore # @param [Object] integer Value to be assigned def integer=(integer) if integer.nil? - fail "integer cannot be nil" + fail ArgumentError, "integer cannot be nil" end if integer > 100.0 - fail "invalid value for 'integer', must be smaller than or equal to 100.0" + fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0" end if integer < 10.0 - fail "invalid value for 'integer', must be greater than or equal to 10.0" + fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0" end @integer = integer @@ -146,15 +146,15 @@ module Petstore # @param [Object] int32 Value to be assigned def int32=(int32) if int32.nil? - fail "int32 cannot be nil" + fail ArgumentError, "int32 cannot be nil" end if int32 > 200.0 - fail "invalid value for 'int32', must be smaller than or equal to 200.0" + fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0" end if int32 < 20.0 - fail "invalid value for 'int32', must be greater than or equal to 20.0" + fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0" end @int32 = int32 @@ -164,15 +164,15 @@ module Petstore # @param [Object] number Value to be assigned def number=(number) if number.nil? - fail "number cannot be nil" + fail ArgumentError, "number cannot be nil" end if number > 543.2 - fail "invalid value for 'number', must be smaller than or equal to 543.2" + fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2" end if number < 32.1 - fail "invalid value for 'number', must be greater than or equal to 32.1" + fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1" end @number = number @@ -182,15 +182,15 @@ module Petstore # @param [Object] float Value to be assigned def float=(float) if float.nil? - fail "float cannot be nil" + fail ArgumentError, "float cannot be nil" end if float > 987.6 - fail "invalid value for 'float', must be smaller than or equal to 987.6" + fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6" end if float < 54.3 - fail "invalid value for 'float', must be greater than or equal to 54.3" + fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3" end @float = float @@ -200,15 +200,15 @@ module Petstore # @param [Object] double Value to be assigned def double=(double) if double.nil? - fail "double cannot be nil" + fail ArgumentError, "double cannot be nil" end if double > 123.4 - fail "invalid value for 'double', must be smaller than or equal to 123.4" + fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4" end if double < 67.8 - fail "invalid value for 'double', must be greater than or equal to 67.8" + fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8" end @double = double @@ -218,7 +218,7 @@ module Petstore # @param [Object] string Value to be assigned def string=(string) if string.nil? - fail "string cannot be nil" + fail ArgumentError, "string cannot be nil" end @string = string @@ -228,15 +228,15 @@ module Petstore # @param [Object] password Value to be assigned def password=(password) if password.nil? - fail "password cannot be nil" + fail ArgumentError, "password cannot be nil" end if password.to_s.length > 64 - fail "invalid value for 'password', the character length must be smaller than or equal to 64" + fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64" end if password.to_s.length < 10 - fail "invalid value for 'password', the character length must be great than or equal to 10" + fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10" end @password = password diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 81f2601e9d9..a7107947d7b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -90,7 +90,7 @@ module Petstore def status=(status) allowed_values = ["placed", "approved", "delivered"] if status && !allowed_values.include?(status) - fail "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}" end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 095f91ca7c3..70ad05b780e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -92,7 +92,7 @@ module Petstore def status=(status) allowed_values = ["available", "pending", "sold"] if status && !allowed_values.include?(status) - fail "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}" end @status = status end From e17a6205067e9bc127b13ece298826a01fe9cc57 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 19:18:05 +0800 Subject: [PATCH 44/63] add methods to validate the ruby object --- .../io/swagger/codegen/CodegenProperty.java | 2 +- .../io/swagger/codegen/DefaultCodegen.java | 4 +- .../src/main/resources/ruby/model.mustache | 117 ++++++++++++++++-- samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/animal.rb | 17 +++ .../ruby/lib/petstore/models/api_response.rb | 15 +++ .../petstore/ruby/lib/petstore/models/cat.rb | 18 +++ .../ruby/lib/petstore/models/category.rb | 14 +++ .../petstore/ruby/lib/petstore/models/dog.rb | 18 +++ .../ruby/lib/petstore/models/format_test.rb | 112 +++++++++++++++-- .../lib/petstore/models/model_200_response.rb | 13 ++ .../ruby/lib/petstore/models/model_return.rb | 13 ++ .../petstore/ruby/lib/petstore/models/name.rb | 19 +++ .../ruby/lib/petstore/models/order.rb | 24 +++- .../petstore/ruby/lib/petstore/models/pet.rb | 32 ++++- .../lib/petstore/models/special_model_name.rb | 13 ++ .../petstore/ruby/lib/petstore/models/tag.rb | 14 +++ .../petstore/ruby/lib/petstore/models/user.rb | 20 +++ 18 files changed, 439 insertions(+), 28 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 42f9d304a3c..199d51ce19e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -42,7 +42,7 @@ public class CodegenProperty { public Map allowableValues; public CodegenProperty items; public Map vendorExtensions; - public Boolean needValidation; // true if pattern, maximum, etc are set (only used in the mustache template) + public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template) @Override public int hashCode() diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 3e59dad1d4f..7e6c43374ac 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1106,7 +1106,7 @@ public class DefaultCodegen { // check if any validation rule defined if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null) - property.needValidation = true; + property.hasValidation = true; // legacy support Map allowableValues = new HashMap(); @@ -1129,7 +1129,7 @@ public class DefaultCodegen { // check if any validation rule defined if (property.pattern != null || property.minLength != null || property.maxLength != null) - property.needValidation = true; + property.hasValidation = true; property.isString = true; if (sp.getEnum() != null) { diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index df3dba8cf47..337845754a7 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -39,12 +39,109 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} {{#vars}} if attributes[:'{{{baseName}}}'] - {{#isContainer}}if (value = attributes[:'{{{baseName}}}']).is_a?(Array) + {{#isContainer}} + if (value = attributes[:'{{{baseName}}}']).is_a?(Array) self.{{{name}}} = value - end{{/isContainer}}{{^isContainer}}self.{{{name}}} = attributes[:'{{{baseName}}}']{{/isContainer}}{{#defaultValue}} + end + {{/isContainer}} + {{^isContainer}} + self.{{{name}}} = attributes[:'{{{baseName}}}'] + {{/isContainer}} + {{#defaultValue}} else - self.{{{name}}} = {{{defaultValue}}}{{/defaultValue}} + self.{{{name}}} = {{{defaultValue}}} + {{/defaultValue}} end + + {{/vars}} + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + {{#isEnum}} + allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] + if {{{name}}} && !allowed_values.include?({{{name}}}) + invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.") + end + + {{/isEnum}} + {{#hasValidation}} + if {{{name}}}.nil? + fail ArgumentError, "{{{name}}} cannot be nil" + end + + {{#minLength}} + if {{{name}}}.to_s.length > {{{maxLength}}} + invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") + end + + {{/minLength}} + {{#maxLength}} + if {{{name}}}.to_s.length < {{{minLength}}} + invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.") + end + + {{/maxLength}} + {{#maximum}} + if {{{name}}} > {{{maximum}}} + invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.") + end + + {{/maximum}} + {{#minimum}} + if {{{name}}} < {{{minimum}}} + invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.") + end + + {{/minimum}} + {{/hasValidation}} + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + {{#vars}} + {{#required}} + if @{{{name}}}.nil? + return false + end + + {{/required}} + {{#isEnum}} + allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] + if {{{name}}} && !allowed_values.include?({{{name}}}) + return false + end + {{/isEnum}} + {{#hasValidation}} + {{#minLength}} + if {{{name}}}.to_s.length > {{{maxLength}}} + return false + end + + {{/minLength}} + {{#maxLength}} + if {{{name}}}.to_s.length < {{{minLength}}} + return false + end + + {{/maxLength}} + {{#maximum}} + if {{{name}}} > {{{maximum}}} + return false + end + + {{/maximum}} + {{#minimum}} + if {{{name}}} < {{{minimum}}} + return false + end + + {{/minimum}} + {{/hasValidation}} {{/vars}} end @@ -55,14 +152,14 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] if {{{name}}} && !allowed_values.include?({{{name}}}) - fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." end @{{{name}}} = {{{name}}} end {{/isEnum}} {{^isEnum}} - {{#needValidation}} + {{#hasValidation}} # Custom attribute writer method with validation # @param [Object] {{{name}}} Value to be assigned def {{{name}}}=({{{name}}}) @@ -72,32 +169,32 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} {{#minLength}} if {{{name}}}.to_s.length > {{{maxLength}}} - fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}" + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}." end {{/minLength}} {{#maxLength}} if {{{name}}}.to_s.length < {{{minLength}}} - fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}" + fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}." end {{/maxLength}} {{#maximum}} if {{{name}}} > {{{maximum}}} - fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}" + fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}." end {{/maximum}} {{#minimum}} if {{{name}}} < {{{minimum}}} - fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}" + fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}." end {{/minimum}} @{{{name}}} = {{{name}}} end - {{/needValidation}} + {{/hasValidation}} {{/isEnum}} {{/vars}} # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 15ba952dc79..96231298d8b 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T17:38:59.414+08:00 +- Build date: 2016-04-25T19:16:37.992+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 342d3b2464d..2f26f9b4bb0 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -45,6 +45,23 @@ module Petstore if attributes[:'className'] self.class_name = attributes[:'className'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index 683083be4b2..da0418eda50 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -53,12 +53,27 @@ module Petstore if attributes[:'code'] self.code = attributes[:'code'] end + if attributes[:'type'] self.type = attributes[:'type'] end + if attributes[:'message'] self.message = attributes[:'message'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 4489e6abb85..0f8c34f0896 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -49,9 +49,27 @@ module Petstore if attributes[:'className'] self.class_name = attributes[:'className'] end + if attributes[:'declawed'] self.declawed = attributes[:'declawed'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 0f6d61d83af..33e4a539fb3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -49,9 +49,23 @@ module Petstore if attributes[:'id'] self.id = attributes[:'id'] end + if attributes[:'name'] self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 5173f9a01ec..66fd396e753 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -49,9 +49,27 @@ module Petstore if attributes[:'className'] self.class_name = attributes[:'className'] end + if attributes[:'breed'] self.breed = attributes[:'breed'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @class_name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index f15a8abab03..79bcce513d8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -89,39 +89,127 @@ module Petstore if attributes[:'integer'] self.integer = attributes[:'integer'] end + if attributes[:'int32'] self.int32 = attributes[:'int32'] end + if attributes[:'int64'] self.int64 = attributes[:'int64'] end + if attributes[:'number'] self.number = attributes[:'number'] end + if attributes[:'float'] self.float = attributes[:'float'] end + if attributes[:'double'] self.double = attributes[:'double'] end + if attributes[:'string'] self.string = attributes[:'string'] end + if attributes[:'byte'] self.byte = attributes[:'byte'] end + if attributes[:'binary'] self.binary = attributes[:'binary'] end + if attributes[:'date'] self.date = attributes[:'date'] end + if attributes[:'dateTime'] self.date_time = attributes[:'dateTime'] end + if attributes[:'password'] self.password = attributes[:'password'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if integer > 100.0 + return false + end + + if integer < 10.0 + return false + end + + if int32 > 200.0 + return false + end + + if int32 < 20.0 + return false + end + + if @number.nil? + return false + end + + if number > 543.2 + return false + end + + if number < 32.1 + return false + end + + if float > 987.6 + return false + end + + if float < 54.3 + return false + end + + if double > 123.4 + return false + end + + if double < 67.8 + return false + end + + if @byte.nil? + return false + end + + if @date.nil? + return false + end + + if @password.nil? + return false + end + + if password.to_s.length > 64 + return false + end + + if password.to_s.length < 10 + return false + end + end # Custom attribute writer method with validation @@ -132,11 +220,11 @@ module Petstore end if integer > 100.0 - fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0" + fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0." end if integer < 10.0 - fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0" + fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0." end @integer = integer @@ -150,11 +238,11 @@ module Petstore end if int32 > 200.0 - fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0" + fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0." end if int32 < 20.0 - fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0" + fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0." end @int32 = int32 @@ -168,11 +256,11 @@ module Petstore end if number > 543.2 - fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2" + fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2." end if number < 32.1 - fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1" + fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1." end @number = number @@ -186,11 +274,11 @@ module Petstore end if float > 987.6 - fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6" + fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6." end if float < 54.3 - fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3" + fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3." end @float = float @@ -204,11 +292,11 @@ module Petstore end if double > 123.4 - fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4" + fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4." end if double < 67.8 - fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8" + fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8." end @double = double @@ -232,11 +320,11 @@ module Petstore end if password.to_s.length > 64 - fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64" + fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64." end if password.to_s.length < 10 - fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10" + fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10." end @password = password diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 9cacbdb1298..71b4501d99e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -46,6 +46,19 @@ module Petstore if attributes[:'name'] self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 31adf497fa2..bb015662bc4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -46,6 +46,19 @@ module Petstore if attributes[:'return'] self._return = attributes[:'return'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index c19beea86cb..bec29f9c69e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -54,12 +54,31 @@ module Petstore if attributes[:'name'] self.name = attributes[:'name'] end + if attributes[:'snake_case'] self.snake_case = attributes[:'snake_case'] end + if attributes[:'property'] self.property = attributes[:'property'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @name.nil? + return false + end + end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index a7107947d7b..823ad3d9f60 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -66,23 +66,45 @@ module Petstore if attributes[:'id'] self.id = attributes[:'id'] end + if attributes[:'petId'] self.pet_id = attributes[:'petId'] end + if attributes[:'quantity'] self.quantity = attributes[:'quantity'] end + if attributes[:'shipDate'] self.ship_date = attributes[:'shipDate'] end + if attributes[:'status'] self.status = attributes[:'status'] end + if attributes[:'complete'] self.complete = attributes[:'complete'] else self.complete = false end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + allowed_values = ["placed", "approved", "delivered"] + if status && !allowed_values.include?(status) + return false + end end # Custom attribute writer method checking allowed values (enum). @@ -90,7 +112,7 @@ module Petstore def status=(status) allowed_values = ["placed", "approved", "delivered"] if status && !allowed_values.include?(status) - fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 70ad05b780e..898a29a4d28 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -66,25 +66,55 @@ module Petstore if attributes[:'id'] self.id = attributes[:'id'] end + if attributes[:'category'] self.category = attributes[:'category'] end + if attributes[:'name'] self.name = attributes[:'name'] end + if attributes[:'photoUrls'] if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end + if attributes[:'tags'] if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end + if attributes[:'status'] self.status = attributes[:'status'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + if @name.nil? + return false + end + + if @photo_urls.nil? + return false + end + + allowed_values = ["available", "pending", "sold"] + if status && !allowed_values.include?(status) + return false + end end # Custom attribute writer method checking allowed values (enum). @@ -92,7 +122,7 @@ module Petstore def status=(status) allowed_values = ["available", "pending", "sold"] if status && !allowed_values.include?(status) - fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}" + fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}." end @status = status end diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 4c859270d1b..94aa62981aa 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -45,6 +45,19 @@ module Petstore if attributes[:'$special[property.name]'] self.special_property_name = attributes[:'$special[property.name]'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index e5c80ee2228..3ef49f71eaa 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -49,9 +49,23 @@ module Petstore if attributes[:'id'] self.id = attributes[:'id'] end + if attributes[:'name'] self.name = attributes[:'name'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index e7ce160dfa2..b9e7b91b08b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -74,27 +74,47 @@ module Petstore if attributes[:'id'] self.id = attributes[:'id'] end + if attributes[:'username'] self.username = attributes[:'username'] end + if attributes[:'firstName'] self.first_name = attributes[:'firstName'] end + if attributes[:'lastName'] self.last_name = attributes[:'lastName'] end + if attributes[:'email'] self.email = attributes[:'email'] end + if attributes[:'password'] self.password = attributes[:'password'] end + if attributes[:'phone'] self.phone = attributes[:'phone'] end + if attributes[:'userStatus'] self.user_status = attributes[:'userStatus'] end + + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properies with the reasons + def list_invalid_properties + invalid_properties = Array.new + return invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? end # Checks equality by comparing each attribute. From 0e58265eb5a70cd966c269a45acf80f921579baa Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 21:52:37 +0800 Subject: [PATCH 45/63] use instance variable in validation rule --- .../src/main/resources/ruby/model.mustache | 24 +++++++++---------- samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/format_test.rb | 24 +++++++++---------- .../ruby/lib/petstore/models/order.rb | 2 +- .../petstore/ruby/lib/petstore/models/pet.rb | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 337845754a7..e3b5c3851d2 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -62,36 +62,36 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} invalid_properties = Array.new {{#isEnum}} allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if {{{name}}} && !allowed_values.include?({{{name}}}) + if @{{{name}}} && !allowed_values.include?(@{{{name}}}) invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.") end {{/isEnum}} {{#hasValidation}} - if {{{name}}}.nil? + if @{{{name}}}.nil? fail ArgumentError, "{{{name}}} cannot be nil" end {{#minLength}} - if {{{name}}}.to_s.length > {{{maxLength}}} + if @{{{name}}}.to_s.length > {{{maxLength}}} invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") end {{/minLength}} {{#maxLength}} - if {{{name}}}.to_s.length < {{{minLength}}} + if @{{{name}}}.to_s.length < {{{minLength}}} invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.") end {{/maxLength}} {{#maximum}} - if {{{name}}} > {{{maximum}}} + if @{{{name}}} > {{{maximum}}} invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.") end {{/maximum}} {{#minimum}} - if {{{name}}} < {{{minimum}}} + if @{{{name}}} < {{{minimum}}} invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.") end @@ -112,31 +112,31 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} {{/required}} {{#isEnum}} allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if {{{name}}} && !allowed_values.include?({{{name}}}) + if @{{{name}}} && !allowed_values.include?(@{{{name}}}) return false end {{/isEnum}} {{#hasValidation}} {{#minLength}} - if {{{name}}}.to_s.length > {{{maxLength}}} + if @{{{name}}}.to_s.length > {{{maxLength}}} return false end {{/minLength}} {{#maxLength}} - if {{{name}}}.to_s.length < {{{minLength}}} + if @{{{name}}}.to_s.length < {{{minLength}}} return false end {{/maxLength}} {{#maximum}} - if {{{name}}} > {{{maximum}}} + if @{{{name}}} > {{{maximum}}} return false end {{/maximum}} {{#minimum}} - if {{{name}}} < {{{minimum}}} + if @{{{name}}} < {{{minimum}}} return false end @@ -151,7 +151,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if {{{name}}} && !allowed_values.include?({{{name}}}) + if {{{name}}} && !allowed_values.include?(@{{{name}}}) fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." end @{{{name}}} = {{{name}}} diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 96231298d8b..a7dd757d991 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T19:16:37.992+08:00 +- Build date: 2016-04-25T21:47:45.004+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 79bcce513d8..02a996abe50 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -146,19 +146,19 @@ module Petstore # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - if integer > 100.0 + if @integer > 100.0 return false end - if integer < 10.0 + if @integer < 10.0 return false end - if int32 > 200.0 + if @int32 > 200.0 return false end - if int32 < 20.0 + if @int32 < 20.0 return false end @@ -166,27 +166,27 @@ module Petstore return false end - if number > 543.2 + if @number > 543.2 return false end - if number < 32.1 + if @number < 32.1 return false end - if float > 987.6 + if @float > 987.6 return false end - if float < 54.3 + if @float < 54.3 return false end - if double > 123.4 + if @double > 123.4 return false end - if double < 67.8 + if @double < 67.8 return false end @@ -202,11 +202,11 @@ module Petstore return false end - if password.to_s.length > 64 + if @password.to_s.length > 64 return false end - if password.to_s.length < 10 + if @password.to_s.length < 10 return false end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 823ad3d9f60..1ae2a898024 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -102,7 +102,7 @@ module Petstore # @return true if the model is valid def valid? allowed_values = ["placed", "approved", "delivered"] - if status && !allowed_values.include?(status) + if @status && !allowed_values.include?(status) return false end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 898a29a4d28..abd1252a935 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -112,7 +112,7 @@ module Petstore end allowed_values = ["available", "pending", "sold"] - if status && !allowed_values.include?(status) + if @status && !allowed_values.include?(status) return false end end From 4854b79a318baab025f97c57fa4e9b9de153cf42 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 22:23:23 +0800 Subject: [PATCH 46/63] add pattern check to ruby model --- .../src/main/resources/ruby/model.mustache | 22 +++++++++++++++++-- ...ith-fake-endpoints-models-for-testing.yaml | 2 +- samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/format_test.rb | 8 +++++++ .../ruby/lib/petstore/models/order.rb | 2 +- .../petstore/ruby/lib/petstore/models/pet.rb | 2 +- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index e3b5c3851d2..b95b55bcee9 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -62,7 +62,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} invalid_properties = Array.new {{#isEnum}} allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if @{{{name}}} && !allowed_values.include?(@{{{name}}}) + if @{{{name}}} && !allowed_values.include?({{{name}}}) invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.") end @@ -96,6 +96,12 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.") + end + + {{/pattern}} {{/hasValidation}} return invalid_properties end @@ -141,6 +147,12 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + return false + end + + {{/pattern}} {{/hasValidation}} {{/vars}} end @@ -151,7 +163,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] - if {{{name}}} && !allowed_values.include?(@{{{name}}}) + if {{{name}}} && !allowed_values.include?({{{name}}}) fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}." end @{{{name}}} = {{{name}}} @@ -191,6 +203,12 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end {{/minimum}} + {{#pattern}} + if @{{{name}}} !~ Regexp.new({{{pattern}}}) + fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}." + end + + {{/pattern}} @{{{name}}} = {{{name}}} end diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index b5df273cfdb..d77eaac6efd 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -787,7 +787,7 @@ definitions: minimum: 67.8 string: type: string - pattern: /[a‑z]/i + pattern: /[a-z]/i byte: type: string format: byte diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index a7dd757d991..9882a3021ec 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T21:47:45.004+08:00 +- Build date: 2016-04-25T22:22:56.750+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index 02a996abe50..e4373bb955f 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -190,6 +190,10 @@ module Petstore return false end + if @string !~ Regexp.new(/[a-z]/i) + return false + end + if @byte.nil? return false end @@ -309,6 +313,10 @@ module Petstore fail ArgumentError, "string cannot be nil" end + if @string !~ Regexp.new(/[a-z]/i) + fail ArgumentError, "invalid value for 'string', must conform to the pattern /[a-z]/i." + end + @string = string end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index 1ae2a898024..b243b70cfb8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -102,7 +102,7 @@ module Petstore # @return true if the model is valid def valid? allowed_values = ["placed", "approved", "delivered"] - if @status && !allowed_values.include?(status) + if @status && !allowed_values.include?(@status) return false end end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index abd1252a935..cdd312f1dad 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -112,7 +112,7 @@ module Petstore end allowed_values = ["available", "pending", "sold"] - if @status && !allowed_values.include?(status) + if @status && !allowed_values.include?(@status) return false end end From 89703d86b71ec398fbe2f93d0f74ecd47891613f Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 25 Apr 2016 22:45:10 +0800 Subject: [PATCH 47/63] add hasValidation to codegenParameter --- .../src/main/java/io/swagger/codegen/CodegenParameter.java | 1 + .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index e74b95cf2c1..a1a0460d0fa 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -20,6 +20,7 @@ public class CodegenParameter { public Map allowableValues; public CodegenProperty items; public Map vendorExtensions; + public Boolean hasValidation; /** * Determines whether this parameter is mandatory. If the parameter is in "path", diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 7e6c43374ac..2f2258c0609 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1833,6 +1833,12 @@ public class DefaultCodegen { p.minItems = qp.getMinItems(); p.uniqueItems = qp.isUniqueItems(); p.multipleOf = qp.getMultipleOf(); + + if (p.maximum != null || p.exclusiveMaximum != null || + p.minimum != null || p.exclusiveMinimum != null || + p.maxLength != null || p.minLength != null || + p.maxItems != null || p.minItems != null || + p.pattern != null || } else { if (!(param instanceof BodyParameter)) { LOGGER.error("Cannot use Parameter " + param + " as Body Parameter"); From 354449ebfe6a9886524d9eb8e3b1126f2de49cbc Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 26 Apr 2016 00:06:44 +0800 Subject: [PATCH 48/63] add validation to method parameters --- .../io/swagger/codegen/CodegenParameter.java | 1 + .../io/swagger/codegen/CodegenProperty.java | 8 ++ .../io/swagger/codegen/DefaultCodegen.java | 5 +- .../src/main/resources/ruby/api.mustache | 58 ++++++++++-- ...ith-fake-endpoints-models-for-testing.yaml | 90 +++++++++++++++++++ samples/client/petstore/ruby/README.md | 33 ++++--- samples/client/petstore/ruby/lib/petstore.rb | 1 + .../petstore/ruby/lib/petstore/api/pet_api.rb | 48 ++++------ .../ruby/lib/petstore/api/store_api.rb | 33 ++++--- .../ruby/lib/petstore/api/user_api.rb | 51 ++++------- .../client/petstore/ruby/spec/spec_helper.rb | 2 +- 11 files changed, 228 insertions(+), 102 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index a1a0460d0fa..3f38d391e70 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -121,6 +121,7 @@ public class CodegenParameter { output.items = this.items; } output.vendorExtensions = this.vendorExtensions; + output.hasValidation = this.hasValidation; output.isBinary = this.isBinary; output.isByteArray = this.isByteArray; output.isString = this.isString; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 199d51ce19e..79b7c60a9eb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -86,6 +86,7 @@ public class CodegenProperty { result = prime * result + ((setter == null) ? 0 : setter.hashCode()); result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode()); result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode()); + result = prime * result + ((hasValidation == null) ? 0 : hasValidation.hashCode()); result = prime * result + ((isString == null) ? 0 : isString.hashCode()); result = prime * result + ((isInteger == null) ? 0 : isInteger.hashCode()); result = prime * result + ((isLong == null) ? 0 : isLong.hashCode()); @@ -203,12 +204,19 @@ public class CodegenProperty { if (this.allowableValues != other.allowableValues && (this.allowableValues == null || !this.allowableValues.equals(other.allowableValues))) { return false; } + if (this.vendorExtensions != other.vendorExtensions && (this.vendorExtensions == null || !this.vendorExtensions.equals(other.vendorExtensions))) { return false; } + + if (this.hasValidation != other.hasValidation && (this.hasValidation == null || !this.hasValidation.equals(other.hasValidation))) { + return false; + } + if (this.isString != other.isString && (this.isString == null || !this.isString.equals(other.isString))) { return false; } + if (this.isInteger != other.isInteger && (this.isInteger == null || !this.isInteger.equals(other.isInteger))) { return false; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 2f2258c0609..69e56e57935 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1838,7 +1838,10 @@ public class DefaultCodegen { p.minimum != null || p.exclusiveMinimum != null || p.maxLength != null || p.minLength != null || p.maxItems != null || p.minItems != null || - p.pattern != null || + p.pattern != null) { + p.hasValidation = true; + } + } else { if (!(param instanceof BodyParameter)) { LOGGER.error("Cannot use Parameter " + param + " as Body Parameter"); diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index 594a813de72..20b6d4593e3 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -33,19 +33,59 @@ module {{moduleName}} {{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: {{classname}}#{{operationId}} ..." + @api_client.config.logger.debug "Calling API: {{classname}}.{{operationId}} ..." end - {{#allParams}}{{#required}} + {{#allParams}} + {{#required}} # verify the required parameter '{{paramName}}' is set - fail "Missing the required parameter '{{paramName}}' when calling {{operationId}}" if {{{paramName}}}.nil?{{#isEnum}} + fail ArgumentError, "Missing the required parameter '{{paramName}}' when calling {{classname}}.{{operationId}}" if {{{paramName}}}.nil? + {{#isEnum}} + # verify enum value unless [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?({{{paramName}}}) - fail "invalid value for '{{{paramName}}}', must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}" - end{{/isEnum}} - {{/required}}{{^required}}{{#isEnum}} - if opts[:'{{{paramName}}}'] && ![{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(opts[:'{{{paramName}}}']) - fail 'invalid value for "{{{paramName}}}", must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}' + fail ArgumentError, "invalid value for '{{{paramName}}}', must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}" end - {{/isEnum}}{{/required}}{{/allParams}} + {{/isEnum}} + {{/required}} + {{^required}} + {{#isEnum}} + if opts[:'{{{paramName}}}'] && ![{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(opts[:'{{{paramName}}}']) + fail ArgumentError, 'invalid value for "{{{paramName}}}", must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}' + end + {{/isEnum}} + {{/required}} + {{#hasValidation}} + {{#minLength}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.' + end + + {{/minLength}} + {{#maxLength}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.' + end + + {{/maxLength}} + {{#maximum}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} > {{{maximum}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{{maximum}}}.' + end + + {{/maximum}} + {{#minimum}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} < {{{minimum}}} + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be greater than or equal to {{{minimum}}}.' + end + + {{/minimum}} + {{#pattern}} + if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ Regexp.new({{{pattern}}}) + fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.' + end + + {{/pattern}} + {{/hasValidation}} + {{/allParams}} # resource path local_var_path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index d77eaac6efd..29996c16b72 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -559,6 +559,96 @@ paths: description: Invalid username supplied '404': description: User not found + + /fake: + post: + tags: + - fake + summary: Fake endpoint for testing various parameters + description: Fake endpoint for testing various parameters + operationId: testEndpointParameters + produces: + - application/xml + - application/json + parameters: + - name: integer + type: integer + maximum: 100 + minimum: 10 + in: formData + description: None + - name: int32 + type: integer + format: int32 + maximum: 200 + minimum: 20 + in: formData + description: None + - name: int64 + type: integer + format: int64 + in: formData + description: None + - name: number + maximum: 543.2 + minimum: 32.1 + in: formData + description: None + required: true + - name: float + type: number + format: float + maximum: 987.6 + in: formData + description: None + - name: double + type: number + in: formData + format: double + maximum: 123.4 + minimum: 67.8 + required: true + description: None + - name: string + type: string + pattern: /[a-z]/i + in: formData + description: None + required: true + - name: byte + type: string + format: byte + in: formData + description: None + required: true + - name: binary + type: string + format: binary + in: formData + description: None + - name: date + type: string + format: date + in: formData + description: None + - name: dateTime + type: string + format: date-time + in: formData + description: None + - name: password + type: string + format: password + maxLength: 64 + minLength: 10 + in: formData + description: None + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + securityDefinitions: petstore_auth: type: oauth2 diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9882a3021ec..9d9deefd9ee 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T22:22:56.750+08:00 +- Build date: 2016-04-25T23:58:59.140+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -55,22 +55,32 @@ Please follow the [installation](#installation) procedure and then run the follo # Load the gem require 'petstore' -# Setup authorization -Petstore.configure do |config| - # Configure OAuth2 access token for authorization: petstore_auth - config.access_token = 'YOUR ACCESS TOKEN' -end +api_instance = Petstore::FakeApi.new -api_instance = Petstore::PetApi.new +number = "number_example" # String | None -body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store +double = 1.2 # Float | None +string = "string_example" # String | None + +byte = "B" # String | None + +opts = { + integer: 56, # Integer | None + int32: 56, # Integer | None + int64: 789, # Integer | None + float: 3.4, # Float | None + binary: "B", # String | None + date: Date.parse("2013-10-20"), # Date | None + date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None + password: "password_example" # String | None +} begin - #Add a new pet to the store - api_instance.add_pet(body) + #Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, opts) rescue Petstore::ApiError => e - puts "Exception when calling PetApi->add_pet: #{e}" + puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" end ``` @@ -81,6 +91,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 5964a522d9f..f203db3f5ba 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -37,6 +37,7 @@ require 'petstore/models/tag' require 'petstore/models/user' # APIs +require 'petstore/api/fake_api' require 'petstore/api/pet_api' require 'petstore/api/store_api' require 'petstore/api/user_api' diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 4355642fc58..7e4121d5120 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -41,12 +41,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def add_pet_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#add_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.add_pet ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling add_pet" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.add_pet" if body.nil? # resource path local_var_path = "/pet".sub('{format}','json') @@ -101,12 +99,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_pet_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#delete_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.delete_pet ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -160,12 +156,10 @@ module Petstore # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_status_with_http_info(status, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#find_pets_by_status ..." + @api_client.config.logger.debug "Calling API: PetApi.find_pets_by_status ..." end - # verify the required parameter 'status' is set - fail "Missing the required parameter 'status' when calling find_pets_by_status" if status.nil? - + fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status" if status.nil? # resource path local_var_path = "/pet/findByStatus".sub('{format}','json') @@ -220,12 +214,10 @@ module Petstore # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_tags_with_http_info(tags, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#find_pets_by_tags ..." + @api_client.config.logger.debug "Calling API: PetApi.find_pets_by_tags ..." end - # verify the required parameter 'tags' is set - fail "Missing the required parameter 'tags' when calling find_pets_by_tags" if tags.nil? - + fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags" if tags.nil? # resource path local_var_path = "/pet/findByTags".sub('{format}','json') @@ -280,12 +272,10 @@ module Petstore # @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers def get_pet_by_id_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#get_pet_by_id ..." + @api_client.config.logger.debug "Calling API: PetApi.get_pet_by_id ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -339,12 +329,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet ..." + @api_client.config.logger.debug "Calling API: PetApi.update_pet ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling update_pet" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.update_pet" if body.nil? # resource path local_var_path = "/pet".sub('{format}','json') @@ -401,12 +389,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_form_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..." + @api_client.config.logger.debug "Calling API: PetApi.update_pet_with_form ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form" if pet_id.nil? # resource path local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) @@ -465,12 +451,10 @@ module Petstore # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers def upload_file_with_http_info(pet_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: PetApi#upload_file ..." + @api_client.config.logger.debug "Calling API: PetApi.upload_file ..." end - # verify the required parameter 'pet_id' is set - fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil? - + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file" if pet_id.nil? # resource path local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 5a3c8efeb82..04c7f2701d8 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -41,12 +41,14 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_order_with_http_info(order_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#delete_order ..." + @api_client.config.logger.debug "Calling API: StoreApi.delete_order ..." end - # verify the required parameter 'order_id' is set - fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil? - + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order" if order_id.nil? + if order_id < 1.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.delete_order, must be greater than or equal to 1.0.' + end + # resource path local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) @@ -97,9 +99,8 @@ module Petstore # @return [Array<(Hash, Fixnum, Hash)>] Hash data, response status code and response headers def get_inventory_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#get_inventory ..." + @api_client.config.logger.debug "Calling API: StoreApi.get_inventory ..." end - # resource path local_var_path = "/store/inventory".sub('{format}','json') @@ -153,12 +154,18 @@ module Petstore # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def get_order_by_id_with_http_info(order_id, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#get_order_by_id ..." + @api_client.config.logger.debug "Calling API: StoreApi.get_order_by_id ..." end - # verify the required parameter 'order_id' is set - fail "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil? - + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.get_order_by_id" if order_id.nil? + if order_id > 5.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.0.' + end + + if order_id < 1.0 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.0.' + end + # resource path local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s) @@ -212,12 +219,10 @@ module Petstore # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def place_order_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: StoreApi#place_order ..." + @api_client.config.logger.debug "Calling API: StoreApi.place_order ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling place_order" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling StoreApi.place_order" if body.nil? # resource path local_var_path = "/store/order".sub('{format}','json') diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index d5535aac583..469c950934a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -41,12 +41,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_user_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_user ..." + @api_client.config.logger.debug "Calling API: UserApi.create_user ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_user" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_user" if body.nil? # resource path local_var_path = "/user".sub('{format}','json') @@ -99,12 +97,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_array_input_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_users_with_array_input ..." + @api_client.config.logger.debug "Calling API: UserApi.create_users_with_array_input ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_users_with_array_input" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_array_input" if body.nil? # resource path local_var_path = "/user/createWithArray".sub('{format}','json') @@ -157,12 +153,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_list_input_with_http_info(body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#create_users_with_list_input ..." + @api_client.config.logger.debug "Calling API: UserApi.create_users_with_list_input ..." end - # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling create_users_with_list_input" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_list_input" if body.nil? # resource path local_var_path = "/user/createWithList".sub('{format}','json') @@ -215,12 +209,10 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_user_with_http_info(username, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#delete_user ..." + @api_client.config.logger.debug "Calling API: UserApi.delete_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling delete_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user" if username.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) @@ -273,12 +265,10 @@ module Petstore # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers def get_user_by_name_with_http_info(username, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..." + @api_client.config.logger.debug "Calling API: UserApi.get_user_by_name ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name" if username.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) @@ -334,15 +324,12 @@ module Petstore # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers def login_user_with_http_info(username, password, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#login_user ..." + @api_client.config.logger.debug "Calling API: UserApi.login_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling login_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.login_user" if username.nil? # verify the required parameter 'password' is set - fail "Missing the required parameter 'password' when calling login_user" if password.nil? - + fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user" if password.nil? # resource path local_var_path = "/user/login".sub('{format}','json') @@ -396,9 +383,8 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def logout_user_with_http_info(opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#logout_user ..." + @api_client.config.logger.debug "Calling API: UserApi.logout_user ..." end - # resource path local_var_path = "/user/logout".sub('{format}','json') @@ -453,15 +439,12 @@ module Petstore # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_user_with_http_info(username, body, opts = {}) if @api_client.config.debugging - @api_client.config.logger.debug "Calling API: UserApi#update_user ..." + @api_client.config.logger.debug "Calling API: UserApi.update_user ..." end - # verify the required parameter 'username' is set - fail "Missing the required parameter 'username' when calling update_user" if username.nil? - + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.update_user" if username.nil? # verify the required parameter 'body' is set - fail "Missing the required parameter 'body' when calling update_user" if body.nil? - + fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user" if body.nil? # resource path local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s) diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb index 68147e76b72..50702c439b7 100644 --- a/samples/client/petstore/ruby/spec/spec_helper.rb +++ b/samples/client/petstore/ruby/spec/spec_helper.rb @@ -55,7 +55,7 @@ end # create a random order, return its id def prepare_store(store_api) - order_id = random_id + order_id = 5 order = Petstore::Order.new("id" => order_id, "petId" => 123, "quantity" => 789, From 875414ff645cd6f6c9624d9fde16747a1ea236e7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 26 Apr 2016 00:32:01 +0800 Subject: [PATCH 49/63] add new ruby files --- samples/client/petstore/ruby/docs/FakeApi.md | 82 +++++++++ .../ruby/lib/petstore/api/fake_api.rb | 171 ++++++++++++++++++ .../petstore/ruby/spec/api/fake_api_spec.rb | 66 +++++++ 3 files changed, 319 insertions(+) create mode 100644 samples/client/petstore/ruby/docs/FakeApi.md create mode 100644 samples/client/petstore/ruby/lib/petstore/api/fake_api.rb create mode 100644 samples/client/petstore/ruby/spec/api/fake_api_spec.rb diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md new file mode 100644 index 00000000000..a7c0b42a475 --- /dev/null +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -0,0 +1,82 @@ +# Petstore::FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters + + +# **test_endpoint_parameters** +> test_endpoint_parameters(number, double, string, byte, opts) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new + +number = "number_example" # String | None + +double = 1.2 # Float | None + +string = "string_example" # String | None + +byte = "B" # String | None + +opts = { + integer: 56, # Integer | None + int32: 56, # Integer | None + int64: 789, # Integer | None + float: 3.4, # Float | None + binary: "B", # String | None + date: Date.parse("2013-10-20"), # Date | None + date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None + password: "password_example" # String | None +} + +begin + #Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, opts) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **String**| None | + **double** | **Float**| None | + **string** | **String**| None | + **byte** | **String**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Integer**| None | [optional] + **float** | **Float**| None | [optional] + **binary** | **String**| None | [optional] + **date** | **Date**| None | [optional] + **date_time** | **DateTime**| None | [optional] + **password** | **String**| None | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb new file mode 100644 index 00000000000..a0cf2913f43 --- /dev/null +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -0,0 +1,171 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require "uri" + +module Petstore + class FakeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [nil] + def test_endpoint_parameters(number, double, string, byte, opts = {}) + test_endpoint_parameters_with_http_info(number, double, string, byte, opts) + return nil + end + + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_endpoint_parameters_with_http_info(number, double, string, byte, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug "Calling API: FakeApi.test_endpoint_parameters ..." + end + # verify the required parameter 'number' is set + fail ArgumentError, "Missing the required parameter 'number' when calling FakeApi.test_endpoint_parameters" if number.nil? + if number > 543.2 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 543.2.' + end + + if number < 32.1 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 32.1.' + end + + # verify the required parameter 'double' is set + fail ArgumentError, "Missing the required parameter 'double' when calling FakeApi.test_endpoint_parameters" if double.nil? + if double > 123.4 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 123.4.' + end + + if double < 67.8 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 67.8.' + end + + # verify the required parameter 'string' is set + fail ArgumentError, "Missing the required parameter 'string' when calling FakeApi.test_endpoint_parameters" if string.nil? + if string !~ Regexp.new(/[a-z]/i) + fail ArgumentError, 'invalid value for "string" when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i.' + end + + # verify the required parameter 'byte' is set + fail ArgumentError, "Missing the required parameter 'byte' when calling FakeApi.test_endpoint_parameters" if byte.nil? + if opts[:'integer'] > 100.0 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.0.' + end + + if opts[:'integer'] < 10.0 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.0.' + end + + if opts[:'int32'] > 200.0 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.0.' + end + + if opts[:'int32'] < 20.0 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.0.' + end + + if opts[:'float'] > 987.6 + fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.' + end + + if opts[:'password'].to_s.length > 64 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be smaller than or equal to 64.' + end + + if opts[:'password'].to_s.length < 10 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be great than or equal to 10.' + end + + # resource path + local_var_path = "/fake".sub('{format}','json') + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # HTTP header 'Accept' (if needed) + local_header_accept = ['application/xml', 'application/json'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result + + # HTTP header 'Content-Type' + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) + + # form parameters + form_params = {} + form_params["number"] = number + form_params["double"] = double + form_params["string"] = string + form_params["byte"] = byte + form_params["integer"] = opts[:'integer'] if opts[:'integer'] + form_params["int32"] = opts[:'int32'] if opts[:'int32'] + form_params["int64"] = opts[:'int64'] if opts[:'int64'] + form_params["float"] = opts[:'float'] if opts[:'float'] + form_params["binary"] = opts[:'binary'] if opts[:'binary'] + form_params["date"] = opts[:'date'] if opts[:'date'] + form_params["dateTime"] = opts[:'date_time'] if opts[:'date_time'] + form_params["password"] = opts[:'password'] if opts[:'password'] + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_endpoint_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/samples/client/petstore/ruby/spec/api/fake_api_spec.rb b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb new file mode 100644 index 00000000000..84929b8115c --- /dev/null +++ b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb @@ -0,0 +1,66 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::FakeApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'FakeApi' do + before do + # run before each test + @instance = Petstore::FakeApi.new + end + + after do + # run after each test + end + + describe 'test an instance of FakeApi' do + it 'should create an instact of FakeApi' do + @instance.should be_a(Petstore::FakeApi) + end + end + + # unit tests for test_endpoint_parameters + # Fake endpoint for testing various parameters + # Fake endpoint for testing various parameters + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [nil] + describe 'test_endpoint_parameters test' do + it "should work" do + # assertion here + # should be_a() + # should be_nil + # should == + # should_not == + end + end + +end From dc4c8e5864077cd6f8faed421d27a59705a08d18 Mon Sep 17 00:00:00 2001 From: Fabien Da Silva Date: Mon, 18 Apr 2016 15:52:43 +0200 Subject: [PATCH 50/63] [Swift] Force required attrs to be defined with unwrapRequired Fix #2116 Removal of forced unwrapping, replaced by required attributes in constructor --- .../src/main/resources/swift/Models.mustache | 17 +++++++++++++++-- .../src/main/resources/swift/model.mustache | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache index 795fdd3d5e7..378c83525f1 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache @@ -137,9 +137,22 @@ class Decoders { // Decoder for {{{classname}}} Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in let sourceDictionary = source as! [NSObject:AnyObject] + {{#unwrapRequired}} + let instance = {{classname}}({{#requiredVars}}{{^-first}}, {{/-first}}{{#isEnum}}{{name}}: {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "")! {{/isEnum}}{{^isEnum}}{{name}}: Decoders.decode(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]!){{/isEnum}}{{/requiredVars}}) + {{#optionalVars}} + {{#isEnum}} + instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "") + {{/isEnum}} + {{^isEnum}} + instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]) + {{/isEnum}} + {{/optionalVars}} + {{/unwrapRequired}} + {{^unwrapRequired}} let instance = {{classname}}(){{#vars}}{{#isEnum}} - instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? ""){{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}} {{/isEnum}}{{^isEnum}} - instance.{{name}} = Decoders.decode{{^unwrapRequired}}Optional{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}Optional{{/required}}{{/unwrapRequired}}(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]{{#unwrapRequired}}{{#required}}!{{/required}}{{/unwrapRequired}}){{/isEnum}}{{/vars}} + instance.{{name}} = {{classname}}.{{datatypeWithEnum}}(rawValue: (sourceDictionary["{{baseName}}"] as? String) ?? "") {{/isEnum}}{{^isEnum}} + instance.{{name}} = Decoders.decodeOptional(clazz: {{{baseType}}}.self, source: sourceDictionary["{{baseName}}"]){{/isEnum}}{{/vars}} + {{/unwrapRequired}} return instance }{{/model}} {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache index 3c0a47c2987..9c1787e5bcd 100644 --- a/modules/swagger-codegen/src/main/resources/swift/model.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache @@ -21,15 +21,26 @@ public class {{classname}}: JSONEncodable { {{#vars}} {{#isEnum}} {{#description}}/** {{description}} */ - {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} + {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/isEnum}} {{^isEnum}} {{#description}}/** {{description}} */ - {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} + {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/isEnum}} {{/vars}} +{{^unwrapRequired}} public init() {} +{{/unwrapRequired}} +{{#unwrapRequired}} + public init({{#requiredVars}}{{^-first}}, {{/-first}}{{name}}: {{#isEnum}}{{datatypeWithEnum}}!{{/isEnum}}{{^isEnum}}{{datatype}}!{{/isEnum}}{{/requiredVars}}) { + {{#vars}} + {{#requiredVars}} + self.{{name}} = {{name}} + {{/requiredVars}} + {{/vars}} + } +{{/unwrapRequired}} // MARK: JSONEncodable func encodeToJSON() -> AnyObject { From 18783e3fc79c97c72bb34f5deb5b7b8019f8a2ab Mon Sep 17 00:00:00 2001 From: Mateusz Mackowiak Date: Mon, 25 Apr 2016 19:04:00 +0200 Subject: [PATCH 51/63] #1907 JsonModel deserialization errors --- .../resources/objc/ApiClient-body.mustache | 56 +- .../resources/objc/ApiClient-header.mustache | 13 +- samples/client/petstore/objc/README.md | 69 +-- .../objc/SwaggerClient/SWGApiClient.h | 22 +- .../objc/SwaggerClient/SWGApiClient.m | 56 +- .../objc/SwaggerClient/SWGConfiguration.m | 43 +- .../objc/SwaggerClient/SWGInlineResponse200.h | 10 +- .../objc/SwaggerClient/SWGInlineResponse200.m | 4 +- .../petstore/objc/SwaggerClient/SWGPetApi.h | 44 +- .../petstore/objc/SwaggerClient/SWGPetApi.m | 213 +------ .../petstore/objc/SwaggerClient/SWGStoreApi.h | 25 - .../petstore/objc/SwaggerClient/SWGStoreApi.m | 131 +---- .../petstore/objc/SwaggerClient/SWGUserApi.m | 2 +- .../petstore/objc/SwaggerClientTests/Podfile | 4 +- .../SwaggerClient.xcodeproj/project.pbxproj | 20 +- .../SwaggerClient/Launch Screen.storyboard | 50 ++ .../SwaggerClient/SwaggerClient-Info.plist | 12 +- .../Tests/DeserializationTest.m | 48 +- .../client/petstore/objc/docs/SWGCategory.md | 11 + samples/client/petstore/objc/docs/SWGOrder.md | 15 + samples/client/petstore/objc/docs/SWGPet.md | 15 + .../client/petstore/objc/docs/SWGPetApi.md | 530 ++++++++++++++++++ .../client/petstore/objc/docs/SWGStoreApi.md | 244 ++++++++ samples/client/petstore/objc/docs/SWGTag.md | 11 + samples/client/petstore/objc/docs/SWGUser.md | 17 + .../client/petstore/objc/docs/SWGUserApi.md | 466 +++++++++++++++ 26 files changed, 1544 insertions(+), 587 deletions(-) create mode 100644 samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard create mode 100644 samples/client/petstore/objc/docs/SWGCategory.md create mode 100644 samples/client/petstore/objc/docs/SWGOrder.md create mode 100644 samples/client/petstore/objc/docs/SWGPet.md create mode 100644 samples/client/petstore/objc/docs/SWGPetApi.md create mode 100644 samples/client/petstore/objc/docs/SWGStoreApi.md create mode 100644 samples/client/petstore/objc/docs/SWGTag.md create mode 100644 samples/client/petstore/objc/docs/SWGUser.md create mode 100644 samples/client/petstore/objc/docs/SWGUserApi.md diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index 142e14a9e80..18b756f78b0 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -2,6 +2,10 @@ NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject"; +NSString *const {{classPrefix}}DeserializationErrorDomainKey = @"{{classPrefix}}DeserializationErrorDomainKey"; + +NSInteger const {{classPrefix}}TypeMismatchErrorCode = 143553; + static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -288,13 +292,7 @@ static void (^reachabilityChangeBlock)(int); #pragma mark - Deserialize methods -- (id) deserialize:(id) data class:(NSString *) class { - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - +- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { // return nil if data is nil or class is nil if (!data || !class) { return nil; @@ -310,6 +308,12 @@ static void (^reachabilityChangeBlock)(int); return data; } + NSRegularExpression *regexp = nil; + NSTextCheckingResult *match = nil; + NSMutableArray *resultArray = nil; + NSMutableDictionary *resultDict = nil; + NSString *innerType = nil; + // list of models NSString *arrayOfModelsPat = @"NSArray<(.+)>"; regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat @@ -321,14 +325,25 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; + *error = [NSError errorWithDomain:{{classPrefix}}DeserializationErrorDomainKey code:{{classPrefix}}TypeMismatchErrorCode userInfo:userInfo]; + } + return nil; + } NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; } - ]; + }]; return resultArray; } @@ -348,7 +363,12 @@ static void (^reachabilityChangeBlock)(int); resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; + } }]; return resultArray; @@ -369,7 +389,12 @@ static void (^reachabilityChangeBlock)(int); resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else { + * stop = YES; + } }]; return resultDict; @@ -407,7 +432,7 @@ static void (^reachabilityChangeBlock)(int); // model Class ModelClass = NSClassFromString(class); if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [[ModelClass alloc] initWithDictionary:data error:nil]; + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; } return nil; @@ -635,7 +660,12 @@ static void (^reachabilityChangeBlock)(int); } else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { - completionBlock([self deserialize:data class:responseType], error); + NSError * serializationError; + id response = [self deserialize:data class:responseType error:&serializationError]; + if(!response && !error){ + error = serializationError; + } + completionBlock(response, error); }]; } return requestId; diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index a039e7e168e..1cf3db5e523 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -25,6 +25,16 @@ */ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const {{classPrefix}}DeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const {{classPrefix}}TypeMismatchErrorCode; + /** * Log debug message macro */ @@ -171,8 +181,9 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; * * @param data The data will be deserialized. * @param class The type of objective-c object. + * @param error The error */ -- (id) deserialize:(id) data class:(NSString *) class; +- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; /** * Logs request and response diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md index 5223de2bc98..bd0f24851a7 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-04-12T15:30:12.334+08:00 +- Build date: 2016-04-25T18:52:19.055+02:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements @@ -41,18 +41,9 @@ Import the following: #import #import // load models -#import -#import -#import #import -#import -#import -#import -#import #import #import -#import -#import #import #import // load API classes for accessing endpoints @@ -107,20 +98,15 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *SWGPetApi* | [**addPet**](docs/SWGPetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*SWGPetApi* | [**addPetUsingByteArray**](docs/SWGPetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store *SWGPetApi* | [**deletePet**](docs/SWGPetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *SWGPetApi* | [**findPetsByStatus**](docs/SWGPetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status *SWGPetApi* | [**findPetsByTags**](docs/SWGPetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags *SWGPetApi* | [**getPetById**](docs/SWGPetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*SWGPetApi* | [**getPetByIdInObject**](docs/SWGPetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*SWGPetApi* | [**petPetIdtestingByteArraytrueGet**](docs/SWGPetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' *SWGPetApi* | [**updatePet**](docs/SWGPetApi.md#updatepet) | **PUT** /pet | Update an existing pet *SWGPetApi* | [**updatePetWithForm**](docs/SWGPetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *SWGPetApi* | [**uploadFile**](docs/SWGPetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *SWGStoreApi* | [**deleteOrder**](docs/SWGStoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*SWGStoreApi* | [**findOrdersByStatus**](docs/SWGStoreApi.md#findordersbystatus) | **GET** /store/findByStatus | Finds orders by status *SWGStoreApi* | [**getInventory**](docs/SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*SWGStoreApi* | [**getInventoryInObject**](docs/SWGStoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' *SWGStoreApi* | [**getOrderById**](docs/SWGStoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID *SWGStoreApi* | [**placeOrder**](docs/SWGStoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *SWGUserApi* | [**createUser**](docs/SWGUserApi.md#createuser) | **POST** /user | Create user @@ -135,18 +121,9 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [SWG200Response](docs/SWG200Response.md) - - [SWGAnimal](docs/SWGAnimal.md) - - [SWGCat](docs/SWGCat.md) - [SWGCategory](docs/SWGCategory.md) - - [SWGDog](docs/SWGDog.md) - - [SWGFormatTest](docs/SWGFormatTest.md) - - [SWGInlineResponse200](docs/SWGInlineResponse200.md) - - [SWGName](docs/SWGName.md) - [SWGOrder](docs/SWGOrder.md) - [SWGPet](docs/SWGPet.md) - - [SWGReturn](docs/SWGReturn.md) - - [SWGSpecialModelName_](docs/SWGSpecialModelName_.md) - [SWGTag](docs/SWGTag.md) - [SWGUser](docs/SWGUser.md) @@ -154,11 +131,14 @@ Class | Method | HTTP request | Description ## Documentation For Authorization -## test_api_key_header +## petstore_auth -- **Type**: API key -- **API key parameter name**: test_api_key_header -- **Location**: HTTP header +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets ## api_key @@ -166,40 +146,9 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header -## test_http_basic - -- **Type**: HTTP basic authentication - -## test_api_client_secret - -- **Type**: API key -- **API key parameter name**: x-test_api_client_secret -- **Location**: HTTP header - -## test_api_client_id - -- **Type**: API key -- **API key parameter name**: x-test_api_client_id -- **Location**: HTTP header - -## test_api_key_query - -- **Type**: API key -- **API key parameter name**: test_api_key_query -- **Location**: URL query string - -## petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account - - **read:pets**: read your pets - ## Author -apiteam@swagger.io +apiteam@wordnik.com diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index af299ff0008..5d40ef2f5f0 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -12,18 +12,9 @@ * Do not edit the class manually. */ -#import "SWG200Response.h" -#import "SWGAnimal.h" -#import "SWGCat.h" #import "SWGCategory.h" -#import "SWGDog.h" -#import "SWGFormatTest.h" -#import "SWGInlineResponse200.h" -#import "SWGName.h" #import "SWGOrder.h" #import "SWGPet.h" -#import "SWGReturn.h" -#import "SWGSpecialModelName_.h" #import "SWGTag.h" #import "SWGUser.h" @@ -38,6 +29,16 @@ */ extern NSString *const SWGResponseObjectErrorKey; +/** + * A key for deserialization ErrorDomain + */ +extern NSString *const SWGDeserializationErrorDomainKey; + +/** + * Code for deserialization type mismatch error + */ +extern NSInteger const SWGTypeMismatchErrorCode; + /** * Log debug message macro */ @@ -184,8 +185,9 @@ extern NSString *const SWGResponseObjectErrorKey; * * @param data The data will be deserialized. * @param class The type of objective-c object. + * @param error The error */ -- (id) deserialize:(id) data class:(NSString *) class; +- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error; /** * Logs request and response diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index 0c8f21d3ae7..ecdf4aaafb2 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -2,6 +2,10 @@ NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; +NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey"; + +NSInteger const SWGTypeMismatchErrorCode = 143553; + static long requestId = 0; static bool offlineState = false; static NSMutableSet * queuedRequests = nil; @@ -288,13 +292,7 @@ static void (^reachabilityChangeBlock)(int); #pragma mark - Deserialize methods -- (id) deserialize:(id) data class:(NSString *) class { - NSRegularExpression *regexp = nil; - NSTextCheckingResult *match = nil; - NSMutableArray *resultArray = nil; - NSMutableDictionary *resultDict = nil; - NSString *innerType = nil; - +- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error { // return nil if data is nil or class is nil if (!data || !class) { return nil; @@ -310,6 +308,12 @@ static void (^reachabilityChangeBlock)(int); return data; } + NSRegularExpression *regexp = nil; + NSTextCheckingResult *match = nil; + NSMutableArray *resultArray = nil; + NSMutableDictionary *resultDict = nil; + NSString *innerType = nil; + // list of models NSString *arrayOfModelsPat = @"NSArray<(.+)>"; regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat @@ -321,14 +325,25 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + if(![data isKindOfClass: [NSArray class]]) { + if(error) { + NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)}; + *error = [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo]; + } + return nil; + } NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; } - ]; + }]; return resultArray; } @@ -348,7 +363,12 @@ static void (^reachabilityChangeBlock)(int); resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [resultArray addObject:[self deserialize:obj class:innerType]]; + id arrObj = [self deserialize:obj class:innerType error:error]; + if(arrObj) { + [resultArray addObject:arrObj]; + } else { + * stop = YES; + } }]; return resultArray; @@ -369,7 +389,12 @@ static void (^reachabilityChangeBlock)(int); resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; + id dicObj = [self deserialize:obj class:valueType error:error]; + if(dicObj) { + [resultDict setValue:dicObj forKey:key]; + } else { + * stop = YES; + } }]; return resultDict; @@ -407,7 +432,7 @@ static void (^reachabilityChangeBlock)(int); // model Class ModelClass = NSClassFromString(class); if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) { - return [[ModelClass alloc] initWithDictionary:data error:nil]; + return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error]; } return nil; @@ -635,7 +660,12 @@ static void (^reachabilityChangeBlock)(int); } else { [self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { - completionBlock([self deserialize:data class:responseType], error); + NSError * serializationError; + id response = [self deserialize:data class:responseType error:&serializationError]; + if(!response && !error){ + error = serializationError; + } + completionBlock(response, error); }]; } return requestId; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 0e5b36f4a81..c9d80f5c488 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -122,12 +122,12 @@ - (NSDictionary *) authSettings { return @{ - @"test_api_key_header": + @"petstore_auth": @{ - @"type": @"api_key", + @"type": @"oauth", @"in": @"header", - @"key": @"test_api_key_header", - @"value": [self getApiKeyWithPrefix:@"test_api_key_header"] + @"key": @"Authorization", + @"value": [self getAccessToken] }, @"api_key": @{ @@ -136,41 +136,6 @@ @"key": @"api_key", @"value": [self getApiKeyWithPrefix:@"api_key"] }, - @"test_http_basic": - @{ - @"type": @"basic", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getBasicAuthToken] - }, - @"test_api_client_secret": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"x-test_api_client_secret", - @"value": [self getApiKeyWithPrefix:@"x-test_api_client_secret"] - }, - @"test_api_client_id": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"x-test_api_client_id", - @"value": [self getApiKeyWithPrefix:@"x-test_api_client_id"] - }, - @"test_api_key_query": - @{ - @"type": @"api_key", - @"in": @"query", - @"key": @"test_api_key_query", - @"value": [self getApiKeyWithPrefix:@"test_api_key_query"] - }, - @"petstore_auth": - @{ - @"type": @"oauth", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getAccessToken] - }, }; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h index aeb69eafa69..577434faae6 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h @@ -16,17 +16,17 @@ @interface SWGInlineResponse200 : SWGObject -@property(nonatomic) NSArray* tags; +@property(nonatomic) NSArray* /* NSString */ photoUrls; + +@property(nonatomic) NSString* name; @property(nonatomic) NSNumber* _id; @property(nonatomic) NSObject* category; + +@property(nonatomic) NSArray* tags; /* pet status in the store [optional] */ @property(nonatomic) NSString* status; -@property(nonatomic) NSString* name; - -@property(nonatomic) NSArray* /* NSString */ photoUrls; - @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m index 5ac2e7b4057..5fbe9ec6ec2 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m @@ -20,7 +20,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"tags": @"tags", @"id": @"_id", @"category": @"category", @"status": @"status", @"name": @"name", @"photoUrls": @"photoUrls" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"photoUrls": @"photoUrls", @"name": @"name", @"id": @"_id", @"category": @"category", @"tags": @"tags", @"status": @"status" }]; } /** @@ -30,7 +30,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"tags", @"category", @"status", @"name", @"photoUrls"]; + NSArray *optionalProperties = @[@"photoUrls", @"name", @"category", @"tags", @"status"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h index 7f3abaa3949..ef66979613f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h @@ -1,6 +1,5 @@ #import #import "SWGPet.h" -#import "SWGInlineResponse200.h" #import "SWGObject.h" #import "SWGApiClient.h" @@ -33,19 +32,6 @@ completionHandler: (void (^)(NSError* error)) handler; -/// -/// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store -/// -/// -/// @param body Pet object in the form of byte array (optional) -/// -/// -/// @return --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body - completionHandler: (void (^)(NSError* error)) handler; - - /// /// /// Deletes a pet @@ -64,9 +50,9 @@ /// /// /// Finds Pets by status -/// Multiple status values can be provided with comma separated strings +/// Multiple status values can be provided with comma seperated strings /// -/// @param status Status values that need to be considered for query (optional) (default to available) +/// @param status Status values that need to be considered for filter (optional) (default to available) /// /// /// @return NSArray* @@ -100,32 +86,6 @@ completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; -/// -/// -/// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// -/// @param petId ID of pet that needs to be fetched -/// -/// -/// @return SWGInlineResponse200* --(NSNumber*) getPetByIdInObjectWithPetId: (NSNumber*) petId - completionHandler: (void (^)(SWGInlineResponse200* output, NSError* error)) handler; - - -/// -/// -/// Fake endpoint to test byte array return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// -/// @param petId ID of pet that needs to be fetched -/// -/// -/// @return NSString* --(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId - completionHandler: (void (^)(NSString* output, NSError* error)) handler; - - /// /// /// Update an existing pet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 8c7959a8c3f..87201064542 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -1,7 +1,6 @@ #import "SWGPetApi.h" #import "SWGQueryParamCollection.h" #import "SWGPet.h" -#import "SWGInlineResponse200.h" @interface SWGPetApi () @@ -132,70 +131,6 @@ static SWGPetApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test byte array in body parameter for adding a new pet to the store -/// -/// @param body Pet object in the form of byte array (optional) -/// -/// @returns void -/// --(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body - completionHandler: (void (^)(NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet?testing_byte_array=true"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; - - // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - bodyParam = body; - - return [self.apiClient requestWithPath: resourcePath - method: @"POST" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: nil - completionBlock: ^(id data, NSError *error) { - handler(error); - } - ]; -} - /// /// Deletes a pet /// @@ -277,8 +212,8 @@ static SWGPetApi* singletonAPI = nil; /// /// Finds Pets by status -/// Multiple status values can be provided with comma separated strings -/// @param status Status values that need to be considered for query (optional, default to available) +/// Multiple status values can be provided with comma seperated strings +/// @param status Status values that need to be considered for filter (optional, default to available) /// /// @returns NSArray* /// @@ -456,7 +391,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[@"petstore_auth", @"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -480,148 +415,6 @@ static SWGPetApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// @param petId ID of pet that needs to be fetched -/// -/// @returns SWGInlineResponse200* -/// --(NSNumber*) getPetByIdInObjectWithPetId: (NSNumber*) petId - completionHandler: (void (^)(SWGInlineResponse200* output, NSError* error)) handler { - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetByIdInObject`"]; - } - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?response=inline_arbitrary_object"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"SWGInlineResponse200*" - completionBlock: ^(id data, NSError *error) { - handler((SWGInlineResponse200*)data, error); - } - ]; -} - -/// -/// Fake endpoint to test byte array return by 'Find pet by ID' -/// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions -/// @param petId ID of pet that needs to be fetched -/// -/// @returns NSString* -/// --(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId - completionHandler: (void (^)(NSString* output, NSError* error)) handler { - // verify the required parameter 'petId' is set - if (petId == nil) { - [NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `petPetIdtestingByteArraytrueGet`"]; - } - - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/{petId}?testing_byte_array=true"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - if (petId != nil) { - pathParams[@"petId"] = petId; - } - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSString*" - completionBlock: ^(id data, NSError *error) { - handler((NSString*)data, error); - } - ]; -} - /// /// Update an existing pet /// diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h index 039f07c8df7..0a7bc70864a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h @@ -32,19 +32,6 @@ completionHandler: (void (^)(NSError* error)) handler; -/// -/// -/// Finds orders by status -/// A single status value can be provided as a string -/// -/// @param status Status value that needs to be considered for query (optional) (default to placed) -/// -/// -/// @return NSArray* --(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status - completionHandler: (void (^)(NSArray* output, NSError* error)) handler; - - /// /// /// Returns pet inventories by status @@ -57,18 +44,6 @@ (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler; -/// -/// -/// Fake endpoint to test arbitrary object return by 'Get inventory' -/// Returns an arbitrary object which is actually a map of status codes to quantities -/// -/// -/// -/// @return NSObject* --(NSNumber*) getInventoryInObjectWithCompletionHandler: - (void (^)(NSObject* output, NSError* error)) handler; - - /// /// /// Find purchase order by ID diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index af0002db3b3..84cd3a699d0 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -138,72 +138,6 @@ static SWGStoreApi* singletonAPI = nil; ]; } -/// -/// Finds orders by status -/// A single status value can be provided as a string -/// @param status Status value that needs to be considered for query (optional, default to placed) -/// -/// @returns NSArray* -/// --(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status - completionHandler: (void (^)(NSArray* output, NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/findByStatus"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if (status != nil) { - queryParams[@"status"] = status; - } - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSArray*" - completionBlock: ^(id data, NSError *error) { - handler((NSArray*)data, error); - } - ]; -} - /// /// Returns pet inventories by status /// Returns a map of status codes to quantities @@ -265,67 +199,6 @@ static SWGStoreApi* singletonAPI = nil; ]; } -/// -/// Fake endpoint to test arbitrary object return by 'Get inventory' -/// Returns an arbitrary object which is actually a map of status codes to quantities -/// @returns NSObject* -/// --(NSNumber*) getInventoryInObjectWithCompletionHandler: - (void (^)(NSObject* output, NSError* error)) handler { - NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory?response=arbitrary_object"]; - - // remove format in URL if needed - if ([resourcePath rangeOfString:@".{format}"].location != NSNotFound) { - [resourcePath replaceCharactersInRange: [resourcePath rangeOfString:@".{format}"] withString:@".json"]; - } - - NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; - // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[@"application/json", @"application/xml"]]; - if ([headerParams[@"Accept"] length] == 0) { - [headerParams removeObjectForKey:@"Accept"]; - } - - // response content type - NSString *responseContentType; - if ([headerParams objectForKey:@"Accept"]) { - responseContentType = [headerParams[@"Accept"] componentsSeparatedByString:@", "][0]; - } - else { - responseContentType = @""; - } - - // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; - - // Authentication setting - NSArray *authSettings = @[@"api_key"]; - - id bodyParam = nil; - NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; - NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init]; - - return [self.apiClient requestWithPath: resourcePath - method: @"GET" - pathParams: pathParams - queryParams: queryParams - formParams: formParams - files: localVarFiles - body: bodyParam - headerParams: headerParams - authSettings: authSettings - requestContentType: requestContentType - responseContentType: responseContentType - responseType: @"NSObject*" - completionBlock: ^(id data, NSError *error) { - handler((NSObject*)data, error); - } - ]; -} - /// /// Find purchase order by ID /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -373,7 +246,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_api_key_header", @"test_api_key_query"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -436,7 +309,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_api_client_id", @"test_api_client_secret"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 71e729ef02c..914d1822402 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -306,7 +306,7 @@ static SWGUserApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"test_http_basic"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClientTests/Podfile b/samples/client/petstore/objc/SwaggerClientTests/Podfile index ea5cdb0e6e8..22654e6adda 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Podfile +++ b/samples/client/petstore/objc/SwaggerClientTests/Podfile @@ -1,10 +1,10 @@ source 'https://github.com/CocoaPods/Specs.git' -target 'SwaggerClient_Example', :exclusive => true do +target 'SwaggerClient_Example' do pod "SwaggerClient", :path => "../" end -target 'SwaggerClient_Tests', :exclusive => true do +target 'SwaggerClient_Tests' do pod "SwaggerClient", :path => "../" pod 'Specta' diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 867a6811293..f7274144997 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -15,14 +15,15 @@ 6003F59A195388D20070C39A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F599195388D20070C39A /* main.m */; }; 6003F59E195388D20070C39A /* SWGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F59D195388D20070C39A /* SWGAppDelegate.m */; }; 6003F5A7195388D20070C39A /* SWGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* SWGViewController.m */; }; - 6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; }; 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; - 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 94BE6BE84795B5034A811E61 /* libPods-SwaggerClient_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */; }; + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC7027D4B025ABCA7999F /* Main.storyboard */; }; + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC65E342ADA697322D68C /* Images.xcassets */; }; + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */; }; CF0ADB481B5F95D6008A2729 /* PetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0ADB471B5F95D6008A2729 /* PetTest.m */; }; CF8F71391B5F73AC00162980 /* DeserializationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF8F71381B5F73AC00162980 /* DeserializationTest.m */; }; CFDFB4121B3CFFA8009739C5 /* UserApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFDFB40D1B3CFEC3009739C5 /* UserApiTest.m */; }; @@ -56,7 +57,6 @@ 6003F59D195388D20070C39A /* SWGAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWGAppDelegate.m; sourceTree = ""; }; 6003F5A5195388D20070C39A /* SWGViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWGViewController.h; sourceTree = ""; }; 6003F5A6195388D20070C39A /* SWGViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SWGViewController.m; sourceTree = ""; }; - 6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwaggerClient_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; @@ -64,8 +64,10 @@ 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 73CCD82196AABD64F2807C7B /* Pods-SwaggerClient_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests.debug.xcconfig"; sourceTree = ""; }; - 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwaggerClient_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = "Launch Screen.storyboard"; path = "SwaggerClient/Launch Screen.storyboard"; sourceTree = ""; }; + B2ADC65E342ADA697322D68C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SwaggerClient/Images.xcassets; sourceTree = ""; }; + B2ADC7027D4B025ABCA7999F /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Main.storyboard; path = SwaggerClient/Main.storyboard; sourceTree = ""; }; BFB4BE760737508B3CFC23B2 /* Pods-SwaggerClient_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example.release.xcconfig"; sourceTree = ""; }; CF0ADB471B5F95D6008A2729 /* PetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PetTest.m; sourceTree = ""; }; CF8F71381B5F73AC00162980 /* DeserializationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeserializationTest.m; sourceTree = ""; }; @@ -121,6 +123,7 @@ children = ( 6003F58A195388D20070C39A /* SwaggerClient_Example.app */, 6003F5AE195388D20070C39A /* SwaggerClient_Tests.xctest */, + B2ADC084A2C0BDF217832B03 /* Launch Screen.storyboard */, ); name = Products; sourceTree = ""; @@ -143,10 +146,8 @@ children = ( 6003F59C195388D20070C39A /* SWGAppDelegate.h */, 6003F59D195388D20070C39A /* SWGAppDelegate.m */, - 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 6003F5A5195388D20070C39A /* SWGViewController.h */, 6003F5A6195388D20070C39A /* SWGViewController.m */, - 6003F5A8195388D20070C39A /* Images.xcassets */, 6003F594195388D20070C39A /* Supporting Files */, ); name = "Example for SwaggerClient"; @@ -194,6 +195,8 @@ children = ( E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */, 4CCE21315897B7D544C83242 /* README.md */, + B2ADC7027D4B025ABCA7999F /* Main.storyboard */, + B2ADC65E342ADA697322D68C /* Images.xcassets */, ); name = "Podspec Metadata"; sourceTree = ""; @@ -287,9 +290,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, - 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, + B2ADC17C287DCABF329BA8AC /* Main.storyboard in Resources */, + B2ADC2D632658A5F73C6CE66 /* Images.xcassets in Resources */, + B2ADC56977372855A63F4E4D /* Launch Screen.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard new file mode 100644 index 00000000000..36df4e16819 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/Launch Screen.storyboard @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist index d617744f3f4..e21b2835ad7 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SwaggerClient-Info.plist @@ -2,11 +2,6 @@ - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - CFBundleDevelopmentRegion en CFBundleDisplayName @@ -29,6 +24,13 @@ 1.0 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + Launch Screen UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m index 7b4b348e4d5..5f5d274b4b0 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m @@ -26,9 +26,9 @@ [formatter setTimeZone:timezone]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSDate *date = [formatter dateFromString:dateStr]; - - NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*"]; - + NSError* error; + NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*" error:&error]; + XCTAssertNil(error); XCTAssertEqualWithAccuracy([date timeIntervalSinceReferenceDate], [deserializedDate timeIntervalSinceReferenceDate], 0.001); } @@ -38,30 +38,33 @@ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate *dateTime = [formatter dateFromString:dateTimeStr]; - - NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*"]; - + NSError* error; + NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*" error:&error]; + XCTAssertNil(error); XCTAssertEqualWithAccuracy([dateTime timeIntervalSinceReferenceDate], [deserializedDateTime timeIntervalSinceReferenceDate], 0.001); } - (void)testDeserializeObject { NSNumber *data = @1; - NSNumber *result = [apiClient deserialize:data class:@"NSObject*"]; - + NSError* error; + NSNumber *result = [apiClient deserialize:data class:@"NSObject*" error:&error]; + XCTAssertNil(error); XCTAssertEqualObjects(data, result); } - (void)testDeserializeString { NSString *data = @"test string"; - NSString *result = [apiClient deserialize:data class:@"NSString*"]; - + NSError* error; + NSString *result = [apiClient deserialize:data class:@"NSString*" error:&error]; + XCTAssertNil(error); XCTAssertTrue([result isEqualToString:data]); } - (void)testDeserializeListOfString { NSArray *data = @[@"test string"]; - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */"]; - + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */" error:&error]; + XCTAssertNil(error); XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSString class]]); } @@ -88,8 +91,8 @@ @"status": @"available" }]; - - NSArray *result = [apiClient deserialize:data class:@"NSArray*"]; + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray*" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]); @@ -119,8 +122,8 @@ } }; - - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */"]; + NSError* error; + NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]); @@ -134,8 +137,8 @@ @"bar": @1 } }; - - NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */"]; + NSError* error; + NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]); @@ -144,8 +147,8 @@ - (void)testDeserializeNestedList { NSArray *data = @[@[@"foo"]]; - - NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */"]; + NSError* error; + NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error]; XCTAssertTrue([result isKindOfClass:[NSArray class]]); XCTAssertTrue([result[0] isKindOfClass:[NSArray class]]); @@ -157,11 +160,12 @@ NSNumber *result; data = @"true"; - result = [apiClient deserialize:data class:@"NSNumber*"]; + NSError* error; + result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@YES]); data = @"false"; - result = [apiClient deserialize:data class:@"NSNumber*"]; + result = [apiClient deserialize:data class:@"NSNumber*" error:&error]; XCTAssertTrue([result isEqual:@NO]); } diff --git a/samples/client/petstore/objc/docs/SWGCategory.md b/samples/client/petstore/objc/docs/SWGCategory.md new file mode 100644 index 00000000000..93a8d14ecb9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGCategory.md @@ -0,0 +1,11 @@ +# SWGCategory + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**name** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGOrder.md b/samples/client/petstore/objc/docs/SWGOrder.md new file mode 100644 index 00000000000..b2a9f25eae9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGOrder.md @@ -0,0 +1,15 @@ +# SWGOrder + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**petId** | **NSNumber*** | | [optional] +**quantity** | **NSNumber*** | | [optional] +**shipDate** | **NSDate*** | | [optional] +**status** | **NSString*** | Order Status | [optional] +**complete** | **NSNumber*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGPet.md b/samples/client/petstore/objc/docs/SWGPet.md new file mode 100644 index 00000000000..6c7286531f9 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGPet.md @@ -0,0 +1,15 @@ +# SWGPet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**category** | [**SWGCategory***](SWGCategory.md) | | [optional] +**name** | **NSString*** | | +**photoUrls** | **NSArray* /* NSString */** | | +**tags** | [**NSArray<SWGTag>***](SWGTag.md) | | [optional] +**status** | **NSString*** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGPetApi.md b/samples/client/petstore/objc/docs/SWGPetApi.md new file mode 100644 index 00000000000..78a54942c2f --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGPetApi.md @@ -0,0 +1,530 @@ +# SWGPetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](SWGPetApi.md#addpet) | **POST** /pet | Add a new pet to the store +[**deletePet**](SWGPetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](SWGPetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](SWGPetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](SWGPetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](SWGPetApi.md#updatepet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](SWGPetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](SWGPetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +```objc +-(NSNumber*) addPetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Add a new pet to the store + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Add a new pet to the store + [apiInstance addPetWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->addPet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGPet***](SWGPet*.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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) + +# **deletePet** +```objc +-(NSNumber*) deletePetWithPetId: (NSNumber*) petId + apiKey: (NSString*) apiKey + completionHandler: (void (^)(NSError* error)) handler; +``` + +Deletes a pet + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSNumber* petId = @789; // Pet id to delete +NSString* apiKey = @"apiKey_example"; // (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Deletes a pet + [apiInstance deletePetWithPetId:petId + apiKey:apiKey + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->deletePet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| Pet id to delete | + **apiKey** | **NSString***| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **findPetsByStatus** +```objc +-(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status + completionHandler: (void (^)(NSArray* output, NSError* error)) handler; +``` + +Finds Pets by status + +Multiple status values can be provided with comma seperated strings + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSArray* /* NSString */ status = @[@"available"]; // Status values that need to be considered for filter (optional) (default to available) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Finds Pets by status + [apiInstance findPetsByStatusWithStatus:status + completionHandler: ^(NSArray* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->findPetsByStatus: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**NSArray* /* NSString */**](NSString*.md)| Status values that need to be considered for filter | [optional] [default to available] + +### Return type + +[**NSArray***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **findPetsByTags** +```objc +-(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags + completionHandler: (void (^)(NSArray* output, NSError* error)) handler; +``` + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSArray* /* NSString */ tags = @[@"tags_example"]; // Tags to filter by (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Finds Pets by tags + [apiInstance findPetsByTagsWithTags:tags + completionHandler: ^(NSArray* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->findPetsByTags: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**NSArray* /* NSString */**](NSString*.md)| Tags to filter by | [optional] + +### Return type + +[**NSArray***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getPetById** +```objc +-(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId + completionHandler: (void (^)(SWGPet* output, NSError* error)) handler; +``` + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + +// Configure API key authorization: (authentication scheme: api_key) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"api_key"]; + + +NSNumber* petId = @789; // ID of pet that needs to be fetched + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Find pet by ID + [apiInstance getPetByIdWithPetId:petId + completionHandler: ^(SWGPet* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->getPetById: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| ID of pet that needs to be fetched | + +### Return type + +[**SWGPet***](SWGPet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +```objc +-(NSNumber*) updatePetWithBody: (SWGPet*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Update an existing pet + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +SWGPet* body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Update an existing pet + [apiInstance updatePetWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->updatePet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGPet***](SWGPet*.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[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) + +# **updatePetWithForm** +```objc +-(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId + name: (NSString*) name + status: (NSString*) status + completionHandler: (void (^)(NSError* error)) handler; +``` + +Updates a pet in the store with form data + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSString* petId = @"petId_example"; // ID of pet that needs to be updated +NSString* name = @"name_example"; // Updated name of the pet (optional) +NSString* status = @"status_example"; // Updated status of the pet (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Updates a pet in the store with form data + [apiInstance updatePetWithFormWithPetId:petId + name:name + status:status + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->updatePetWithForm: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSString***| ID of pet that needs to be updated | + **name** | **NSString***| Updated name of the pet | [optional] + **status** | **NSString***| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +[[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) + +# **uploadFile** +```objc +-(NSNumber*) uploadFileWithPetId: (NSNumber*) petId + additionalMetadata: (NSString*) additionalMetadata + file: (NSURL*) file + completionHandler: (void (^)(NSError* error)) handler; +``` + +uploads an image + + + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +NSNumber* petId = @789; // ID of pet to update +NSString* additionalMetadata = @"additionalMetadata_example"; // Additional data to pass to server (optional) +NSURL* file = [NSURL fileURLWithPath:@"/path/to/file.txt"]; // file to upload (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // uploads an image + [apiInstance uploadFileWithPetId:petId + additionalMetadata:additionalMetadata + file:file + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->uploadFile: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **NSNumber***| ID of pet to update | + **additionalMetadata** | **NSString***| Additional data to pass to server | [optional] + **file** | **NSURL***| file to upload | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +[[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/objc/docs/SWGStoreApi.md b/samples/client/petstore/objc/docs/SWGStoreApi.md new file mode 100644 index 00000000000..1eacf83431a --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGStoreApi.md @@ -0,0 +1,244 @@ +# SWGStoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](SWGStoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](SWGStoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](SWGStoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +```objc +-(NSNumber*) deleteOrderWithOrderId: (NSString*) orderId + completionHandler: (void (^)(NSError* error)) handler; +``` + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```objc + +NSString* orderId = @"orderId_example"; // ID of the order that needs to be deleted + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Delete purchase order by ID + [apiInstance deleteOrderWithOrderId:orderId + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->deleteOrder: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **NSString***| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getInventory** +```objc +-(NSNumber*) getInventoryWithCompletionHandler: + (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler; +``` + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```objc +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure API key authorization: (authentication scheme: api_key) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"api_key"]; + + + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Returns pet inventories by status + [apiInstance getInventoryWithCompletionHandler: + ^(NSDictionary* /* NSString, NSNumber */ output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->getInventory: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**NSDictionary* /* NSString, NSNumber */**](NSDictionary.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getOrderById** +```objc +-(NSNumber*) getOrderByIdWithOrderId: (NSString*) orderId + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; +``` + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```objc + +NSString* orderId = @"orderId_example"; // ID of pet that needs to be fetched + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Find purchase order by ID + [apiInstance getOrderByIdWithOrderId:orderId + completionHandler: ^(SWGOrder* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->getOrderById: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **NSString***| ID of pet that needs to be fetched | + +### Return type + +[**SWGOrder***](SWGOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +```objc +-(NSNumber*) placeOrderWithBody: (SWGOrder*) body + completionHandler: (void (^)(SWGOrder* output, NSError* error)) handler; +``` + +Place an order for a pet + + + +### Example +```objc + +SWGOrder* body = [[SWGOrder alloc] init]; // order placed for purchasing the pet (optional) + +@try +{ + SWGStoreApi *apiInstance = [[SWGStoreApi alloc] init]; + + // Place an order for a pet + [apiInstance placeOrderWithBody:body + completionHandler: ^(SWGOrder* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGStoreApi->placeOrder: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGOrder***](SWGOrder*.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**SWGOrder***](SWGOrder.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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/objc/docs/SWGTag.md b/samples/client/petstore/objc/docs/SWGTag.md new file mode 100644 index 00000000000..5495d5c8a99 --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGTag.md @@ -0,0 +1,11 @@ +# SWGTag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**name** | **NSString*** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGUser.md b/samples/client/petstore/objc/docs/SWGUser.md new file mode 100644 index 00000000000..35bf5540cad --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGUser.md @@ -0,0 +1,17 @@ +# SWGUser + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_id** | **NSNumber*** | | [optional] +**username** | **NSString*** | | [optional] +**firstName** | **NSString*** | | [optional] +**lastName** | **NSString*** | | [optional] +**email** | **NSString*** | | [optional] +**password** | **NSString*** | | [optional] +**phone** | **NSString*** | | [optional] +**userStatus** | **NSNumber*** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/objc/docs/SWGUserApi.md b/samples/client/petstore/objc/docs/SWGUserApi.md new file mode 100644 index 00000000000..4fe7a25bccf --- /dev/null +++ b/samples/client/petstore/objc/docs/SWGUserApi.md @@ -0,0 +1,466 @@ +# SWGUserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](SWGUserApi.md#createuser) | **POST** /user | Create user +[**createUsersWithArrayInput**](SWGUserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](SWGUserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](SWGUserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](SWGUserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +[**loginUser**](SWGUserApi.md#loginuser) | **GET** /user/login | Logs user into the system +[**logoutUser**](SWGUserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](SWGUserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +# **createUser** +```objc +-(NSNumber*) createUserWithBody: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Create user + +This can only be done by the logged in user. + +### Example +```objc + +SWGUser* body = [[SWGUser alloc] init]; // Created user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Create user + [apiInstance createUserWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SWGUser***](SWGUser*.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +```objc +-(NSNumber*) createUsersWithArrayInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Creates list of users with given input array + + + +### Example +```objc + +NSArray* body = @[[[SWGUser alloc] init]]; // List of user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Creates list of users with given input array + [apiInstance createUsersWithArrayInputWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUsersWithArrayInput: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**NSArray<SWGUser>***](SWGUser.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +```objc +-(NSNumber*) createUsersWithListInputWithBody: (NSArray*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Creates list of users with given input array + + + +### Example +```objc + +NSArray* body = @[[[SWGUser alloc] init]]; // List of user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Creates list of users with given input array + [apiInstance createUsersWithListInputWithBody:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->createUsersWithListInput: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**NSArray<SWGUser>***](SWGUser.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **deleteUser** +```objc +-(NSNumber*) deleteUserWithUsername: (NSString*) username + completionHandler: (void (^)(NSError* error)) handler; +``` + +Delete user + +This can only be done by the logged in user. + +### Example +```objc + +NSString* username = @"username_example"; // The name that needs to be deleted + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Delete user + [apiInstance deleteUserWithUsername:username + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->deleteUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **getUserByName** +```objc +-(NSNumber*) getUserByNameWithUsername: (NSString*) username + completionHandler: (void (^)(SWGUser* output, NSError* error)) handler; +``` + +Get user by user name + + + +### Example +```objc + +NSString* username = @"username_example"; // The name that needs to be fetched. Use user1 for testing. + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Get user by user name + [apiInstance getUserByNameWithUsername:username + completionHandler: ^(SWGUser* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->getUserByName: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**SWGUser***](SWGUser.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **loginUser** +```objc +-(NSNumber*) loginUserWithUsername: (NSString*) username + password: (NSString*) password + completionHandler: (void (^)(NSString* output, NSError* error)) handler; +``` + +Logs user into the system + + + +### Example +```objc + +NSString* username = @"username_example"; // The user name for login (optional) +NSString* password = @"password_example"; // The password for login in clear text (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Logs user into the system + [apiInstance loginUserWithUsername:username + password:password + completionHandler: ^(NSString* output, NSError* error) { + if (output) { + NSLog(@"%@", output); + } + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->loginUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| The user name for login | [optional] + **password** | **NSString***| The password for login in clear text | [optional] + +### Return type + +**NSString*** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + +# **logoutUser** +```objc +-(NSNumber*) logoutUserWithCompletionHandler: + (void (^)(NSError* error)) handler; +``` + +Logs out current logged in user session + + + +### Example +```objc + + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Logs out current logged in user session + [apiInstance logoutUserWithCompletionHandler: + ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->logoutUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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** +```objc +-(NSNumber*) updateUserWithUsername: (NSString*) username + body: (SWGUser*) body + completionHandler: (void (^)(NSError* error)) handler; +``` + +Updated user + +This can only be done by the logged in user. + +### Example +```objc + +NSString* username = @"username_example"; // name that need to be deleted +SWGUser* body = [[SWGUser alloc] init]; // Updated user object (optional) + +@try +{ + SWGUserApi *apiInstance = [[SWGUserApi alloc] init]; + + // Updated user + [apiInstance updateUserWithUsername:username + body:body + completionHandler: ^(NSError* error) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGUserApi->updateUser: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **NSString***| name that need to be deleted | + **body** | [**SWGUser***](SWGUser*.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[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) + From a3701cd81cd893850d316cd995fb725c0f9ea7e8 Mon Sep 17 00:00:00 2001 From: Silvio Heuberger Date: Thu, 31 Mar 2016 14:26:14 +0200 Subject: [PATCH 52/63] Update retrofit2 and retrofit2rx to use retrofit 2.0.1 --- .../swagger/codegen/languages/JavaClientCodegen.java | 2 +- .../Java/libraries/retrofit2/build.gradle.mustache | 5 ++--- .../resources/Java/libraries/retrofit2/pom.mustache | 10 +++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 9fe2b6fc370..2bd79dbf015 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -110,7 +110,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6"); supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1"); supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)"); - supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta4). Enable the RxJava adapter using '-DuseRxJava=true'."); + supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.1). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.2)"); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); library.setDefault(DEFAULT_LIBRARY); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 1be055c1fff..3f07e9df177 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -94,9 +94,8 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.1" - retrofit_version = "2.0.0-beta4" - gson_version = "2.6.2" + oltu_version = "1.0.0" + retrofit_version = "2.0.1" swagger_annotations_version = "1.5.8" junit_version = "4.12" {{#useRxJava}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index 11bbae5797a..d120e7255c6 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -122,11 +122,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -153,8 +148,9 @@ 1.5.8 - 2.0.0-beta4{{#useRxJava}} - 1.1.3{{/useRxJava}} + 2.0.1 + {{#useRxJava}}1.1.3{{/useRxJava}} + 3.0.1 1.0.1 1.0.0 4.12 From 4b3dad7fb0c0bace15a0c039b8130bcc8f7668c3 Mon Sep 17 00:00:00 2001 From: Silvio Heuberger Date: Fri, 1 Apr 2016 11:00:50 +0200 Subject: [PATCH 53/63] Fix pom.mustache of retrofit2 client lib --- .../src/main/resources/Java/libraries/retrofit2/pom.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index d120e7255c6..e33d026aaf5 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -112,6 +112,11 @@ swagger-annotations ${swagger-core-version} + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} + com.squareup.retrofit2 retrofit From 2b71165584cda00294cd57d6bd58d93b406ecde7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 27 Apr 2016 00:06:29 +0800 Subject: [PATCH 54/63] fix date mapping in qt5cpp --- .../main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java index ff75d795656..aa32eb4e510 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java @@ -111,7 +111,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { super.typeMapping = new HashMap(); - typeMapping.put("Date", "QDate"); + typeMapping.put("date", "QDate"); typeMapping.put("DateTime", "QDateTime"); typeMapping.put("string", "QString"); typeMapping.put("integer", "qint32"); From 1361bb7c0bdfd5491812422f893dafc61dd825c3 Mon Sep 17 00:00:00 2001 From: Brian Hou Date: Tue, 26 Apr 2016 10:21:16 -0700 Subject: [PATCH 55/63] Fix ruby model boolean attributes --- .../src/main/resources/ruby/model.mustache | 2 +- samples/client/petstore/ruby/README.md | 2 +- .../ruby/lib/petstore/models/animal.rb | 2 +- .../ruby/lib/petstore/models/api_response.rb | 6 ++--- .../petstore/ruby/lib/petstore/models/cat.rb | 4 ++-- .../ruby/lib/petstore/models/category.rb | 4 ++-- .../petstore/ruby/lib/petstore/models/dog.rb | 4 ++-- .../ruby/lib/petstore/models/format_test.rb | 24 +++++++++---------- .../lib/petstore/models/model_200_response.rb | 2 +- .../ruby/lib/petstore/models/model_return.rb | 2 +- .../petstore/ruby/lib/petstore/models/name.rb | 6 ++--- .../ruby/lib/petstore/models/order.rb | 12 +++++----- .../petstore/ruby/lib/petstore/models/pet.rb | 12 +++++----- .../lib/petstore/models/special_model_name.rb | 2 +- .../petstore/ruby/lib/petstore/models/tag.rb | 4 ++-- .../petstore/ruby/lib/petstore/models/user.rb | 16 ++++++------- .../petstore/ruby/spec/base_object_spec.rb | 10 +++++++- 17 files changed, 61 insertions(+), 53 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index b95b55bcee9..14f26898d2b 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -38,7 +38,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} {{#vars}} - if attributes[:'{{{baseName}}}'] + if attributes.has_key?(:'{{{baseName}}}') {{#isContainer}} if (value = attributes[:'{{{baseName}}}']).is_a?(Array) self.{{{name}}} = value diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9d9deefd9ee..cab06a92ce1 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-25T23:58:59.140+08:00 +- Build date: 2016-04-26T10:05:22.048-07:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 2f26f9b4bb0..5612f227d09 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -42,7 +42,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb index da0418eda50..79da573e941 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/api_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -50,15 +50,15 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'code'] + if attributes.has_key?(:'code') self.code = attributes[:'code'] end - if attributes[:'type'] + if attributes.has_key?(:'type') self.type = attributes[:'type'] end - if attributes[:'message'] + if attributes.has_key?(:'message') self.message = attributes[:'message'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 0f8c34f0896..12f17b85553 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'declawed'] + if attributes.has_key?(:'declawed') self.declawed = attributes[:'declawed'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 33e4a539fb3..c4879d65bb4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 66fd396e753..90d213dbf45 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] + if attributes.has_key?(:'className') self.class_name = attributes[:'className'] end - if attributes[:'breed'] + if attributes.has_key?(:'breed') self.breed = attributes[:'breed'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index e4373bb955f..a7ebd095f9d 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -86,51 +86,51 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'integer'] + if attributes.has_key?(:'integer') self.integer = attributes[:'integer'] end - if attributes[:'int32'] + if attributes.has_key?(:'int32') self.int32 = attributes[:'int32'] end - if attributes[:'int64'] + if attributes.has_key?(:'int64') self.int64 = attributes[:'int64'] end - if attributes[:'number'] + if attributes.has_key?(:'number') self.number = attributes[:'number'] end - if attributes[:'float'] + if attributes.has_key?(:'float') self.float = attributes[:'float'] end - if attributes[:'double'] + if attributes.has_key?(:'double') self.double = attributes[:'double'] end - if attributes[:'string'] + if attributes.has_key?(:'string') self.string = attributes[:'string'] end - if attributes[:'byte'] + if attributes.has_key?(:'byte') self.byte = attributes[:'byte'] end - if attributes[:'binary'] + if attributes.has_key?(:'binary') self.binary = attributes[:'binary'] end - if attributes[:'date'] + if attributes.has_key?(:'date') self.date = attributes[:'date'] end - if attributes[:'dateTime'] + if attributes.has_key?(:'dateTime') self.date_time = attributes[:'dateTime'] end - if attributes[:'password'] + if attributes.has_key?(:'password') self.password = attributes[:'password'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index 71b4501d99e..7a2473fb8b9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -43,7 +43,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index bb015662bc4..0361451b290 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -43,7 +43,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'return'] + if attributes.has_key?(:'return') self._return = attributes[:'return'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index bec29f9c69e..d5e3ef4adb8 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -51,15 +51,15 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'snake_case'] + if attributes.has_key?(:'snake_case') self.snake_case = attributes[:'snake_case'] end - if attributes[:'property'] + if attributes.has_key?(:'property') self.property = attributes[:'property'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index b243b70cfb8..6c021e50ec7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -63,27 +63,27 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'petId'] + if attributes.has_key?(:'petId') self.pet_id = attributes[:'petId'] end - if attributes[:'quantity'] + if attributes.has_key?(:'quantity') self.quantity = attributes[:'quantity'] end - if attributes[:'shipDate'] + if attributes.has_key?(:'shipDate') self.ship_date = attributes[:'shipDate'] end - if attributes[:'status'] + if attributes.has_key?(:'status') self.status = attributes[:'status'] end - if attributes[:'complete'] + if attributes.has_key?(:'complete') self.complete = attributes[:'complete'] else self.complete = false diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index cdd312f1dad..ba4d466df21 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -63,31 +63,31 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'category'] + if attributes.has_key?(:'category') self.category = attributes[:'category'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end - if attributes[:'photoUrls'] + if attributes.has_key?(:'photoUrls') if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end - if attributes[:'tags'] + if attributes.has_key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes[:'status'] + if attributes.has_key?(:'status') self.status = attributes[:'status'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index 94aa62981aa..853d1e49600 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -42,7 +42,7 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'$special[property.name]'] + if attributes.has_key?(:'$special[property.name]') self.special_property_name = attributes[:'$special[property.name]'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index 3ef49f71eaa..d6d49068e37 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -46,11 +46,11 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'name'] + if attributes.has_key?(:'name') self.name = attributes[:'name'] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index b9e7b91b08b..f0c39b741d5 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -71,35 +71,35 @@ module Petstore # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] + if attributes.has_key?(:'id') self.id = attributes[:'id'] end - if attributes[:'username'] + if attributes.has_key?(:'username') self.username = attributes[:'username'] end - if attributes[:'firstName'] + if attributes.has_key?(:'firstName') self.first_name = attributes[:'firstName'] end - if attributes[:'lastName'] + if attributes.has_key?(:'lastName') self.last_name = attributes[:'lastName'] end - if attributes[:'email'] + if attributes.has_key?(:'email') self.email = attributes[:'email'] end - if attributes[:'password'] + if attributes.has_key?(:'password') self.password = attributes[:'password'] end - if attributes[:'phone'] + if attributes.has_key?(:'phone') self.phone = attributes[:'phone'] end - if attributes[:'userStatus'] + if attributes.has_key?(:'userStatus') self.user_status = attributes[:'userStatus'] end diff --git a/samples/client/petstore/ruby/spec/base_object_spec.rb b/samples/client/petstore/ruby/spec/base_object_spec.rb index 61dcb4d6d9d..a315d52276b 100644 --- a/samples/client/petstore/ruby/spec/base_object_spec.rb +++ b/samples/client/petstore/ruby/spec/base_object_spec.rb @@ -30,8 +30,16 @@ class ArrayMapObject < Petstore::Category end end - describe 'BaseObject' do + describe 'boolean values' do + let(:obj) { Petstore::Cat.new({declawed: false}) } + + it 'should have values set' do + obj.declawed.should_not eq nil + obj.declawed.should eq false + end + end + describe 'array and map properties' do let(:obj) { ArrayMapObject.new } From dab2b13df1e2312f180bcd6b12db7b80386fbb26 Mon Sep 17 00:00:00 2001 From: Neil O'Toole Date: Wed, 27 Apr 2016 01:32:02 +0100 Subject: [PATCH 56/63] issue #2711 adding equals, hashcode etc to model classes --- .../java/io/swagger/codegen/ClientOpts.java | 29 +++ .../java/io/swagger/codegen/CodegenModel.java | 110 ++++++++++- .../io/swagger/codegen/CodegenOperation.java | 153 +++++++++++++++ .../io/swagger/codegen/CodegenParameter.java | 180 ++++++++++++++++++ .../io/swagger/codegen/CodegenProperty.java | 6 + .../io/swagger/codegen/CodegenResponse.java | 67 +++++++ .../io/swagger/codegen/CodegenSecurity.java | 58 ++++++ .../io/swagger/codegen/SupportingFile.java | 23 +++ 8 files changed, 625 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java index 9c4d41f7bfd..1087de5786d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/ClientOpts.java @@ -54,4 +54,33 @@ public class ClientOpts { sb.append("}"); return sb.toString(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ClientOpts that = (ClientOpts) o; + + if (uri != null ? !uri.equals(that.uri) : that.uri != null) + return false; + if (target != null ? !target.equals(that.target) : that.target != null) + return false; + if (auth != null ? !auth.equals(that.auth) : that.auth != null) + return false; + if (properties != null ? !properties.equals(that.properties) : that.properties != null) + return false; + return outputDirectory != null ? outputDirectory.equals(that.outputDirectory) : that.outputDirectory == null; + + } + + @Override + public int hashCode() { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (target != null ? target.hashCode() : 0); + result = 31 * result + (auth != null ? auth.hashCode() : 0); + result = 31 * result + (properties != null ? properties.hashCode() : 0); + result = 31 * result + (outputDirectory != null ? outputDirectory.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index 62f5e27aa05..945388b2588 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -1,7 +1,6 @@ package io.swagger.codegen; import io.swagger.models.ExternalDocs; - import java.util.*; public class CodegenModel { @@ -39,4 +38,113 @@ public class CodegenModel { allVars = vars; allMandatory = mandatory; } + + @Override + public String toString() { + return String.format("%s(%s)", name, classname); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CodegenModel that = (CodegenModel) o; + + if (parent != null ? !parent.equals(that.parent) : that.parent != null) + return false; + if (parentSchema != null ? !parentSchema.equals(that.parentSchema) : that.parentSchema != null) + return false; + if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null) + return false; + if (parentModel != null ? !parentModel.equals(that.parentModel) : that.parentModel != null) + return false; + if (interfaceModels != null ? !interfaceModels.equals(that.interfaceModels) : that.interfaceModels != null) + return false; + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + if (classname != null ? !classname.equals(that.classname) : that.classname != null) + return false; + if (description != null ? !description.equals(that.description) : that.description != null) + return false; + if (classVarName != null ? !classVarName.equals(that.classVarName) : that.classVarName != null) + return false; + if (modelJson != null ? !modelJson.equals(that.modelJson) : that.modelJson != null) + return false; + if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) + return false; + if (classFilename != null ? !classFilename.equals(that.classFilename) : that.classFilename != null) + return false; + if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null) + return false; + if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null) + return false; + if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null) + return false; + if (vars != null ? !vars.equals(that.vars) : that.vars != null) + return false; + if (requiredVars != null ? !requiredVars.equals(that.requiredVars) : that.requiredVars != null) + return false; + if (optionalVars != null ? !optionalVars.equals(that.optionalVars) : that.optionalVars != null) + return false; + if (allVars != null ? !allVars.equals(that.allVars) : that.allVars != null) + return false; + if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null) + return false; + if (mandatory != null ? !mandatory.equals(that.mandatory) : that.mandatory != null) + return false; + if (allMandatory != null ? !allMandatory.equals(that.allMandatory) : that.allMandatory != null) + return false; + if (imports != null ? !imports.equals(that.imports) : that.imports != null) + return false; + if (hasVars != null ? !hasVars.equals(that.hasVars) : that.hasVars != null) + return false; + if (emptyVars != null ? !emptyVars.equals(that.emptyVars) : that.emptyVars != null) + return false; + if (hasMoreModels != null ? !hasMoreModels.equals(that.hasMoreModels) : that.hasMoreModels != null) + return false; + if (hasEnums != null ? !hasEnums.equals(that.hasEnums) : that.hasEnums != null) + return false; + if (isEnum != null ? !isEnum.equals(that.isEnum) : that.isEnum != null) + return false; + if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null) + return false; + return vendorExtensions != null ? vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions == null; + + } + + @Override + public int hashCode() { + int result = parent != null ? parent.hashCode() : 0; + result = 31 * result + (parentSchema != null ? parentSchema.hashCode() : 0); + result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0); + result = 31 * result + (parentModel != null ? parentModel.hashCode() : 0); + result = 31 * result + (interfaceModels != null ? interfaceModels.hashCode() : 0); + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (classname != null ? classname.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (classVarName != null ? classVarName.hashCode() : 0); + result = 31 * result + (modelJson != null ? modelJson.hashCode() : 0); + result = 31 * result + (dataType != null ? dataType.hashCode() : 0); + result = 31 * result + (classFilename != null ? classFilename.hashCode() : 0); + result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0); + result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0); + result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); + result = 31 * result + (vars != null ? vars.hashCode() : 0); + result = 31 * result + (requiredVars != null ? requiredVars.hashCode() : 0); + result = 31 * result + (optionalVars != null ? optionalVars.hashCode() : 0); + result = 31 * result + (allVars != null ? allVars.hashCode() : 0); + result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0); + result = 31 * result + (mandatory != null ? mandatory.hashCode() : 0); + result = 31 * result + (allMandatory != null ? allMandatory.hashCode() : 0); + result = 31 * result + (imports != null ? imports.hashCode() : 0); + result = 31 * result + (hasVars != null ? hasVars.hashCode() : 0); + result = 31 * result + (emptyVars != null ? emptyVars.hashCode() : 0); + result = 31 * result + (hasMoreModels != null ? hasMoreModels.hashCode() : 0); + result = 31 * result + (hasEnums != null ? hasEnums.hashCode() : 0); + result = 31 * result + (isEnum != null ? isEnum.hashCode() : 0); + result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0); + result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index 2485e657de2..48858a0d504 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -88,4 +88,157 @@ public class CodegenOperation { return nonempty(formParams); } + @Override + public String toString() { + return String.format("%s(%s)", baseName, path); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CodegenOperation that = (CodegenOperation) o; + + if (responseHeaders != null ? !responseHeaders.equals(that.responseHeaders) : that.responseHeaders != null) + return false; + if (hasAuthMethods != null ? !hasAuthMethods.equals(that.hasAuthMethods) : that.hasAuthMethods != null) + return false; + if (hasConsumes != null ? !hasConsumes.equals(that.hasConsumes) : that.hasConsumes != null) + return false; + if (hasProduces != null ? !hasProduces.equals(that.hasProduces) : that.hasProduces != null) + return false; + if (hasParams != null ? !hasParams.equals(that.hasParams) : that.hasParams != null) + return false; + if (hasOptionalParams != null ? !hasOptionalParams.equals(that.hasOptionalParams) : that.hasOptionalParams != null) + return false; + if (returnTypeIsPrimitive != null ? !returnTypeIsPrimitive.equals(that.returnTypeIsPrimitive) : that.returnTypeIsPrimitive != null) + return false; + if (returnSimpleType != null ? !returnSimpleType.equals(that.returnSimpleType) : that.returnSimpleType != null) + return false; + if (subresourceOperation != null ? !subresourceOperation.equals(that.subresourceOperation) : that.subresourceOperation != null) + return false; + if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null) + return false; + if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null) + return false; + if (isMultipart != null ? !isMultipart.equals(that.isMultipart) : that.isMultipart != null) + return false; + if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null) + return false; + if (isResponseBinary != null ? !isResponseBinary.equals(that.isResponseBinary) : that.isResponseBinary != null) + return false; + if (hasReference != null ? !hasReference.equals(that.hasReference) : that.hasReference != null) + return false; + if (path != null ? !path.equals(that.path) : that.path != null) + return false; + if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null) + return false; + if (returnType != null ? !returnType.equals(that.returnType) : that.returnType != null) + return false; + if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null) + return false; + if (returnBaseType != null ? !returnBaseType.equals(that.returnBaseType) : that.returnBaseType != null) + return false; + if (returnContainer != null ? !returnContainer.equals(that.returnContainer) : that.returnContainer != null) + return false; + if (summary != null ? !summary.equals(that.summary) : that.summary != null) + return false; + if (unescapedNotes != null ? !unescapedNotes.equals(that.unescapedNotes) : that.unescapedNotes != null) + return false; + if (notes != null ? !notes.equals(that.notes) : that.notes != null) + return false; + if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null) + return false; + if (defaultResponse != null ? !defaultResponse.equals(that.defaultResponse) : that.defaultResponse != null) + return false; + if (discriminator != null ? !discriminator.equals(that.discriminator) : that.discriminator != null) + return false; + if (consumes != null ? !consumes.equals(that.consumes) : that.consumes != null) + return false; + if (produces != null ? !produces.equals(that.produces) : that.produces != null) + return false; + if (bodyParam != null ? !bodyParam.equals(that.bodyParam) : that.bodyParam != null) + return false; + if (allParams != null ? !allParams.equals(that.allParams) : that.allParams != null) + return false; + if (bodyParams != null ? !bodyParams.equals(that.bodyParams) : that.bodyParams != null) + return false; + if (pathParams != null ? !pathParams.equals(that.pathParams) : that.pathParams != null) + return false; + if (queryParams != null ? !queryParams.equals(that.queryParams) : that.queryParams != null) + return false; + if (headerParams != null ? !headerParams.equals(that.headerParams) : that.headerParams != null) + return false; + if (formParams != null ? !formParams.equals(that.formParams) : that.formParams != null) + return false; + if (authMethods != null ? !authMethods.equals(that.authMethods) : that.authMethods != null) + return false; + if (tags != null ? !tags.equals(that.tags) : that.tags != null) + return false; + if (responses != null ? !responses.equals(that.responses) : that.responses != null) + return false; + if (imports != null ? !imports.equals(that.imports) : that.imports != null) + return false; + if (examples != null ? !examples.equals(that.examples) : that.examples != null) + return false; + if (externalDocs != null ? !externalDocs.equals(that.externalDocs) : that.externalDocs != null) + return false; + if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null) + return false; + if (nickname != null ? !nickname.equals(that.nickname) : that.nickname != null) + return false; + return operationIdLowerCase != null ? operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase == null; + + } + + @Override + public int hashCode() { + int result = responseHeaders != null ? responseHeaders.hashCode() : 0; + result = 31 * result + (hasAuthMethods != null ? hasAuthMethods.hashCode() : 0); + result = 31 * result + (hasConsumes != null ? hasConsumes.hashCode() : 0); + result = 31 * result + (hasProduces != null ? hasProduces.hashCode() : 0); + result = 31 * result + (hasParams != null ? hasParams.hashCode() : 0); + result = 31 * result + (hasOptionalParams != null ? hasOptionalParams.hashCode() : 0); + result = 31 * result + (returnTypeIsPrimitive != null ? returnTypeIsPrimitive.hashCode() : 0); + result = 31 * result + (returnSimpleType != null ? returnSimpleType.hashCode() : 0); + result = 31 * result + (subresourceOperation != null ? subresourceOperation.hashCode() : 0); + result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0); + result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0); + result = 31 * result + (isMultipart != null ? isMultipart.hashCode() : 0); + result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0); + result = 31 * result + (isResponseBinary != null ? isResponseBinary.hashCode() : 0); + result = 31 * result + (hasReference != null ? hasReference.hashCode() : 0); + result = 31 * result + (path != null ? path.hashCode() : 0); + result = 31 * result + (operationId != null ? operationId.hashCode() : 0); + result = 31 * result + (returnType != null ? returnType.hashCode() : 0); + result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0); + result = 31 * result + (returnBaseType != null ? returnBaseType.hashCode() : 0); + result = 31 * result + (returnContainer != null ? returnContainer.hashCode() : 0); + result = 31 * result + (summary != null ? summary.hashCode() : 0); + result = 31 * result + (unescapedNotes != null ? unescapedNotes.hashCode() : 0); + result = 31 * result + (notes != null ? notes.hashCode() : 0); + result = 31 * result + (baseName != null ? baseName.hashCode() : 0); + result = 31 * result + (defaultResponse != null ? defaultResponse.hashCode() : 0); + result = 31 * result + (discriminator != null ? discriminator.hashCode() : 0); + result = 31 * result + (consumes != null ? consumes.hashCode() : 0); + result = 31 * result + (produces != null ? produces.hashCode() : 0); + result = 31 * result + (bodyParam != null ? bodyParam.hashCode() : 0); + result = 31 * result + (allParams != null ? allParams.hashCode() : 0); + result = 31 * result + (bodyParams != null ? bodyParams.hashCode() : 0); + result = 31 * result + (pathParams != null ? pathParams.hashCode() : 0); + result = 31 * result + (queryParams != null ? queryParams.hashCode() : 0); + result = 31 * result + (headerParams != null ? headerParams.hashCode() : 0); + result = 31 * result + (formParams != null ? formParams.hashCode() : 0); + result = 31 * result + (authMethods != null ? authMethods.hashCode() : 0); + result = 31 * result + (tags != null ? tags.hashCode() : 0); + result = 31 * result + (responses != null ? responses.hashCode() : 0); + result = 31 * result + (imports != null ? imports.hashCode() : 0); + result = 31 * result + (examples != null ? examples.hashCode() : 0); + result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0); + result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); + result = 31 * result + (nickname != null ? nickname.hashCode() : 0); + result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java index 3f38d391e70..a69f7197181 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java @@ -137,5 +137,185 @@ public class CodegenParameter { return output; } + + @Override + public String toString() { + return String.format("%s(%s)", baseName, dataType); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CodegenParameter that = (CodegenParameter) o; + + if (isEnum != that.isEnum) return false; + if (isFormParam != null ? !isFormParam.equals(that.isFormParam) : that.isFormParam != null) + return false; + if (isQueryParam != null ? !isQueryParam.equals(that.isQueryParam) : that.isQueryParam != null) + return false; + if (isPathParam != null ? !isPathParam.equals(that.isPathParam) : that.isPathParam != null) + return false; + if (isHeaderParam != null ? !isHeaderParam.equals(that.isHeaderParam) : that.isHeaderParam != null) + return false; + if (isCookieParam != null ? !isCookieParam.equals(that.isCookieParam) : that.isCookieParam != null) + return false; + if (isBodyParam != null ? !isBodyParam.equals(that.isBodyParam) : that.isBodyParam != null) + return false; + if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null) + return false; + if (isContainer != null ? !isContainer.equals(that.isContainer) : that.isContainer != null) + return false; + if (secondaryParam != null ? !secondaryParam.equals(that.secondaryParam) : that.secondaryParam != null) + return false; + if (isCollectionFormatMulti != null ? !isCollectionFormatMulti.equals(that.isCollectionFormatMulti) : that.isCollectionFormatMulti != null) + return false; + if (isPrimitiveType != null ? !isPrimitiveType.equals(that.isPrimitiveType) : that.isPrimitiveType != null) + return false; + if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null) + return false; + if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null) + return false; + if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) + return false; + if (datatypeWithEnum != null ? !datatypeWithEnum.equals(that.datatypeWithEnum) : that.datatypeWithEnum != null) + return false; + if (collectionFormat != null ? !collectionFormat.equals(that.collectionFormat) : that.collectionFormat != null) + return false; + if (description != null ? !description.equals(that.description) : that.description != null) + return false; + if (unescapedDescription != null ? !unescapedDescription.equals(that.unescapedDescription) : that.unescapedDescription != null) + return false; + if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null) + return false; + if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null) + return false; + if (example != null ? !example.equals(that.example) : that.example != null) + return false; + if (jsonSchema != null ? !jsonSchema.equals(that.jsonSchema) : that.jsonSchema != null) + return false; + if (isString != null ? !isString.equals(that.isString) : that.isString != null) + return false; + if (isInteger != null ? !isInteger.equals(that.isInteger) : that.isInteger != null) + return false; + if (isLong != null ? !isLong.equals(that.isLong) : that.isLong != null) + return false; + if (isFloat != null ? !isFloat.equals(that.isFloat) : that.isFloat != null) + return false; + if (isDouble != null ? !isDouble.equals(that.isDouble) : that.isDouble != null) + return false; + if (isByteArray != null ? !isByteArray.equals(that.isByteArray) : that.isByteArray != null) + return false; + if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null) + return false; + if (isBoolean != null ? !isBoolean.equals(that.isBoolean) : that.isBoolean != null) + return false; + if (isDate != null ? !isDate.equals(that.isDate) : that.isDate != null) + return false; + if (isDateTime != null ? !isDateTime.equals(that.isDateTime) : that.isDateTime != null) + return false; + if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null) + return false; + if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null) + return false; + if (isFile != null ? !isFile.equals(that.isFile) : that.isFile != null) + return false; + if (notFile != null ? !notFile.equals(that.notFile) : that.notFile != null) + return false; + if (_enum != null ? !_enum.equals(that._enum) : that._enum != null) + return false; + if (allowableValues != null ? !allowableValues.equals(that.allowableValues) : that.allowableValues != null) + return false; + if (items != null ? !items.equals(that.items) : that.items != null) + return false; + if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null) + return false; + if (hasValidation != null ? !hasValidation.equals(that.hasValidation) : that.hasValidation != null) + return false; + if (required != null ? !required.equals(that.required) : that.required != null) + return false; + if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null) + return false; + if (exclusiveMaximum != null ? !exclusiveMaximum.equals(that.exclusiveMaximum) : that.exclusiveMaximum != null) + return false; + if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null) + return false; + if (exclusiveMinimum != null ? !exclusiveMinimum.equals(that.exclusiveMinimum) : that.exclusiveMinimum != null) + return false; + if (maxLength != null ? !maxLength.equals(that.maxLength) : that.maxLength != null) + return false; + if (minLength != null ? !minLength.equals(that.minLength) : that.minLength != null) + return false; + if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null) + return false; + if (maxItems != null ? !maxItems.equals(that.maxItems) : that.maxItems != null) + return false; + if (minItems != null ? !minItems.equals(that.minItems) : that.minItems != null) + return false; + if (uniqueItems != null ? !uniqueItems.equals(that.uniqueItems) : that.uniqueItems != null) + return false; + return multipleOf != null ? multipleOf.equals(that.multipleOf) : that.multipleOf == null; + + } + + @Override + public int hashCode() { + int result = isFormParam != null ? isFormParam.hashCode() : 0; + result = 31 * result + (isQueryParam != null ? isQueryParam.hashCode() : 0); + result = 31 * result + (isPathParam != null ? isPathParam.hashCode() : 0); + result = 31 * result + (isHeaderParam != null ? isHeaderParam.hashCode() : 0); + result = 31 * result + (isCookieParam != null ? isCookieParam.hashCode() : 0); + result = 31 * result + (isBodyParam != null ? isBodyParam.hashCode() : 0); + result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0); + result = 31 * result + (isContainer != null ? isContainer.hashCode() : 0); + result = 31 * result + (secondaryParam != null ? secondaryParam.hashCode() : 0); + result = 31 * result + (isCollectionFormatMulti != null ? isCollectionFormatMulti.hashCode() : 0); + result = 31 * result + (isPrimitiveType != null ? isPrimitiveType.hashCode() : 0); + result = 31 * result + (baseName != null ? baseName.hashCode() : 0); + result = 31 * result + (paramName != null ? paramName.hashCode() : 0); + result = 31 * result + (dataType != null ? dataType.hashCode() : 0); + result = 31 * result + (datatypeWithEnum != null ? datatypeWithEnum.hashCode() : 0); + result = 31 * result + (collectionFormat != null ? collectionFormat.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (unescapedDescription != null ? unescapedDescription.hashCode() : 0); + result = 31 * result + (baseType != null ? baseType.hashCode() : 0); + result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); + result = 31 * result + (example != null ? example.hashCode() : 0); + result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0); + result = 31 * result + (isString != null ? isString.hashCode() : 0); + result = 31 * result + (isInteger != null ? isInteger.hashCode() : 0); + result = 31 * result + (isLong != null ? isLong.hashCode() : 0); + result = 31 * result + (isFloat != null ? isFloat.hashCode() : 0); + result = 31 * result + (isDouble != null ? isDouble.hashCode() : 0); + result = 31 * result + (isByteArray != null ? isByteArray.hashCode() : 0); + result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0); + result = 31 * result + (isBoolean != null ? isBoolean.hashCode() : 0); + result = 31 * result + (isDate != null ? isDate.hashCode() : 0); + result = 31 * result + (isDateTime != null ? isDateTime.hashCode() : 0); + result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0); + result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0); + result = 31 * result + (isFile != null ? isFile.hashCode() : 0); + result = 31 * result + (notFile != null ? notFile.hashCode() : 0); + result = 31 * result + (isEnum ? 1 : 0); + result = 31 * result + (_enum != null ? _enum.hashCode() : 0); + result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0); + result = 31 * result + (items != null ? items.hashCode() : 0); + result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); + result = 31 * result + (hasValidation != null ? hasValidation.hashCode() : 0); + result = 31 * result + (required != null ? required.hashCode() : 0); + result = 31 * result + (maximum != null ? maximum.hashCode() : 0); + result = 31 * result + (exclusiveMaximum != null ? exclusiveMaximum.hashCode() : 0); + result = 31 * result + (minimum != null ? minimum.hashCode() : 0); + result = 31 * result + (exclusiveMinimum != null ? exclusiveMinimum.hashCode() : 0); + result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0); + result = 31 * result + (minLength != null ? minLength.hashCode() : 0); + result = 31 * result + (pattern != null ? pattern.hashCode() : 0); + result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0); + result = 31 * result + (minItems != null ? minItems.hashCode() : 0); + result = 31 * result + (uniqueItems != null ? uniqueItems.hashCode() : 0); + result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 79b7c60a9eb..d58a1a81b1d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -44,6 +44,12 @@ public class CodegenProperty { public Map vendorExtensions; public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template) + @Override + public String toString() { + return String.format("%s(%s)", baseName, datatype); + } + + @Override public int hashCode() { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java index e20735b1418..746f65cea38 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java @@ -22,4 +22,71 @@ public class CodegenResponse { public boolean isWildcard() { return "0".equals(code) || "default".equals(code); } + + @Override + public String toString() { + return String.format("%s(%s)", code, containerType); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CodegenResponse that = (CodegenResponse) o; + + if (headers != null ? !headers.equals(that.headers) : that.headers != null) + return false; + if (code != null ? !code.equals(that.code) : that.code != null) + return false; + if (message != null ? !message.equals(that.message) : that.message != null) + return false; + if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null) + return false; + if (examples != null ? !examples.equals(that.examples) : that.examples != null) + return false; + if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) + return false; + if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null) + return false; + if (containerType != null ? !containerType.equals(that.containerType) : that.containerType != null) + return false; + if (isDefault != null ? !isDefault.equals(that.isDefault) : that.isDefault != null) + return false; + if (simpleType != null ? !simpleType.equals(that.simpleType) : that.simpleType != null) + return false; + if (primitiveType != null ? !primitiveType.equals(that.primitiveType) : that.primitiveType != null) + return false; + if (isMapContainer != null ? !isMapContainer.equals(that.isMapContainer) : that.isMapContainer != null) + return false; + if (isListContainer != null ? !isListContainer.equals(that.isListContainer) : that.isListContainer != null) + return false; + if (isBinary != null ? !isBinary.equals(that.isBinary) : that.isBinary != null) + return false; + if (schema != null ? !schema.equals(that.schema) : that.schema != null) + return false; + return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null; + + } + + @Override + public int hashCode() { + int result = headers != null ? headers.hashCode() : 0; + result = 31 * result + (code != null ? code.hashCode() : 0); + result = 31 * result + (message != null ? message.hashCode() : 0); + result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0); + result = 31 * result + (examples != null ? examples.hashCode() : 0); + result = 31 * result + (dataType != null ? dataType.hashCode() : 0); + result = 31 * result + (baseType != null ? baseType.hashCode() : 0); + result = 31 * result + (containerType != null ? containerType.hashCode() : 0); + result = 31 * result + (isDefault != null ? isDefault.hashCode() : 0); + result = 31 * result + (simpleType != null ? simpleType.hashCode() : 0); + result = 31 * result + (primitiveType != null ? primitiveType.hashCode() : 0); + result = 31 * result + (isMapContainer != null ? isMapContainer.hashCode() : 0); + result = 31 * result + (isListContainer != null ? isListContainer.hashCode() : 0); + result = 31 * result + (isBinary != null ? isBinary.hashCode() : 0); + result = 31 * result + (schema != null ? schema.hashCode() : 0); + result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java index 10118206383..2e33242c370 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenSecurity.java @@ -13,4 +13,62 @@ public class CodegenSecurity { // Oauth specific public String flow, authorizationUrl, tokenUrl; public List> scopes; + + @Override + public String toString() { + return String.format("%s(%s)", name, type); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + CodegenSecurity that = (CodegenSecurity) o; + + if (name != null ? !name.equals(that.name) : that.name != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + if (hasMore != null ? !hasMore.equals(that.hasMore) : that.hasMore != null) + return false; + if (isBasic != null ? !isBasic.equals(that.isBasic) : that.isBasic != null) + return false; + if (isOAuth != null ? !isOAuth.equals(that.isOAuth) : that.isOAuth != null) + return false; + if (isApiKey != null ? !isApiKey.equals(that.isApiKey) : that.isApiKey != null) + return false; + if (keyParamName != null ? !keyParamName.equals(that.keyParamName) : that.keyParamName != null) + return false; + if (isKeyInQuery != null ? !isKeyInQuery.equals(that.isKeyInQuery) : that.isKeyInQuery != null) + return false; + if (isKeyInHeader != null ? !isKeyInHeader.equals(that.isKeyInHeader) : that.isKeyInHeader != null) + return false; + if (flow != null ? !flow.equals(that.flow) : that.flow != null) + return false; + if (authorizationUrl != null ? !authorizationUrl.equals(that.authorizationUrl) : that.authorizationUrl != null) + return false; + if (tokenUrl != null ? !tokenUrl.equals(that.tokenUrl) : that.tokenUrl != null) + return false; + return scopes != null ? scopes.equals(that.scopes) : that.scopes == null; + + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (hasMore != null ? hasMore.hashCode() : 0); + result = 31 * result + (isBasic != null ? isBasic.hashCode() : 0); + result = 31 * result + (isOAuth != null ? isOAuth.hashCode() : 0); + result = 31 * result + (isApiKey != null ? isApiKey.hashCode() : 0); + result = 31 * result + (keyParamName != null ? keyParamName.hashCode() : 0); + result = 31 * result + (isKeyInQuery != null ? isKeyInQuery.hashCode() : 0); + result = 31 * result + (isKeyInHeader != null ? isKeyInHeader.hashCode() : 0); + result = 31 * result + (flow != null ? flow.hashCode() : 0); + result = 31 * result + (authorizationUrl != null ? authorizationUrl.hashCode() : 0); + result = 31 * result + (tokenUrl != null ? tokenUrl.hashCode() : 0); + result = 31 * result + (scopes != null ? scopes.hashCode() : 0); + return result; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java index 976376bae68..e5fb6a27da6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/SupportingFile.java @@ -21,4 +21,27 @@ public class SupportingFile { return builder.toString(); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SupportingFile that = (SupportingFile) o; + + if (templateFile != null ? !templateFile.equals(that.templateFile) : that.templateFile != null) + return false; + if (folder != null ? !folder.equals(that.folder) : that.folder != null) + return false; + return destinationFilename != null ? destinationFilename.equals(that.destinationFilename) : that.destinationFilename == null; + + } + + @Override + public int hashCode() { + int result = templateFile != null ? templateFile.hashCode() : 0; + result = 31 * result + (folder != null ? folder.hashCode() : 0); + result = 31 * result + (destinationFilename != null ? destinationFilename.hashCode() : 0); + return result; + } } \ No newline at end of file From 21b39e24afd56fabec4591ee7e574d9f3de4a8f9 Mon Sep 17 00:00:00 2001 From: Silvio Heuberger Date: Wed, 27 Apr 2016 10:01:20 +0200 Subject: [PATCH 57/63] Update libraries to the newest stable version --- .../resources/Java/libraries/retrofit2/build.gradle.mustache | 4 ++-- .../src/main/resources/Java/libraries/retrofit2/pom.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 3f07e9df177..e56e682cfcd 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -94,8 +94,8 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" - retrofit_version = "2.0.1" + oltu_version = "1.0.1" + retrofit_version = "2.0.2" swagger_annotations_version = "1.5.8" junit_version = "4.12" {{#useRxJava}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index e33d026aaf5..30f6a71d285 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -153,9 +153,9 @@ 1.5.8 - 2.0.1 + 2.0.2 {{#useRxJava}}1.1.3{{/useRxJava}} - 3.0.1 + 3.2.0 1.0.1 1.0.0 4.12 From 39c08b2cfc38312fccb8c4f7ebca21fc5c015acc Mon Sep 17 00:00:00 2001 From: Silvio Heuberger Date: Wed, 27 Apr 2016 10:03:45 +0200 Subject: [PATCH 58/63] Regenrate samples after updating the libraries in pom and build.gradle mustache --- .../petstore/java/retrofit2/build.gradle | 3 +- .../client/petstore/java/retrofit2/hello.txt | 1 - .../client/petstore/java/retrofit2/pom.xml | 17 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/FakeApi.java | 43 +++ .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/model/FormatTest.java | 16 +- .../src/test/java/io/swagger/TestUtils.java | 17 -- .../io/swagger/petstore/test/PetApiTest.java | 190 ------------- .../swagger/petstore/test/StoreApiTest.java | 74 ----- .../io/swagger/petstore/test/UserApiTest.java | 86 ------ .../petstore/java/retrofit2rx/build.gradle | 9 +- .../client/petstore/java/retrofit2rx/pom.xml | 24 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/FakeApi.java | 43 +++ .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/model/FormatTest.java | 16 +- .../io/swagger/petstore/test/PetApiTest.java | 255 ------------------ .../petstore/test/SkeletonSubscriber.java | 30 --- .../swagger/petstore/test/StoreApiTest.java | 96 ------- .../io/swagger/petstore/test/UserApiTest.java | 108 -------- 21 files changed, 142 insertions(+), 894 deletions(-) delete mode 100644 samples/client/petstore/java/retrofit2/hello.txt create mode 100644 samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java delete mode 100644 samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java delete mode 100644 samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java delete mode 100644 samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java delete mode 100644 samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java create mode 100644 samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java diff --git a/samples/client/petstore/java/retrofit2/build.gradle b/samples/client/petstore/java/retrofit2/build.gradle index fb29db0475c..6b96656a4a8 100644 --- a/samples/client/petstore/java/retrofit2/build.gradle +++ b/samples/client/petstore/java/retrofit2/build.gradle @@ -95,8 +95,7 @@ if(hasProperty('target') && target == 'android') { ext { oltu_version = "1.0.1" - retrofit_version = "2.0.0-beta4" - gson_version = "2.6.2" + retrofit_version = "2.0.2" swagger_annotations_version = "1.5.8" junit_version = "4.12" diff --git a/samples/client/petstore/java/retrofit2/hello.txt b/samples/client/petstore/java/retrofit2/hello.txt deleted file mode 100644 index 6769dd60bdf..00000000000 --- a/samples/client/petstore/java/retrofit2/hello.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2/pom.xml b/samples/client/petstore/java/retrofit2/pom.xml index c9ec80dacf4..05774ac3834 100644 --- a/samples/client/petstore/java/retrofit2/pom.xml +++ b/samples/client/petstore/java/retrofit2/pom.xml @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 @@ -113,6 +112,11 @@ swagger-annotations ${swagger-core-version} + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} + com.squareup.retrofit2 retrofit @@ -123,11 +127,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -144,7 +143,9 @@ 1.5.8 - 2.0.0-beta4 + 2.0.2 + + 3.2.0 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java index c56ed86683a..f5e5cea4151 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:08:50.551+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:24.454+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 00000000000..dc732e67ae7 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,43 @@ +package io.swagger.client.api; + +import io.swagger.client.CollectionFormats.*; + + +import retrofit2.Call; +import retrofit2.http.*; + +import okhttp3.RequestBody; + +import java.util.Date; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface FakeApi { + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param number None (required) + * @param _double None (required) + * @param string None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @return Call + */ + + @FormUrlEncoded + @POST("fake") + Call testEndpointParameters( + @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + ); + +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index dd39a864f06..ec9d67a7449 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import java.io.File; import io.swagger.client.model.ModelApiResponse; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java index 29d17bbdfe7..40d1ca0ecea 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/FormatTest.java @@ -51,6 +51,8 @@ public class FormatTest { private String password = null; /** + * minimum: 10.0 + * maximum: 100.0 **/ @ApiModelProperty(value = "") public Integer getInteger() { @@ -61,6 +63,8 @@ public class FormatTest { } /** + * minimum: 20.0 + * maximum: 200.0 **/ @ApiModelProperty(value = "") public Integer getInt32() { @@ -81,6 +85,8 @@ public class FormatTest { } /** + * minimum: 32.1 + * maximum: 543.2 **/ @ApiModelProperty(required = true, value = "") public BigDecimal getNumber() { @@ -91,6 +97,8 @@ public class FormatTest { } /** + * minimum: 54.3 + * maximum: 987.6 **/ @ApiModelProperty(value = "") public Float getFloat() { @@ -101,6 +109,8 @@ public class FormatTest { } /** + * minimum: 67.8 + * maximum: 123.4 **/ @ApiModelProperty(value = "") public Double getDouble() { @@ -122,7 +132,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public byte[] getByte() { return _byte; } @@ -142,7 +152,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public Date getDate() { return date; } @@ -162,7 +172,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public String getPassword() { return password; } diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java deleted file mode 100644 index 7ddf142426e..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/TestUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.swagger; - -import java.util.Random; -import java.util.concurrent.atomic.AtomicLong; - -public class TestUtils { - private static final AtomicLong atomicId = createAtomicId(); - - public static long nextId() { - return atomicId.getAndIncrement(); - } - - private static AtomicLong createAtomicId() { - int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000; - return new AtomicLong((long) baseId); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java deleted file mode 100644 index ac8abefb216..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.*; - -import retrofit2.Response; - -import okhttp3.MediaType; -import okhttp3.RequestBody; - -import static org.junit.Assert.*; - -public class PetApiTest { - PetApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(PetApi.class); - } - - @Test - public void testCreateAndGetPet() throws Exception { - Pet pet = createRandomPet(); - Response rp2 = api.addPet(pet).execute(); - - Response rp = api.getPetById(pet.getId()).execute(); - Pet fetched = rp.body(); - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - - @Test - public void testUpdatePet() throws Exception { - Pet pet = createRandomPet(); - pet.setName("programmer"); - - api.updatePet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - - @Test - public void testFindPetsByStatus() throws Exception { - Pet pet = createRandomPet(); - pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - api.updatePet(pet).execute(); - - List pets = api.findPetsByStatus(new CSVParams("available")).execute().body(); - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - - assertTrue(found); - } - - @Test - public void testFindPetsByTags() throws Exception { - Pet pet = createRandomPet(); - pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - List tags = new ArrayList(); - Tag tag1 = new Tag(); - tag1.setName("friendly"); - tags.add(tag1); - pet.setTags(tags); - - api.updatePet(pet).execute(); - - List pets = api.findPetsByTags(new CSVParams("friendly")).execute().body(); - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - assertTrue(found); - } - - @Test - public void testUpdatePetWithForm() throws Exception { - Pet pet = createRandomPet(); - pet.setName("frank"); - api.addPet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - - api.updatePetWithForm(fetched.getId(), "furt", null).execute(); - Pet updated = api.getPetById(fetched.getId()).execute().body(); - - assertEquals(updated.getName(), "furt"); - } - - @Test - public void testDeletePet() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).execute(); - - Pet fetched = api.getPetById(pet.getId()).execute().body(); - api.deletePet(fetched.getId(), null).execute(); - - assertFalse(api.getPetById(fetched.getId()).execute().isSuccess()); - } - - @Test - public void testUploadFile() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).execute(); - - File file = new File("hello.txt"); - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - writer.write("Hello world!"); - writer.close(); - - api.uploadFile(pet.getId(), null, RequestBody.create(MediaType.parse("text/plain"), file)).execute(); - } - - @Test - public void testEqualsAndHashCode() { - Pet pet1 = new Pet(); - Pet pet2 = new Pet(); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - - pet2.setName("really-happy"); - pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertFalse(pet1.equals(pet2)); - assertFalse(pet2.equals(pet1)); - assertFalse(pet1.hashCode() == (pet2.hashCode())); - assertTrue(pet2.equals(pet2)); - assertTrue(pet2.hashCode() == pet2.hashCode()); - - pet1.setName("really-happy"); - pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - } - - private Pet createRandomPet() { - Pet pet = new Pet(); - pet.setId(TestUtils.nextId()); - pet.setName("gorilla"); - - Category category = new Category(); - category.setName("really-happy"); - - pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); - pet.setPhotoUrls(photos); - - return pet; - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java deleted file mode 100644 index 249d5dc4828..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.junit.*; - -import retrofit2.Response; -import static org.junit.Assert.*; - -public class StoreApiTest { - StoreApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(StoreApi.class); - } - - @Test - public void testGetInventory() throws Exception { - Map inventory = api.getInventory().execute().body(); - assertTrue(inventory.keySet().size() > 0); - } - - @Test - public void testPlaceOrder() throws Exception { - Order order = createOrder(); - api.placeOrder(order).execute(); - - Order fetched = api.getOrderById(order.getId()).execute().body(); - assertEquals(order.getId(), fetched.getId()); - assertEquals(order.getPetId(), fetched.getPetId()); - assertEquals(order.getQuantity(), fetched.getQuantity()); - } - - @Test - public void testDeleteOrder() throws Exception { - Order order = createOrder(); - Response aa = api.placeOrder(order).execute(); - - Order fetched = api.getOrderById(order.getId()).execute().body(); - assertEquals(fetched.getId(), order.getId()); - - api.deleteOrder(String.valueOf(order.getId())).execute(); - - api.getOrderById(order.getId()).execute(); - //also in retrofit 1 should return an error but don't, check server api impl. - } - - private Order createOrder() { - Order order = new Order(); - order.setPetId(new Long(200)); - order.setQuantity(new Integer(13)); - order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.PLACED); - order.setComplete(true); - - try { - Field idField = Order.class.getDeclaredField("id"); - idField.setAccessible(true); - idField.set(order, TestUtils.nextId()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return order; - } -} diff --git a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java deleted file mode 100644 index 6c35c94383a..00000000000 --- a/samples/client/petstore/java/retrofit2/src/test/java/io/swagger/petstore/test/UserApiTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.TestUtils; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - - -import java.util.Arrays; - -import org.junit.*; -import static org.junit.Assert.*; - -public class UserApiTest { - UserApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(UserApi.class); - } - - @Test - public void testCreateUser() throws Exception { - User user = createUser(); - - api.createUser(user).execute(); - - User fetched = api.getUserByName(user.getUsername()).execute().body(); - assertEquals(user.getId(), fetched.getId()); - } - - @Test - public void testCreateUsersWithArray() throws Exception { - User user1 = createUser(); - user1.setUsername("user" + user1.getId()); - User user2 = createUser(); - user2.setUsername("user" + user2.getId()); - - api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})).execute(); - - User fetched = api.getUserByName(user1.getUsername()).execute().body(); - assertEquals(user1.getId(), fetched.getId()); - } - - @Test - public void testCreateUsersWithList() throws Exception { - User user1 = createUser(); - user1.setUsername("user" + user1.getId()); - User user2 = createUser(); - user2.setUsername("user" + user2.getId()); - - api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})).execute(); - - User fetched = api.getUserByName(user1.getUsername()).execute().body(); - assertEquals(user1.getId(), fetched.getId()); - } - - @Test - public void testLoginUser() throws Exception { - User user = createUser(); - api.createUser(user).execute(); - - String token = api.loginUser(user.getUsername(), user.getPassword()).execute().body(); - assertTrue(token.startsWith("logged in user session:")); - } - - @Test - public void logoutUser() throws Exception { - api.logoutUser().execute(); - } - - private User createUser() { - User user = new User(); - user.setId(TestUtils.nextId()); - user.setUsername("fred"); - user.setFirstName("Fred"); - user.setLastName("Meyer"); - user.setEmail("fred@fredmeyer.com"); - user.setPassword("xxXXxx"); - user.setPhone("408-867-5309"); - user.setUserStatus(123); - - return user; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/build.gradle b/samples/client/petstore/java/retrofit2rx/build.gradle index 123bae25560..cbd0119e24b 100644 --- a/samples/client/petstore/java/retrofit2rx/build.gradle +++ b/samples/client/petstore/java/retrofit2rx/build.gradle @@ -94,12 +94,11 @@ if(hasProperty('target') && target == 'android') { } ext { - oltu_version = "1.0.0" - retrofit_version = "2.0.0-beta4" - gson_version = "2.4" - swagger_annotations_version = "1.5.0" + oltu_version = "1.0.1" + retrofit_version = "2.0.2" + swagger_annotations_version = "1.5.8" junit_version = "4.12" - rx_java_version = "1.0.16" + rx_java_version = "1.1.3" } diff --git a/samples/client/petstore/java/retrofit2rx/pom.xml b/samples/client/petstore/java/retrofit2rx/pom.xml index b2cf9949578..79d826c3a41 100644 --- a/samples/client/petstore/java/retrofit2rx/pom.xml +++ b/samples/client/petstore/java/retrofit2rx/pom.xml @@ -100,8 +100,7 @@ maven-compiler-plugin 2.3.2 - - 1.7 + 1.7 1.7 @@ -111,7 +110,12 @@ io.swagger swagger-annotations - ${swagger-annotations-version} + ${swagger-core-version} + + + com.squareup.retrofit2 + converter-gson + ${retrofit-version} com.squareup.retrofit2 @@ -123,11 +127,6 @@ converter-scalars ${retrofit-version} - - com.squareup.retrofit2 - converter-gson - ${retrofit-version} - org.apache.oltu.oauth2 org.apache.oltu.oauth2.client @@ -153,10 +152,11 @@ - 1.5.0 - 2.0.0-beta4 - 1.0.16 - 1.0.0 + 1.5.8 + 2.0.2 + 1.1.3 + 3.2.0 + 1.0.1 1.0.0 4.12 diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java index 9b9c01b35b2..cee81411e96 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-22T23:10:58.658+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-27T10:03:29.641+02:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java new file mode 100644 index 00000000000..beaa9833892 --- /dev/null +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java @@ -0,0 +1,43 @@ +package io.swagger.client.api; + +import io.swagger.client.CollectionFormats.*; + +import rx.Observable; + +import retrofit2.http.*; + +import okhttp3.RequestBody; + +import java.util.Date; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface FakeApi { + /** + * Fake endpoint for testing various parameters + * Fake endpoint for testing various parameters + * @param number None (required) + * @param _double None (required) + * @param string None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @return Call + */ + + @FormUrlEncoded + @POST("fake") + Observable testEndpointParameters( + @Field("number") String number, @Field("double") Double _double, @Field("string") String string, @Field("byte") byte[] _byte, @Field("integer") Integer integer, @Field("int32") Integer int32, @Field("int64") Long int64, @Field("float") Float _float, @Field("binary") byte[] binary, @Field("date") Date date, @Field("dateTime") Date dateTime, @Field("password") String password + ); + +} diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 304ea7a29a8..4a2e64b726e 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import retrofit2.http.*; import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import java.io.File; import io.swagger.client.model.ModelApiResponse; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java index 29d17bbdfe7..40d1ca0ecea 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/FormatTest.java @@ -51,6 +51,8 @@ public class FormatTest { private String password = null; /** + * minimum: 10.0 + * maximum: 100.0 **/ @ApiModelProperty(value = "") public Integer getInteger() { @@ -61,6 +63,8 @@ public class FormatTest { } /** + * minimum: 20.0 + * maximum: 200.0 **/ @ApiModelProperty(value = "") public Integer getInt32() { @@ -81,6 +85,8 @@ public class FormatTest { } /** + * minimum: 32.1 + * maximum: 543.2 **/ @ApiModelProperty(required = true, value = "") public BigDecimal getNumber() { @@ -91,6 +97,8 @@ public class FormatTest { } /** + * minimum: 54.3 + * maximum: 987.6 **/ @ApiModelProperty(value = "") public Float getFloat() { @@ -101,6 +109,8 @@ public class FormatTest { } /** + * minimum: 67.8 + * maximum: 123.4 **/ @ApiModelProperty(value = "") public Double getDouble() { @@ -122,7 +132,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public byte[] getByte() { return _byte; } @@ -142,7 +152,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public Date getDate() { return date; } @@ -162,7 +172,7 @@ public class FormatTest { /** **/ - @ApiModelProperty(value = "") + @ApiModelProperty(required = true, value = "") public String getPassword() { return password; } diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java deleted file mode 100644 index e506ec00e9a..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ /dev/null @@ -1,255 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.CollectionFormats.*; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.*; - -import okhttp3.MediaType; -import okhttp3.RequestBody; - -import static org.junit.Assert.*; - -public class PetApiTest { - PetApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(PetApi.class); - } - - @Test - public void testCreateAndGetPet() throws Exception { - final Pet pet = createRandomPet(); - api.addPet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - }); - - } - }); - - } - - @Test - public void testUpdatePet() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("programmer"); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - assertNotNull(fetched); - assertEquals(pet.getId(), fetched.getId()); - assertNotNull(fetched.getCategory()); - assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); - } - }); - - } - }); - - } - - @Test - public void testFindPetsByStatus() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.findPetsByStatus(new CSVParams("available")).subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(List pets) { - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - - assertTrue(found); - } - }); - - } - }); - - } - - @Test - public void testFindPetsByTags() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("monster"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - - List tags = new ArrayList(); - Tag tag1 = new Tag(); - tag1.setName("friendly"); - tags.add(tag1); - pet.setTags(tags); - - api.updatePet(pet).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.findPetsByTags(new CSVParams("friendly")).subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(List pets) { - assertNotNull(pets); - - boolean found = false; - for (Pet fetched : pets) { - if (fetched.getId().equals(pet.getId())) { - found = true; - break; - } - } - assertTrue(found); - } - }); - - } - }); - - } - - @Test - public void testUpdatePetWithForm() throws Exception { - final Pet pet = createRandomPet(); - pet.setName("frank"); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(final Pet fetched) { - api.updatePetWithForm(fetched.getId(), "furt", null) - .subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet updated) { - assertEquals(updated.getName(), "furt"); - } - }); - - } - }); - } - }); - - - } - - @Test - public void testDeletePet() throws Exception { - Pet pet = createRandomPet(); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getPetById(pet.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet fetched) { - - api.deletePet(fetched.getId(), null).subscribe(SkeletonSubscriber.failTestOnError()); - api.getPetById(fetched.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Pet deletedPet) { - fail("Should not have found deleted pet."); - } - - @Override - public void onError(Throwable e) { - // expected, because the pet has been deleted. - } - }); - } - }); - } - - @Test - public void testUploadFile() throws Exception { - File file = File.createTempFile("test", "hello.txt"); - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - - writer.write("Hello world!"); - writer.close(); - - Pet pet = createRandomPet(); - api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError()); - - RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file); - api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber() { - @Override - public void onError(Throwable e) { - // this also yields a 400 for other tests, so I guess it's okay... - } - }); - } - - @Test - public void testEqualsAndHashCode() { - Pet pet1 = new Pet(); - Pet pet2 = new Pet(); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - - pet2.setName("really-happy"); - pet2.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertFalse(pet1.equals(pet2)); - assertFalse(pet2.equals(pet1)); - assertFalse(pet1.hashCode() == (pet2.hashCode())); - assertTrue(pet2.equals(pet2)); - assertTrue(pet2.hashCode() == pet2.hashCode()); - - pet1.setName("really-happy"); - pet1.setPhotoUrls(Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"})); - assertTrue(pet1.equals(pet2)); - assertTrue(pet2.equals(pet1)); - assertTrue(pet1.hashCode() == pet2.hashCode()); - assertTrue(pet1.equals(pet1)); - assertTrue(pet1.hashCode() == pet1.hashCode()); - } - - private Pet createRandomPet() { - Pet pet = new Pet(); - pet.setId(System.currentTimeMillis()); - pet.setName("gorilla"); - - Category category = new Category(); - category.setName("really-happy"); - - pet.setCategory(category); - pet.setStatus(Pet.StatusEnum.AVAILABLE); - List photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"}); - pet.setPhotoUrls(photos); - - return pet; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java deleted file mode 100644 index 5d34a1e5d5d..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/SkeletonSubscriber.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.swagger.petstore.test; - -import junit.framework.TestFailure; -import rx.Subscriber; - -/** - * Skeleton subscriber for tests that will fail when onError() is called unexpectedly. - */ -public abstract class SkeletonSubscriber extends Subscriber { - - public static SkeletonSubscriber failTestOnError() { - return new SkeletonSubscriber() { - }; - } - - @Override - public void onCompleted() { - // space for rent - } - - @Override - public void onNext(T t) { - // space for rent - } - - @Override - public void onError(Throwable e) { - throw new RuntimeException("Subscriber onError() called with unhandled exception!", e); - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java deleted file mode 100644 index f5a34eab200..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.junit.*; - -import retrofit2.Response; - -import static org.junit.Assert.*; - -public class StoreApiTest { - StoreApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(StoreApi.class); - } - - @Test - public void testGetInventory() throws Exception { - api.getInventory().subscribe(new SkeletonSubscriber>() { - @Override - public void onNext(Map inventory) { - assertTrue(inventory.keySet().size() > 0); - } - }); - - } - - @Test - public void testPlaceOrder() throws Exception { - final Order order = createOrder(); - api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order fetched) { - assertEquals(order.getId(), fetched.getId()); - assertEquals(order.getPetId(), fetched.getPetId()); - assertEquals(order.getQuantity(), fetched.getQuantity()); - } - }); - } - - @Test - public void testDeleteOrder() throws Exception { - final Order order = createOrder(); - api.placeOrder(order).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getOrderById(order.getId()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order fetched) { - assertEquals(fetched.getId(), order.getId()); - } - }); - - - api.deleteOrder(String.valueOf(order.getId())).subscribe(SkeletonSubscriber.failTestOnError()); - api.getOrderById(order.getId()) - .subscribe(new SkeletonSubscriber() { - @Override - public void onNext(Order order) { - throw new RuntimeException("Should not have found deleted order."); - } - - @Override - public void onError(Throwable e) { - // should not find deleted order. - } - } - ); - } - - private Order createOrder() { - Order order = new Order(); - order.setPetId(new Long(200)); - order.setQuantity(new Integer(13)); - order.setShipDate(new java.util.Date()); - order.setStatus(Order.StatusEnum.PLACED); - order.setComplete(true); - - try { - Field idField = Order.class.getDeclaredField("id"); - idField.setAccessible(true); - idField.set(order, System.currentTimeMillis()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - return order; - } -} diff --git a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java deleted file mode 100644 index 59e238b457b..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/test/java/io/swagger/petstore/test/UserApiTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package io.swagger.petstore.test; - -import io.swagger.client.ApiClient; -import io.swagger.client.api.*; -import io.swagger.client.model.*; - - -import java.util.Arrays; - -import org.junit.*; - -import static org.junit.Assert.*; - -/** - * NOTE: This serves as a sample and test case for the generator, which is why this is java-7 code. - * Much looks much nicer with no anonymous classes. - */ -public class UserApiTest { - UserApi api = null; - - @Before - public void setup() { - api = new ApiClient().createService(UserApi.class); - } - - @Test - public void testCreateUser() throws Exception { - final User user = createUser(); - - api.createUser(user).subscribe(new SkeletonSubscriber() { - @Override - public void onCompleted() { - api.getUserByName(user.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user.getId(), fetched.getId()); - } - }); - } - }); - } - - @Test - public void testCreateUsersWithArray() throws Exception { - final User user1 = createUser(); - user1.setUsername("abc123"); - User user2 = createUser(); - user2.setUsername("123abc"); - - api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2})).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getUserByName(user1.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user1.getId(), fetched.getId()); - } - }); - } - - @Test - public void testCreateUsersWithList() throws Exception { - final User user1 = createUser(); - user1.setUsername("abc123"); - User user2 = createUser(); - user2.setUsername("123abc"); - - api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2})).subscribe(SkeletonSubscriber.failTestOnError()); - - api.getUserByName(user1.getUsername()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(User fetched) { - assertEquals(user1.getId(), fetched.getId()); - } - }); - } - - @Test - public void testLoginUser() throws Exception { - User user = createUser(); - api.createUser(user); - - api.loginUser(user.getUsername(), user.getPassword()).subscribe(new SkeletonSubscriber() { - @Override - public void onNext(String token) { - assertTrue(token.startsWith("logged in user session:")); - } - }); - } - - @Test - public void logoutUser() throws Exception { - api.logoutUser(); - } - - private User createUser() { - User user = new User(); - user.setId(System.currentTimeMillis()); - user.setUsername("fred"); - user.setFirstName("Fred"); - user.setLastName("Meyer"); - user.setEmail("fred@fredmeyer.com"); - user.setPassword("xxXXxx"); - user.setPhone("408-867-5309"); - user.setUserStatus(123); - - return user; - } -} \ No newline at end of file From 4d3f82e70140ce764a382b8e3194421a49619b00 Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 27 Apr 2016 16:09:53 +0800 Subject: [PATCH 59/63] renmae toJSONSchemaPattern to toRegularExpression --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 69e56e57935..11400996733 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -328,12 +328,12 @@ public class DefaultCodegen { } /** - * Return the JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33) + * Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33) * * @param pattern the pattern (regular expression) * @return properly-escaped pattern */ - public String toJSONSchemaPattern(String pattern) { + public String toRegularExpression(String pattern) { return escapeText(pattern); } @@ -1125,7 +1125,7 @@ public class DefaultCodegen { StringProperty sp = (StringProperty) p; property.maxLength = sp.getMaxLength(); property.minLength = sp.getMinLength(); - property.pattern = toJSONSchemaPattern(sp.getPattern()); + property.pattern = toRegularExpression(sp.getPattern()); // check if any validation rule defined if (property.pattern != null || property.minLength != null || property.maxLength != null) @@ -1828,7 +1828,7 @@ public class DefaultCodegen { p.exclusiveMinimum = qp.isExclusiveMinimum(); p.maxLength = qp.getMaxLength(); p.minLength = qp.getMinLength(); - p.pattern = toJSONSchemaPattern(qp.getPattern()); + p.pattern = toRegularExpression(qp.getPattern()); p.maxItems = qp.getMaxItems(); p.minItems = qp.getMinItems(); p.uniqueItems = qp.isUniqueItems(); From 8753faf2a592eb56b39ee68fa757639a721a1374 Mon Sep 17 00:00:00 2001 From: Neil O'Toole Date: Wed, 27 Apr 2016 09:19:23 +0100 Subject: [PATCH 60/63] issue #2717 - go code won't compile due to not respecting packageName var --- .../swagger-codegen/src/main/resources/go/api_response.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache index 2a34a8cf35a..9f81de76d62 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_response.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -1,4 +1,4 @@ -package swagger +package {{packageName}} import ( "net/http" From 87c6566bd0dadd2ff684a27d2ff8c906f723860a Mon Sep 17 00:00:00 2001 From: wing328 Date: Wed, 27 Apr 2016 17:37:44 +0800 Subject: [PATCH 61/63] mapped uuid to str in python --- .../languages/PythonClientCodegen.java | 4 ++- ...ith-fake-endpoints-models-for-testing.yaml | 4 +++ samples/client/petstore/python/README.md | 27 ++++++++++++------- .../client/petstore/python/docs/FormatTest.md | 7 ++--- .../python/swagger_client/__init__.py | 1 + .../python/swagger_client/apis/__init__.py | 1 + .../swagger_client/models/format_test.py | 25 +++++++++++++++++ 7 files changed, 56 insertions(+), 13 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index a1e3d6f9356..7cb4dc703db 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -58,10 +58,12 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("DateTime", "datetime"); typeMapping.put("object", "object"); typeMapping.put("file", "file"); - //TODO binary should be mapped to byte array + // TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "str"); typeMapping.put("ByteArray", "str"); + // map uuid to string for the time being + typeMapping.put("UUID", "str"); // from https://docs.python.org/release/2.5.4/ref/keywords.html setReservedWordsLowerCase( diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 29996c16b72..4160e59cc48 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -590,6 +590,7 @@ paths: in: formData description: None - name: number + type: number maximum: 543.2 minimum: 32.1 in: formData @@ -890,6 +891,9 @@ definitions: dateTime: type: string format: date-time + uuid: + type: string + format: uuid password: type: string format: password diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 79eef580326..851c5458cb1 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-20T22:11:45.927+08:00 +- Build date: 2016-04-27T17:36:32.266+08:00 - Build package: class io.swagger.codegen.languages.PythonClientCodegen ## Requirements. @@ -50,18 +50,26 @@ import time import swagger_client from swagger_client.rest import ApiException from pprint import pprint - -# Configure OAuth2 access token for authorization: petstore_auth -swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' # create an instance of the API class -api_instance = swagger_client.PetApi -body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store +api_instance = swagger_client.FakeApi +number = 3.4 # float | None +double = 1.2 # float | None +string = 'string_example' # str | None +byte = 'B' # str | None +integer = 56 # int | None (optional) +int32 = 56 # int | None (optional) +int64 = 789 # int | None (optional) +float = 3.4 # float | None (optional) +binary = 'B' # str | None (optional) +date = '2013-10-20' # date | None (optional) +date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) +password = 'password_example' # str | None (optional) try: - # Add a new pet to the store - api_instance.add_pet(body) + # Fake endpoint for testing various parameters + api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password) except ApiException as e: - print "Exception when calling PetApi->add_pet: %s\n" % e + print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e ``` @@ -71,6 +79,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/client/petstore/python/docs/FormatTest.md b/samples/client/petstore/python/docs/FormatTest.md index 4182a447086..3e489e863fa 100644 --- a/samples/client/petstore/python/docs/FormatTest.md +++ b/samples/client/petstore/python/docs/FormatTest.md @@ -10,11 +10,12 @@ Name | Type | Description | Notes **float** | **float** | | [optional] **double** | **float** | | [optional] **string** | **str** | | [optional] -**byte** | **str** | | [optional] +**byte** | **str** | | **binary** | **str** | | [optional] -**date** | **date** | | [optional] +**date** | **date** | | **date_time** | **datetime** | | [optional] -**password** | **str** | | [optional] +**uuid** | **str** | | [optional] +**password** | **str** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 2169ecd37e7..783f8b9713a 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -17,6 +17,7 @@ from .models.tag import Tag from .models.user import User # import apis into sdk package +from .apis.fake_api import FakeApi from .apis.pet_api import PetApi from .apis.store_api import StoreApi from .apis.user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index a3a12ea9ac1..ddde8c164bf 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -1,6 +1,7 @@ from __future__ import absolute_import # import apis into api package +from .fake_api import FakeApi from .pet_api import PetApi from .store_api import StoreApi from .user_api import UserApi diff --git a/samples/client/petstore/python/swagger_client/models/format_test.py b/samples/client/petstore/python/swagger_client/models/format_test.py index 8654d79bc3c..28f348edf04 100644 --- a/samples/client/petstore/python/swagger_client/models/format_test.py +++ b/samples/client/petstore/python/swagger_client/models/format_test.py @@ -48,6 +48,7 @@ class FormatTest(object): 'binary': 'str', 'date': 'date', 'date_time': 'datetime', + 'uuid': 'str', 'password': 'str' } @@ -63,6 +64,7 @@ class FormatTest(object): 'binary': 'binary', 'date': 'date', 'date_time': 'dateTime', + 'uuid': 'uuid', 'password': 'password' } @@ -77,6 +79,7 @@ class FormatTest(object): self._binary = None self._date = None self._date_time = None + self._uuid = None self._password = None @property @@ -321,6 +324,28 @@ class FormatTest(object): """ self._date_time = date_time + @property + def uuid(self): + """ + Gets the uuid of this FormatTest. + + + :return: The uuid of this FormatTest. + :rtype: str + """ + return self._uuid + + @uuid.setter + def uuid(self, uuid): + """ + Sets the uuid of this FormatTest. + + + :param uuid: The uuid of this FormatTest. + :type: str + """ + self._uuid = uuid + @property def password(self): """ From 74fb6175b608ba6a50cf5f076c4c9354277691fa Mon Sep 17 00:00:00 2001 From: Fabien Da Silva Date: Wed, 27 Apr 2016 13:25:33 +0200 Subject: [PATCH 62/63] Fix typo introduced while fixing #2116 --- modules/swagger-codegen/src/main/resources/swift/model.mustache | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache index 9c1787e5bcd..96c4d2ff683 100644 --- a/modules/swagger-codegen/src/main/resources/swift/model.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache @@ -34,11 +34,9 @@ public class {{classname}}: JSONEncodable { {{/unwrapRequired}} {{#unwrapRequired}} public init({{#requiredVars}}{{^-first}}, {{/-first}}{{name}}: {{#isEnum}}{{datatypeWithEnum}}!{{/isEnum}}{{^isEnum}}{{datatype}}!{{/isEnum}}{{/requiredVars}}) { - {{#vars}} {{#requiredVars}} self.{{name}} = {{name}} {{/requiredVars}} - {{/vars}} } {{/unwrapRequired}} From 8a330e9dad09146e3cfd2f8daf45124af0945959 Mon Sep 17 00:00:00 2001 From: Andrew Z Allen Date: Thu, 28 Apr 2016 06:16:43 +0000 Subject: [PATCH 63/63] Improve type checking for closure-angular Closure angular now has more accurate type checking enabled. --- .../Javascript-Closure-Angular/api.mustache | 10 +- .../API/Client/PetApi.js | 214 ++++++++++-------- .../API/Client/StoreApi.js | 176 +++++++------- .../API/Client/UserApi.js | 208 +++++++++-------- 4 files changed, 324 insertions(+), 284 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache index 957add6753e..35604bf73df 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript-Closure-Angular/api.mustache @@ -47,8 +47,8 @@ goog.require('{{import}}'); /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } {{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector']; {{#operation}} @@ -69,7 +69,7 @@ goog.require('{{import}}'); var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); {{#hasFormParams}} /** @type {!Object} */ var formParams = {}; @@ -108,7 +108,7 @@ goog.require('{{import}}'); json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}}, {{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}}, {{/bodyParam}} - {{#hasFormParams}}data: this.httpParamSerializer_(formParams), + {{#hasFormParams}}data: this.httpParamSerializer(formParams), {{/hasFormParams}} params: queryParameters, headers: headerParams @@ -118,7 +118,7 @@ goog.require('{{import}}'); httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } {{/operation}} {{/operations}} diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js index 5cf1c6d751d..39a22ebcdbe 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/PetApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -40,11 +40,50 @@ API.Client.PetApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.PetApi.$inject = ['$http', '$httpParamSerializer', '$injector']; +/** + * Update an existing pet + * + * @param {!Pet} body Pet object that needs to be added to the store + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.PetApi.prototype.updatePet = function(body, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/pet'; + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'body' is set + if (!body) { + throw new Error('Missing required parameter body when calling updatePet'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'PUT', + url: path, + json: true, + data: body, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + /** * Add a new pet to the store * @@ -60,7 +99,7 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling addPet'); @@ -71,7 +110,9 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -79,47 +120,7 @@ API.Client.PetApi.prototype.addPet = function(body, opt_extraHttpRequestParams) httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Deletes a pet - * - * @param {!number} petId Pet id to delete - * @param {!string=} opt_apiKey - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/pet/{petId}' - .replace('{' + 'petId' + '}', String(petId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'petId' is set - if (!petId) { - throw new Error('Missing required parameter petId when calling deletePet'); - } - headerParams['api_key'] = opt_apiKey; - - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -137,7 +138,7 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'status' is set if (!status) { throw new Error('Missing required parameter status when calling findPetsByStatus'); @@ -151,7 +152,9 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -159,7 +162,7 @@ API.Client.PetApi.prototype.findPetsByStatus = function(status, opt_extraHttpReq httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -177,7 +180,7 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'tags' is set if (!tags) { throw new Error('Missing required parameter tags when calling findPetsByTags'); @@ -191,7 +194,9 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -199,7 +204,7 @@ API.Client.PetApi.prototype.findPetsByTags = function(tags, opt_extraHttpRequest httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -218,7 +223,7 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling getPetById'); @@ -228,7 +233,9 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -236,44 +243,7 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Update an existing pet - * - * @param {!Pet} body Pet object that needs to be added to the store - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.PetApi.prototype.updatePet = function(body, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/pet'; - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'body' is set - if (!body) { - throw new Error('Missing required parameter body when calling updatePet'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'PUT', - url: path, - json: true, - data: body, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -294,7 +264,7 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var formParams = {}; @@ -313,7 +283,9 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st method: 'POST', url: path, json: false, - data: this.httpParamSerializer_(formParams), + + data: this.httpParamSerializer(formParams), + params: queryParameters, headers: headerParams }; @@ -322,7 +294,49 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Deletes a pet + * + * @param {!number} petId Pet id to delete + * @param {!string=} opt_apiKey + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/pet/{petId}' + .replace('{' + 'petId' + '}', String(petId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'petId' is set + if (!petId) { + throw new Error('Missing required parameter petId when calling deletePet'); + } + headerParams['api_key'] = opt_apiKey; + + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -343,7 +357,7 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var formParams = {}; @@ -362,7 +376,9 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, method: 'POST', url: path, json: false, - data: this.httpParamSerializer_(formParams), + + data: this.httpParamSerializer(formParams), + params: queryParameters, headers: headerParams }; @@ -371,5 +387,5 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js index e6c1216099a..9e18eceefcc 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/StoreApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -39,48 +39,11 @@ API.Client.StoreApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.StoreApi.$inject = ['$http', '$httpParamSerializer', '$injector']; -/** - * Delete purchase order by ID - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * @param {!string} orderId ID of the order that needs to be deleted - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.StoreApi.prototype.deleteOrder = function(orderId, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling deleteOrder'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); -} - /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -95,13 +58,15 @@ API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var httpRequestParams = { method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -109,44 +74,7 @@ API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Find purchase order by ID - * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - * @param {!number} orderId ID of pet that needs to be fetched - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/store/order/{orderId}' - .replace('{' + 'orderId' + '}', String(orderId)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling getOrderById'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'GET', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -164,7 +92,7 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling placeOrder'); @@ -175,7 +103,9 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -183,5 +113,83 @@ API.Client.StoreApi.prototype.placeOrder = function(body, opt_extraHttpRequestPa httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param {!number} orderId ID of pet that needs to be fetched + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling getOrderById'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'GET', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param {!string} orderId ID of the order that needs to be deleted + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.StoreApi.prototype.deleteOrder = function(orderId, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/store/order/{orderId}' + .replace('{' + 'orderId' + '}', String(orderId)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling deleteOrder'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } diff --git a/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js b/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js index 97b524c9d8a..733f7d65f5a 100644 --- a/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js +++ b/samples/client/petstore/javascript-closure-angular/API/Client/UserApi.js @@ -3,9 +3,9 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. * Version: 1.0.0 - * Generated at: 2016-04-16T18:02:07.029+08:00 + * Generated at: 2016-04-28T06:15:51.482Z * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** @@ -39,8 +39,8 @@ API.Client.UserApi = function($http, $httpParamSerializer, $injector) { /** @private {!angular.$http} */ this.http_ = $http; - /** @private {!Object} */ - this.httpParamSerializer_ = $injector.get('$httpParamSerializer'); + /** @package {!Object} */ + this.httpParamSerializer = $injector.get('$httpParamSerializer'); } API.Client.UserApi.$inject = ['$http', '$httpParamSerializer', '$injector']; @@ -59,7 +59,7 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUser'); @@ -70,7 +70,9 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -78,7 +80,7 @@ API.Client.UserApi.prototype.createUser = function(body, opt_extraHttpRequestPar httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -96,7 +98,7 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUsersWithArrayInput'); @@ -107,7 +109,9 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -115,7 +119,7 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(body, opt_extr httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -133,7 +137,7 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'body' is set if (!body) { throw new Error('Missing required parameter body when calling createUsersWithListInput'); @@ -144,7 +148,9 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -152,81 +158,7 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(body, opt_extra httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); -} - -/** - * Delete user - * This can only be done by the logged in user. - * @param {!string} username The name that needs to be deleted - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.UserApi.prototype.deleteUser = function(username, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'username' is set - if (!username) { - throw new Error('Missing required parameter username when calling deleteUser'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'DELETE', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); -} - -/** - * Get user by user name - * - * @param {!string} username The name that needs to be fetched. Use user1 for testing. - * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. - * @return {!angular.$q.Promise} - */ -API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpRequestParams) { - /** @const {string} */ - var path = this.basePath_ + '/user/{username}' - .replace('{' + 'username' + '}', String(username)); - - /** @type {!Object} */ - var queryParameters = {}; - - /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); - // verify required parameter 'username' is set - if (!username) { - throw new Error('Missing required parameter username when calling getUserByName'); - } - /** @type {!Object} */ - var httpRequestParams = { - method: 'GET', - url: path, - json: true, - params: queryParameters, - headers: headerParams - }; - - if (opt_extraHttpRequestParams) { - httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); - } - - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -245,7 +177,7 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling loginUser'); @@ -267,7 +199,9 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -275,7 +209,7 @@ API.Client.UserApi.prototype.loginUser = function(username, password, opt_extraH httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -292,13 +226,15 @@ API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) { var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); /** @type {!Object} */ var httpRequestParams = { method: 'GET', url: path, json: true, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -306,7 +242,46 @@ API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) { httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Get user by user name + * + * @param {!string} username The name that needs to be fetched. Use user1 for testing. + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling getUserByName'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'GET', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); } /** @@ -326,7 +301,7 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp var queryParameters = {}; /** @type {!Object} */ - var headerParams = angular.extend({}, this.defaultHeaders); + var headerParams = angular.extend({}, this.defaultHeaders_); // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling updateUser'); @@ -341,7 +316,9 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp url: path, json: true, data: body, - params: queryParameters, + + + params: queryParameters, headers: headerParams }; @@ -349,5 +326,44 @@ API.Client.UserApi.prototype.updateUser = function(username, body, opt_extraHttp httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); } - return this.http_(httpRequestParams); + return (/** @type {?} */ (this.http_))(httpRequestParams); +} + +/** + * Delete user + * This can only be done by the logged in user. + * @param {!string} username The name that needs to be deleted + * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. + * @return {!angular.$q.Promise} + */ +API.Client.UserApi.prototype.deleteUser = function(username, opt_extraHttpRequestParams) { + /** @const {string} */ + var path = this.basePath_ + '/user/{username}' + .replace('{' + 'username' + '}', String(username)); + + /** @type {!Object} */ + var queryParameters = {}; + + /** @type {!Object} */ + var headerParams = angular.extend({}, this.defaultHeaders_); + // verify required parameter 'username' is set + if (!username) { + throw new Error('Missing required parameter username when calling deleteUser'); + } + /** @type {!Object} */ + var httpRequestParams = { + method: 'DELETE', + url: path, + json: true, + + + params: queryParameters, + headers: headerParams + }; + + if (opt_extraHttpRequestParams) { + httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams); + } + + return (/** @type {?} */ (this.http_))(httpRequestParams); }