forked from loafle/openapi-generator-original
fixed code gen using {{#isListContainer}}*{{/isListContainer}} field
This commit is contained in:
@@ -401,13 +401,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
listIterator.add(newImportMap);
|
||||
}
|
||||
}
|
||||
// add pointer to return type string if it is not array
|
||||
for (CodegenOperation operation : operations) {
|
||||
if((operation.returnContainer == null || operation.returnContainer != "array")
|
||||
&& operation.returnType != null) {
|
||||
operation.returnType = "*" + operation.returnType;
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}} {
|
||||
* {{notes}}{{/notes}}
|
||||
*
|
||||
{{#allParams}} * @param {{paramName}} {{description}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{/allParams}} * @return {{#returnType}}{{^isListContainer}}*{{/isListContainer}}{{{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}}{{^isListContainer}}*{{/isListContainer}}{{{returnType}}}, {{/returnType}}*APIResponse, error) {
|
||||
|
||||
var httpMethod = "{{httpMethod}}"
|
||||
// create path and map variables
|
||||
@@ -46,7 +46,7 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if &{{paramName}} == nil {
|
||||
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||
return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}new({{{returnType}}}), {{/returnType}}nil, errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||
}{{/required}}{{/allParams}}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
@@ -113,10 +113,10 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
|
||||
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
|
||||
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}}{{#isListContainer}}*{{/isListContainer}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
{{#returnType}}
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
|
||||
return {{#returnType}}*successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err
|
||||
return {{#returnType}}{{#isListContainer}}*{{/isListContainer}}successPayload, {{/returnType}}NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
Reference in New Issue
Block a user