From 4e7711763af75e744a01903e3092e3de2e8e8929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Bresson?= Date: Sun, 22 Apr 2018 10:32:30 +0200 Subject: [PATCH] Merge branch 'swagger-codegen_renamed' into 'master' (#183) * Added vendorExtensions.x-isPrimitive. (#7991) * Added vendorExtensions.x-isPrimitive. Switch template for constructFromObject. * Reflect review indication. * [typescript-angular] AOT-compatible API client (via ng-packagr and ngc) (#7984) * typescript-angular: uses ng-packagr for the build see https://github.com/swagger-api/swagger-codegen/issues/6722 see https://github.com/swagger-api/swagger-codegen/pull/6735/ * this should make everybody happy: Angular 2/4/5 AOT support - uses ngc when targeting Angular 2 (as seen in https://github.com/swagger-api/swagger-codegen/pull/6735) - uses ng-packagr 1 when targeting Angular 4 - uses ng-packagr 2 when targeting Angular 5 * removes bogus import * cleans / updates Petstore samples, adds a new sample for Angular 5 * typo in README * fixes broken travis build. adds pom.xml files again This reverts commit 471d248a2e9b5d8eed10c71644c222c053e007b0. * makes usage of `dist` more clear and i feel generally better when `npm run build` is called explicitly. - for ng-packagr 2 is doesn't matter, since the final package.json does not have any scripts - for old ng-packagr 1 it matters, scripts are copied to the final package.json which breaks installation via `npm install {{npmName}} --save` (it runs `npm run build` again) * typescript-angular: small improvements as suggested by @macjohnny * angular-typescript: updated petstore samples, 3rd try * Issue 5542, always generate pom and readme (#7977) * Issue 5542, generate pom.xml with separate parameter. InterfaceOnly=true for not generating pom.xml not works in every situation. * Issue 5542, generate pom.xml with separate parameter. InterfaceOnly=true for not generating pom.xml not works in every situation. * Issue #5542 Always generate pom.xml and README.md * [TypeScript][Angular] fix date path parameters (#7476, #7302) (#7479) * #7476, #7302: [TypeScript][Angular] fix date path parameters, fix path parameters with :.+ in it * #7476, #7302: [TypeScript][Angular] fix date path parameters, fix path parameters with :.+ in it * #7476, #7302: [TypeScript][Angular] fix date path parameters, fix path parameters with :.+ in it * #7476: generate samples * code cleanup * #7476: improve variable description * #7302: revert character skipping, since it will now have the same parameter name in the method signature and in the api path * #7302: generate samples * typescript-angular: added Interfaces to api exports if withInterfaces is selected (#7975) * added Interfaces to api exports if withInterfaces is selected * removed import of interface classes * added gererated petstore example api.ts * Fix Issue 8014 * Adapted to work with Angular2 Http and Angular 4.3+ HttpClient * removed unnecessary (others) for ng HttpClient from Interface * Golang Client Refactor (body and model in errors, typed optional parameters) (#7987) * Return abstracted errors with model data if available. * update tests with error models. * Return error models on the abstract type. * dont leak FH * duplicate of PR #7752 for issue #7511 * Change optional parameters to structs. * update documentation * fix circleCI failure * [typescript][angular] query parameter with null value should not be set (#8033) * #7893: [typescript][angular] fix optional query parameter null value * #7893: [typescript][angular] generate samples * #7893: [typescript][angular] generate samples * Version rest-assured has been updated to 3.1.0 (#8052) * [Dart] Fixes TypeError in Dart 2 mode (#7959) * Properly convert lists to dart types * Updated sample petstore client * Fixed maps in Dart strong mode Fixed list parsing for null-elements * change parseDate in es6/APIClient (#7973) * [PHP] Improve duplicated validation logic (#7954) * Improve duplicated validation logic * Update the samples --- .generator/templates/api.mustache | 143 ++++++++++++++++---------- .generator/templates/api_doc.mustache | 8 +- .generator/templates/client.mustache | 41 +++++++- .generator/templates/model.mustache | 2 - 4 files changed, 131 insertions(+), 63 deletions(-) diff --git a/.generator/templates/api.mustache b/.generator/templates/api.mustache index a7bb7a7f876..1aa817ca8d1 100644 --- a/.generator/templates/api.mustache +++ b/.generator/templates/api.mustache @@ -7,7 +7,7 @@ import ( "net/http" "net/url" "strings" - "golang.org/x/net/context" + "context" {{#imports}} "{{import}}" {{/imports}} ) @@ -20,22 +20,30 @@ var ( type {{classname}}Service service {{#operation}} -/* {{{classname}}}Service{{#summary}} {{.}}{{/summary}}{{#notes}} +/* +{{{classname}}}Service{{#summary}} {{.}}{{/summary}}{{#notes}} {{notes}}{{/notes}} - * @param ctx context.Context for authentication, logging, tracing, etc. -{{#allParams}}{{#required}}@param {{paramName}}{{#description}} {{.}}{{/description}} -{{/required}}{{/allParams}}{{#hasOptionalParams}}@param optional (nil or map[string]interface{}) with one or more of: -{{#allParams}}{{^required}} @param "{{paramName}}" ({{dataType}}){{#description}} {{.}}{{/description}} -{{/required}}{{/allParams}}{{/hasOptionalParams}}@return {{#returnType}}{{{returnType}}}{{/returnType}}*/ -func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals map[string]interface{}{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) { + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). +{{#allParams}}{{#required}} * @param {{paramName}}{{#description}} {{.}}{{/description}} +{{/required}}{{/allParams}}{{#hasOptionalParams}} * @param optional nil or *{{{nickname}}}Opts - Optional Parameters: +{{#allParams}}{{^required}} * @param "{{vendorExtensions.x-exportParamName}}" ({{#isPrimitiveType}}optional.{{vendorExtensions.x-optionalDataType}}{{/isPrimitiveType}}{{^isPrimitiveType}}optional.Interface of {{dataType}}{{/isPrimitiveType}}) - {{#description}} {{.}}{{/description}} +{{/required}}{{/allParams}}{{/hasOptionalParams}} +{{#returnType}}@return {{{returnType}}}{{/returnType}} +*/ +{{#hasOptionalParams}} + +type {{{nickname}}}Opts struct { {{#allParams}}{{^required}} +{{#isPrimitiveType}} {{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}{{/isPrimitiveType}}{{^isPrimitiveType}} {{vendorExtensions.x-exportParamName}} optional.Interface{{/isPrimitiveType}}{{/required}}{{/allParams}} +} + +{{/hasOptionalParams}} +func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("{{httpMethod}}") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte -{{#returnType}} - successPayload {{returnType}} -{{/returnType}} + {{#returnType}}localVarReturnValue {{{returnType}}}{{/returnType}} ) // create path and map variables @@ -46,32 +54,25 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarQueryParams := url.Values{} localVarFormParams := url.Values{} {{#allParams}} - {{^required}} - {{#isPrimitiveType}} - if err := typeCheckParameter(localVarOptionals["{{paramName}}"], "{{{dataType}}}", "{{paramName}}"); err != nil { - return {{#returnType}}successPayload, {{/returnType}}nil, err - } - {{/isPrimitiveType}} - {{/required}} {{#required}} {{#minItems}} if len({{paramName}}) < {{minItems}} { - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements") } {{/minItems}} {{#maxItems}} if len({{paramName}}) > {{maxItems}} { - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements") } {{/maxItems}} {{#minLength}} if strlen({{paramName}}) < {{minLength}} { - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements") } {{/minLength}} {{#maxLength}} if strlen({{paramName}}) > {{maxLength}} { - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements") } {{/maxLength}} {{#minimum}} @@ -82,7 +83,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{^isString}} if {{paramName}} < {{minimum}} { {{/isString}} - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}") } {{/minimum}} {{#maximum}} @@ -93,7 +94,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{^isString}} if {{paramName}} > {{maximum}} { {{/isString}} - return {{#returnType}}successPayload, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}") + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}") } {{/maximum}} {{/required}} @@ -105,8 +106,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarQueryParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) {{/required}} {{^required}} - if localVarTempParam, localVarOk := localVarOptionals["{{paramName}}"].({{dataType}}); localVarOk { - localVarQueryParams.Add("{{baseName}}", parameterToString(localVarTempParam, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) + if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { + localVarQueryParams.Add("{{baseName}}", parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) } {{/required}} {{/queryParams}} @@ -138,8 +139,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarHeaderParams["{{baseName}}"] = parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}") {{/required}} {{^required}} - if localVarTempParam, localVarOk := localVarOptionals["{{paramName}}"].({{dataType}}); localVarOk { - localVarHeaderParams["{{baseName}}"] = parameterToString(localVarTempParam, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}") + if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { + localVarHeaderParams["{{baseName}}"] = parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}") } {{/required}} {{/headerParams}} @@ -148,9 +149,13 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{#formParams}} {{#isFile}} {{^required}} - var localVarFile ({{dataType}}) - if localVarTempParam, localVarOk := localVarOptionals["{{paramName}}"].({{dataType}}); localVarOk { - localVarFile = localVarTempParam + var localVarFile {{dataType}} + if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { + localVarFileOk := false + localVarFile, localVarFileOk = localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{dataType}}) + if !localVarFileOk { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} should be {{dataType}}") + } } {{/required}} if localVarFile != nil { @@ -165,8 +170,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarFormParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) {{/required}} {{^required}} - if localVarTempParam, localVarOk := localVarOptionals["{{paramName}}"].({{dataType}}); localVarOk { - localVarFormParams.Add("{{baseName}}", parameterToString(localVarTempParam, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) + if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { + localVarFormParams.Add("{{baseName}}", parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")) } {{/required}} {{/isFile}} @@ -178,8 +183,13 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} localVarPostBody = &{{paramName}} {{/required}} {{^required}} - if localVarTempParam, localVarOk := localVarOptionals["{{paramName}}"].({{dataType}}); localVarOk { - localVarPostBody = &localVarTempParam + if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() { + {{#isPrimitiveType}}localVarPostBody = &localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(){{/isPrimitiveType}} + {{^isPrimitiveType}}localVarOptional{{vendorExtensions.x-exportParamName}}, localVarOptional{{vendorExtensions.x-exportParamName}}ok := localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{{dataType}}}) + if !localVarOptional{{vendorExtensions.x-exportParamName}}ok { + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} should be {{dataType}}") + } + localVarPostBody = &localVarOptional{{vendorExtensions.x-exportParamName}}{{/isPrimitiveType}} } {{/required}} {{/bodyParams}} @@ -195,42 +205,63 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} } else { key = auth.Key } - {{#isKeyInHeader}}localVarHeaderParams["{{keyParamName}}"] = key{{/isKeyInHeader}}{{#isKeyInQuery}}localVarQueryParams.Add("{{keyParamName}}", key){{/isKeyInQuery}} + {{#isKeyInHeader}}localVarHeaderParams["{{keyParamName}}"] = key{{/isKeyInHeader}} + {{#isKeyInQuery}}localVarQueryParams.Add("{{keyParamName}}", key){{/isKeyInQuery}} } } {{/isApiKey}} {{/authMethods}} r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { - return {{#returnType}}successPayload, {{/returnType}}nil, err + return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { - return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err } - defer localVarHttpResponse.Body.Close() - if localVarHttpResponse.StatusCode >= 300 { - bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body) - return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes) - } -{{#returnType}} - {{#withXml}} - contentType := localVarHttpResponse.Header.Get("content-type") - if strings.Contains(contentType, "application/xml") { - if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return successPayload, localVarHttpResponse, err - } - return successPayload, localVarHttpResponse, err + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err } - {{/withXml}} - if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil { - return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err + {{#returnType}} + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err == nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err + } + } + {{/returnType}} + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + {{#responses}}{{#dataType}} + if localVarHttpResponse.StatusCode == {{{code}}} { + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + if err != nil { + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err + } + + var v {{{dataType}}} + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); + if err != nil { + newErr.error = err.Error() + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr + } + newErr.model = v + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr + } + {{/dataType}}{{/responses}} + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr } -{{/returnType}} - return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err + return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil } {{/operation}}{{/operations}} \ No newline at end of file diff --git a/.generator/templates/api_doc.mustache b/.generator/templates/api_doc.mustache index 635a91e3ed8..76e823ebb83 100644 --- a/.generator/templates/api_doc.mustache +++ b/.generator/templates/api_doc.mustache @@ -20,16 +20,16 @@ Method | HTTP request | Description {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **ctx** | **context.Context** | context for logging, tracing, authentication, etc.{{/-last}}{{/allParams}}{{#allParams}}{{#required}} + **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.{{/-last}}{{/allParams}}{{#allParams}}{{#required}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}} - **optional** | **map[string]interface{}** | optional parameters | nil if no parameters + **optional** | ***{{{nickname}}}Opts** | optional parameters | nil if no parameters ### Optional Parameters -Optional parameters are passed through a map[string]interface{}. +Optional parameters are passed through a pointer to a {{{nickname}}}Opts struct {{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}} - **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}} +{{^required}} **{{paramName}}** | {{#isFile}}**optional.Interface of {{dataType}}**{{/isFile}}{{#isPrimitiveType}}**optional.{{vendorExtensions.x-optionalDataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**optional.Interface of {{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}} ### Return type diff --git a/.generator/templates/client.mustache b/.generator/templates/client.mustache index 38c7a7e2720..c2b2d9ea5e6 100644 --- a/.generator/templates/client.mustache +++ b/.generator/templates/client.mustache @@ -20,7 +20,7 @@ import ( "time" "unicode/utf8" - "golang.org/x/net/context" + "context" "golang.org/x/oauth2" ) @@ -303,6 +303,21 @@ func (c *APIClient) prepareRequest( return localVarRequest, nil } +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if strings.Contains(contentType, "application/xml") { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } else if strings.Contains(contentType, "application/json") { + if err = json.Unmarshal(b, v); err != nil { + return err + } + return nil + } + return errors.New("undefined response type") +} + // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) @@ -337,6 +352,8 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { @@ -427,3 +444,25 @@ func CacheExpires(r *http.Response) time.Time { func strlen(s string) int { return utf8.RuneCountInString(s) } + +// GenericSwaggerError Provides access to the body, error and model on returned errors. +type GenericSwaggerError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericSwaggerError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericSwaggerError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericSwaggerError) Model() interface{} { + return e.model +} \ No newline at end of file diff --git a/.generator/templates/model.mustache b/.generator/templates/model.mustache index 65996a1a9fb..cc8c45cb27d 100644 --- a/.generator/templates/model.mustache +++ b/.generator/templates/model.mustache @@ -12,7 +12,6 @@ const ( {{#allowableValues}} {{#enumVars}} {{^-first}} - {{/-first}} {{name}} {{{classname}}} = "{{{value}}}" {{/enumVars}} @@ -22,7 +21,6 @@ const ( type {{classname}} struct { {{#vars}} {{^-first}} - {{/-first}} {{#description}} // {{{description}}}