forked from loafle/openapi-generator-original
account for return type where the response type is in a list container, and properly import models into operations
This commit is contained in:
parent
bb11322919
commit
f9f58596b8
@ -10,9 +10,12 @@ import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@ -244,7 +247,31 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
return addNamespaces(super.postProcessOperations(objs));
|
||||
objs = addNamespaces(super.postProcessOperations(objs));
|
||||
|
||||
if (objs.containsKey("imports")) {
|
||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||
LinkedHashMap<String, String> newImport;
|
||||
String currentImport;
|
||||
String modelName;
|
||||
|
||||
for (Map<String, String> importMap : (List<Map<String, String>>) objs.get("imports")) {
|
||||
currentImport = importMap.get("import");
|
||||
modelName = currentImport.replace(modelPackage + ".", "");
|
||||
|
||||
if (reservedWords.contains(modelName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newImport = new LinkedHashMap<String, String>();
|
||||
newImport.put("import", modelNamespace + "\\" + modelName);
|
||||
imports.add(newImport);
|
||||
}
|
||||
|
||||
objs.put("imports", imports);
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,10 @@ namespace {{apiNamespace}};
|
||||
use {{invokerNamespace}}\Configuration;
|
||||
use {{invokerNamespace}}\ApiClient;
|
||||
|
||||
{{#imports}}
|
||||
use {{{import}}};
|
||||
{{/imports}}
|
||||
|
||||
{{#operations}}
|
||||
class {{classname}} {
|
||||
|
||||
@ -65,7 +69,7 @@ class {{classname}} {
|
||||
* {{{summary}}}
|
||||
*
|
||||
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{/allParams}} * @return {{#returnType}}{{#isListContainer}}{{returnBaseType}}[]{{/isListContainer}}{{^isListContainer}}{{{returnType}}}{{/isListContainer}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
*/
|
||||
public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
{{#allParams}}{{#required}}
|
||||
@ -136,6 +140,5 @@ class {{classname}} {
|
||||
return $responseObject;{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
{{newline}}
|
||||
{{/operations}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user