forked from loafle/openapi-generator-original
Reduce casting for operations processing (#12002)
This commit is contained in:
parent
66db259678
commit
edfb3e123f
@ -29,6 +29,7 @@ import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -194,7 +195,7 @@ public interface CodegenConfig {
|
||||
|
||||
ModelsMap postProcessModels(ModelsMap objs);
|
||||
|
||||
Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels);
|
||||
OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels);
|
||||
|
||||
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
|
||||
|
||||
|
@ -40,6 +40,7 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter;
|
||||
import org.openapitools.codegen.templating.mustache.*;
|
||||
@ -810,7 +811,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// override with any special post-processing
|
||||
@Override
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,11 @@ import org.openapitools.codegen.languages.PythonClientCodegen;
|
||||
import org.openapitools.codegen.languages.PythonExperimentalClientCodegen;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.templating.CommonTemplateContentLocator;
|
||||
import org.openapitools.codegen.templating.GeneratorTemplateContentLocator;
|
||||
@ -541,7 +544,7 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void generateApis(List<File> files, List<Object> allOperations, List<ModelMap> allModels) {
|
||||
void generateApis(List<File> files, List<OperationsMap> allOperations, List<ModelMap> allModels) {
|
||||
if (!generateApis) {
|
||||
// TODO: Process these anyway and present info via dryRun?
|
||||
LOGGER.info("Skipping generation of APIs.");
|
||||
@ -566,7 +569,7 @@ public class DefaultGenerator implements Generator {
|
||||
try {
|
||||
List<CodegenOperation> ops = paths.get(tag);
|
||||
ops.sort((one, another) -> ObjectUtils.compare(one.operationId, another.operationId));
|
||||
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
||||
OperationsMap operation = processOperations(config, tag, ops, allModels);
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
operation.put("basePath", basePath);
|
||||
operation.put("basePathWithoutHost", removeTrailingSlash(config.encodePath(url.getPath())));
|
||||
@ -595,9 +598,8 @@ public class DefaultGenerator implements Generator {
|
||||
if (config.vendorExtensions().containsKey("x-group-parameters")) {
|
||||
boolean isGroupParameters = Boolean.parseBoolean(config.vendorExtensions().get("x-group-parameters").toString());
|
||||
|
||||
Map<String, Object> objectMap = (Map<String, Object>) operation.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
OperationMap objectMap = operation.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation op : operations) {
|
||||
if (isGroupParameters && !op.vendorExtensions.containsKey("x-group-parameters")) {
|
||||
op.vendorExtensions.put("x-group-parameters", Boolean.TRUE);
|
||||
@ -617,7 +619,7 @@ public class DefaultGenerator implements Generator {
|
||||
processMimeTypes(swagger.getProduces(), operation, "produces");
|
||||
*/
|
||||
|
||||
allOperations.add(new HashMap<>(operation));
|
||||
allOperations.add(operation);
|
||||
|
||||
addAuthenticationSwitches(operation);
|
||||
|
||||
@ -746,14 +748,13 @@ public class DefaultGenerator implements Generator {
|
||||
generateVersionMetadata(files);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> buildSupportFileBundle(List<Object> allOperations, List<ModelMap> allModels) {
|
||||
Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, List<ModelMap> allModels) {
|
||||
|
||||
Map<String, Object> bundle = new HashMap<>(config.additionalProperties());
|
||||
bundle.put("apiPackage", config.apiPackage());
|
||||
|
||||
Map<String, Object> apis = new HashMap<>();
|
||||
apis.put("apis", allOperations);
|
||||
ApiInfoMap apis = new ApiInfoMap();
|
||||
apis.setApis(allOperations);
|
||||
|
||||
URL url = URLPathUtils.getServerURL(openAPI, config.serverVariableOverrides());
|
||||
|
||||
@ -887,7 +888,7 @@ public class DefaultGenerator implements Generator {
|
||||
List<ModelMap> allModels = new ArrayList<>();
|
||||
generateModels(files, allModels, filteredSchemas);
|
||||
// apis
|
||||
List<Object> allOperations = new ArrayList<>();
|
||||
List<OperationsMap> allOperations = new ArrayList<>();
|
||||
generateApis(files, allOperations, allModels);
|
||||
|
||||
// supporting files
|
||||
@ -1170,11 +1171,11 @@ public class DefaultGenerator implements Generator {
|
||||
return parameter.getName() + ":" + parameter.getIn();
|
||||
}
|
||||
|
||||
private Map<String, Object> processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = new HashMap<>();
|
||||
Map<String, Object> objs = new HashMap<>();
|
||||
objs.put("classname", config.toApiName(tag));
|
||||
objs.put("pathPrefix", config.toApiVarName(tag));
|
||||
private OperationsMap processOperations(CodegenConfig config, String tag, List<CodegenOperation> ops, List<ModelMap> allModels) {
|
||||
OperationsMap operations = new OperationsMap();
|
||||
OperationMap objs = new OperationMap();
|
||||
objs.setClassname(config.toApiName(tag));
|
||||
objs.setPathPrefix(config.toApiVarName(tag));
|
||||
|
||||
// check for operationId uniqueness
|
||||
Set<String> opIds = new HashSet<>();
|
||||
@ -1187,9 +1188,9 @@ public class DefaultGenerator implements Generator {
|
||||
}
|
||||
opIds.add(opId);
|
||||
}
|
||||
objs.put("operation", ops);
|
||||
objs.setOperation(ops);
|
||||
|
||||
operations.put("operations", objs);
|
||||
operations.setOperation(objs);
|
||||
operations.put("package", config.apiPackage());
|
||||
|
||||
Set<String> allImports = new ConcurrentSkipListSet<>();
|
||||
@ -1201,10 +1202,10 @@ public class DefaultGenerator implements Generator {
|
||||
Set<Map<String, String>> imports = toImportsObjects(mappings);
|
||||
|
||||
//Some codegen implementations rely on a list interface for the imports
|
||||
operations.put("imports", imports.stream().collect(Collectors.toList()));
|
||||
operations.setImports(new ArrayList<>(imports));
|
||||
|
||||
// add a flag to indicate whether there's any {{import}}
|
||||
if (imports.size() > 0) {
|
||||
if (!imports.isEmpty()) {
|
||||
operations.put("hasImport", true);
|
||||
}
|
||||
|
||||
@ -1239,18 +1240,14 @@ public class DefaultGenerator implements Generator {
|
||||
* @return The set of unique imports
|
||||
*/
|
||||
private Set<Map<String, String>> toImportsObjects(Map<String, String> mappedImports) {
|
||||
Set<Map<String, String>> result = new TreeSet<Map<String, String>>(
|
||||
(Comparator<Map<String, String>>) (o1, o2) -> {
|
||||
String s1 = o1.get("classname");
|
||||
String s2 = o2.get("classname");
|
||||
return s1.compareTo(s2);
|
||||
}
|
||||
Set<Map<String, String>> result = new TreeSet<>(
|
||||
Comparator.comparing(o -> o.get("classname"))
|
||||
);
|
||||
|
||||
mappedImports.entrySet().forEach(mapping -> {
|
||||
mappedImports.forEach((key, value) -> {
|
||||
Map<String, String> im = new LinkedHashMap<>();
|
||||
im.put("import", mapping.getKey());
|
||||
im.put("classname", mapping.getValue());
|
||||
im.put("import", key);
|
||||
im.put("classname", value);
|
||||
result.add(im);
|
||||
});
|
||||
return result;
|
||||
|
@ -36,6 +36,8 @@ import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -607,9 +609,9 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op1 : operationList) {
|
||||
if (op1.summary != null) {
|
||||
|
@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -663,12 +665,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
|
||||
// Check return types for collection
|
||||
|
@ -12,6 +12,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -560,11 +562,11 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
if (op.hasConsumes) {
|
||||
if (!op.formParams.isEmpty() || op.isMultipart) {
|
||||
|
@ -26,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -362,11 +364,9 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
|
||||
@ -374,7 +374,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
if (imports == null)
|
||||
return objs;
|
||||
|
||||
@ -401,7 +401,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
// recursively add import for mapping one type to multiple imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> recursiveImports = objs.getImports();
|
||||
if (recursiveImports == null)
|
||||
return objs;
|
||||
|
||||
|
@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -512,12 +514,12 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
|
||||
// Check return types for collection
|
||||
|
@ -24,6 +24,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -462,11 +464,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
@ -474,7 +474,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
if (imports == null)
|
||||
return objs;
|
||||
|
||||
@ -565,7 +565,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
// recursively add import for mapping one type to multiple imports
|
||||
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> recursiveImports = objs.getImports();
|
||||
if (recursiveImports == null)
|
||||
return objs;
|
||||
|
||||
|
@ -21,6 +21,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -421,10 +423,10 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
|
||||
for (CodegenOperation op : (List<CodegenOperation>) objs.get("operation")) {
|
||||
for (CodegenOperation op : objs.getOperation()) {
|
||||
// non GET/HEAD methods are mutation
|
||||
if (!"GET".equals(op.httpMethod.toUpperCase(Locale.ROOT)) && !"HEAD".equals(op.httpMethod.toUpperCase(Locale.ROOT))) {
|
||||
op.vendorExtensions.put("x-is-mutation", Boolean.TRUE);
|
||||
@ -440,7 +442,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
return operations;
|
||||
}
|
||||
|
||||
public String graphQlInputsPackage() {
|
||||
|
@ -38,6 +38,8 @@ import org.openapitools.codegen.languages.features.DocumentationProviderFeatures
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -1362,10 +1364,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// Remove imports of List, ArrayList, Map and HashMap as they are
|
||||
// imported in the template already.
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
Pattern pattern = Pattern.compile("java\\.util\\.(List|ArrayList|Map|HashMap)");
|
||||
for (Iterator<Map<String, String>> itr = imports.iterator(); itr.hasNext(); ) {
|
||||
String itrImport = itr.next().get("import");
|
||||
@ -1374,8 +1376,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
Collection<String> operationImports = new ConcurrentSkipListSet<>();
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
|
@ -25,6 +25,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -168,12 +170,11 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> updatedObjs = jaxrsPostProcessOperations(objs);
|
||||
Map<String, Object> operations = (Map<String, Object>) updatedObjs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap updatedObjs = jaxrsPostProcessOperations(objs);
|
||||
OperationMap operations = updatedObjs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation co : ops) {
|
||||
handleImplicitHeaders(co);
|
||||
}
|
||||
@ -181,13 +182,11 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
return updatedObjs;
|
||||
}
|
||||
|
||||
static Map<String, Object> jaxrsPostProcessOperations(Map<String, Object> objs) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
static OperationsMap jaxrsPostProcessOperations(OperationsMap objs) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
String commonPath = null;
|
||||
if (operations != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
Map<String, String> firstType = operation.consumes.get(0);
|
||||
|
@ -24,6 +24,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -703,9 +705,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
// for API test method name
|
||||
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
|
||||
|
@ -32,8 +32,11 @@ import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -465,13 +468,11 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Map<String, Object>> getOperations(Map<String, Object> objs) {
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
|
||||
for (Map<String, Object> api : apis) {
|
||||
result.add((Map<String, Object>) api.get("operations"));
|
||||
private static List<OperationMap> getOperations(Map<String, Object> objs) {
|
||||
List<OperationMap> result = new ArrayList<>();
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) objs.get("apiInfo");
|
||||
for (OperationsMap api : apiInfo.getApis()) {
|
||||
result.add(api.getOperations());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -483,9 +484,9 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
opsByPath.put(op.path, op);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> opsByPathList = new ArrayList<Map<String, Object>>();
|
||||
List<Map<String, Object>> opsByPathList = new ArrayList<>();
|
||||
for (Map.Entry<String, Collection<CodegenOperation>> entry : opsByPath.asMap().entrySet()) {
|
||||
Map<String, Object> opsByPathEntry = new HashMap<String, Object>();
|
||||
Map<String, Object> opsByPathEntry = new HashMap<>();
|
||||
opsByPathList.add(opsByPathEntry);
|
||||
opsByPathEntry.put("path", entry.getKey());
|
||||
opsByPathEntry.put("operation", entry.getValue());
|
||||
@ -570,9 +571,8 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
generateJSONSpecFile(objs);
|
||||
generateYAMLSpecFile(objs);
|
||||
|
||||
for (Map<String, Object> operations : getOperations(objs)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (OperationMap operations : getOperations(objs)) {
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
|
||||
List<Map<String, Object>> opsByPathList = sortOperationsByPath(ops);
|
||||
operations.put("operationsByPath", opsByPathList);
|
||||
@ -645,9 +645,9 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation operation : operationList) {
|
||||
Map<String, String> skipTests = new HashMap<>();
|
||||
|
@ -20,6 +20,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -88,18 +90,17 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
List<CodegenOperation> newOpList = new ArrayList<>();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = op.path;
|
||||
|
||||
String[] items = path.split("/", -1);
|
||||
List<String> splitPath = new ArrayList<String>();
|
||||
List<String> splitPath = new ArrayList<>();
|
||||
for (String item : items) {
|
||||
if (item.matches("^\\{(.*)\\}$")) {
|
||||
item = "*";
|
||||
@ -113,9 +114,10 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
|
||||
if (!foundInNewList) {
|
||||
if (op1.path.equals(op.path)) {
|
||||
foundInNewList = true;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get("x-codegen-otherMethods");
|
||||
if (currentOtherMethodList == null) {
|
||||
currentOtherMethodList = new ArrayList<CodegenOperation>();
|
||||
currentOtherMethodList = new ArrayList<>();
|
||||
}
|
||||
op.operationIdCamelCase = op1.operationIdCamelCase;
|
||||
currentOtherMethodList.add(op);
|
||||
@ -127,7 +129,7 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
|
||||
newOpList.add(op);
|
||||
}
|
||||
}
|
||||
operations.put("operation", newOpList);
|
||||
operations.setOperation(newOpList);
|
||||
return objs;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -462,13 +464,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
// We need to postprocess the operations to add proper consumes tags and fix form file handling
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.consumes == null) {
|
||||
continue;
|
||||
|
@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -354,9 +356,9 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
// Convert httpMethod to lower case, e.g. "get", "post"
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
@ -23,6 +23,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -117,9 +119,9 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -255,14 +257,13 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
return op;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
String classname = (String) operations.get("classname");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
String classname = operations.getClassname();
|
||||
operations.put("classnameSnakeUpperCase", underscore(classname).toUpperCase(Locale.ROOT));
|
||||
operations.put("classnameSnakeLowerCase", underscore(classname).toLowerCase(Locale.ROOT));
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
boolean consumeJson = false;
|
||||
boolean isParsingSupported = true;
|
||||
|
@ -7,6 +7,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -310,12 +312,11 @@ public abstract class CppQtAbstractCodegen extends AbstractCppCodegen implements
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
Map<String, CodegenModel> codegenModels = new HashMap<>();
|
||||
|
||||
for (ModelMap moObj : allModels) {
|
||||
|
@ -29,6 +29,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.util.*;
|
||||
@ -322,11 +324,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
|
||||
// override with any special post-processing
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (String hdr : op.imports) {
|
||||
if (importMapping.containsKey(hdr)) {
|
||||
|
@ -24,6 +24,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -282,11 +284,10 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
return toApiName(name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
List<CodegenOperation> newOpList = new ArrayList<>();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
@ -318,6 +319,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
if (op1.path.equals(op.path)) {
|
||||
foundInNewList = true;
|
||||
final String X_CODEGEN_OTHER_METHODS = "x-codegen-other-methods";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> currentOtherMethodList = (List<CodegenOperation>) op1.vendorExtensions.get(X_CODEGEN_OTHER_METHODS);
|
||||
if (currentOtherMethodList == null) {
|
||||
currentOtherMethodList = new ArrayList<>();
|
||||
@ -332,7 +334,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
newOpList.add(op);
|
||||
}
|
||||
}
|
||||
operations.put("operation", newOpList);
|
||||
operations.setOperation(newOpList);
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.PrefixWithHashLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -556,9 +558,9 @@ public class CrystalClientCodegen extends DefaultCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<>();
|
||||
|
||||
@ -567,7 +569,7 @@ public class CrystalClientCodegen extends DefaultCodegen {
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
p.vendorExtensions.put("x-crystal-example", constructExampleCode(p, modelMaps, processedModelMaps));
|
||||
|
@ -23,6 +23,8 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -393,13 +395,13 @@ public class CsharpNetcoreFunctionsServerCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
// We need to postprocess the operations to add proper consumes tags and fix form file handling
|
||||
if (objs != null) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.consumes == null) {
|
||||
continue;
|
||||
|
@ -25,6 +25,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -264,10 +266,10 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
Set<Map<String, Object>> serializers = new HashSet<>();
|
||||
Set<String> resultImports = new HashSet<>();
|
||||
@ -303,6 +305,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
// for some reason "import" structure is changed ..
|
||||
objs.put("imports", resultImports.stream().sorted().collect(Collectors.toList()));
|
||||
objs.put("serializers", serializers);
|
||||
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.ClientModificationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -295,10 +297,10 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
Set<String> resultImports = new HashSet<>();
|
||||
|
||||
@ -365,6 +367,7 @@ public class DartDioNextClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
// for some reason "import" structure is changed ..
|
||||
objs.put("imports", resultImports.stream().sorted().collect(Collectors.toList()));
|
||||
|
||||
return objs;
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
@ -245,11 +247,11 @@ public class DartJaguarClientCodegen extends AbstractDartCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
Set<String> modelImports = new HashSet<>();
|
||||
Set<String> fullImports = new HashSet<>();
|
||||
|
@ -28,6 +28,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -298,9 +300,9 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) super.postProcessOperationsWithModels(objs, allModels).get("operations");
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = super.postProcessOperationsWithModels(objs, allModels).getOperations();
|
||||
List<CodegenOperation> os = operations.getOperation();
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}([^\\{]*)");
|
||||
for (CodegenOperation o : os) {
|
||||
@ -332,7 +334,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
newOs.add(eco);
|
||||
}
|
||||
operations.put("operation", newOs);
|
||||
operations.setOperation(newOs);
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -359,10 +361,10 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"static-method", "unchecked"})
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
@SuppressWarnings("static-method")
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
ops.forEach(op -> {
|
||||
op.allParams = op.allParams.stream().sorted(new ParameterSorter()).collect(Collectors.toList());
|
||||
op.responses.forEach(response -> {
|
||||
|
@ -23,6 +23,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.JoinWithCommaLambda;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -309,10 +311,10 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<ExtendedCodegenOperation>();
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> os = operations.getOperation();
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}");
|
||||
for (CodegenOperation o : os) {
|
||||
// force http method to lower case
|
||||
@ -322,7 +324,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
o.returnType = "[" + o.returnBaseType + "]";
|
||||
}
|
||||
|
||||
ArrayList<String> pathTemplateNames = new ArrayList<String>();
|
||||
ArrayList<String> pathTemplateNames = new ArrayList<>();
|
||||
Matcher matcher = pattern.matcher(o.path);
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
@ -341,7 +343,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
eco.setPathTemplateNames(pathTemplateNames);
|
||||
newOs.add(eco);
|
||||
}
|
||||
operations.put("operation", newOs);
|
||||
operations.setOperation(newOs);
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -368,9 +370,9 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> os = operations.getOperation();
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}");
|
||||
for (CodegenOperation o : os) {
|
||||
@ -397,7 +399,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
newOs.add(eco);
|
||||
}
|
||||
operations.put("operation", newOs);
|
||||
operations.setOperation(newOs);
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -270,9 +272,9 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
if (op.path != null) {
|
||||
op.path = op.path.replaceAll("\\{(.*?)\\}", ":$1");
|
||||
|
@ -29,6 +29,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -456,10 +458,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, ArrayList<Integer>> processedModelMaps = new HashMap<>();
|
||||
|
||||
for (ModelMap modelMap : allModels) {
|
||||
@ -467,7 +469,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
p.vendorExtensions.put("x-go-example", constructExampleCode(p, modelMaps, processedModelMaps));
|
||||
@ -670,4 +672,4 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
return "*" + goImportAlias + ".New" + toModelName(model) + "(" + StringUtils.join(propertyExamples, ", ") + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@ -107,11 +109,11 @@ public class GoEchoServerCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
if (op.path != null) {
|
||||
op.path = op.path.replaceAll("\\{(.*?)\\}", ":$1");
|
||||
|
@ -23,6 +23,8 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -122,11 +124,11 @@ public class GoGinServerCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
if (op.path != null) {
|
||||
op.path = op.path.replaceAll("\\{(.*?)\\}", ":$1");
|
||||
|
@ -22,6 +22,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -286,14 +288,12 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
if (imports == null)
|
||||
return objs;
|
||||
|
||||
|
@ -33,6 +33,8 @@ import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
|
||||
public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
@ -126,9 +128,9 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
// Overwrite path to map variable with path parameters
|
||||
op.path = op.path.replace("{", "${");
|
||||
|
@ -30,6 +30,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -809,10 +811,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> ret = super.postProcessOperationsWithModels(objs, allModels);
|
||||
HashMap<String, Object> pathOps = (HashMap<String, Object>) ret.get("operations");
|
||||
ArrayList<CodegenOperation> ops = (ArrayList<CodegenOperation>) pathOps.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap ret = super.postProcessOperationsWithModels(objs, allModels);
|
||||
OperationMap pathOps = ret.getOperations();
|
||||
List<CodegenOperation> ops = pathOps.getOperation();
|
||||
if (ops.size() > 0) {
|
||||
ops.get(0).vendorExtensions.put(VENDOR_EXTENSION_X_HAS_NEW_TAG, true);
|
||||
}
|
||||
@ -827,7 +829,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
m.vendorExtensions.put(VENDOR_EXTENSION_X_MIME_TYPES, mimeTypes);
|
||||
|
||||
if ((boolean) additionalProperties.get(PROP_GENERATE_FORM_URLENCODED_INSTANCES) && mimeTypes.contains("MimeFormUrlEncoded")) {
|
||||
Boolean hasMimeFormUrlEncoded = true;
|
||||
boolean hasMimeFormUrlEncoded = true;
|
||||
for (CodegenProperty v : m.vars) {
|
||||
if (!(v.isPrimitiveType || v.isString || v.isDate || v.isDateTime)) {
|
||||
hasMimeFormUrlEncoded = false;
|
||||
|
@ -24,6 +24,7 @@ import org.openapitools.codegen.languages.features.GzipTestFeatures;
|
||||
import org.openapitools.codegen.languages.features.LoggingTestFeatures;
|
||||
import org.openapitools.codegen.languages.features.UseGenericResponseFeatures;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -166,7 +167,7 @@ public class JavaCXFClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
return AbstractJavaJAXRSServerCodegen.jaxrsPostProcessOperations(objs);
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.languages.features.CXFExtServerFeatures;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.JsonCache;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.JsonCache.CacheException;
|
||||
@ -1161,17 +1163,17 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> result = super.postProcessOperationsWithModels(objs, allModels);
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap result = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
if (generateOperationBody) {
|
||||
// We generate the operation body in code because the logic to do so is far too complicated to be expressed
|
||||
// in the logic-less Mustache templating system.
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> operations = (Map<String, Object>) result.get("operations");
|
||||
OperationMap operations = result.getOperations();
|
||||
if (operations != null) {
|
||||
String classname = (String) operations.get("classname");
|
||||
String classname = operations.getClassname();
|
||||
|
||||
// Map the models so we can look them up by name.
|
||||
Map<String, CodegenModel> models = new HashMap<>();
|
||||
@ -1181,8 +1183,7 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
|
||||
}
|
||||
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
applyDefaultContentTypes(op);
|
||||
String testDataPath = '/' + classname + '/' + op.operationId;
|
||||
@ -1246,16 +1247,16 @@ public class JavaCXFExtServerCodegen extends JavaCXFServerCodegen implements CXF
|
||||
// did not include the ones we've just added to support the code in the operation bodies. Therefore it
|
||||
// is necessary to recompute the imports and overwrite the existing ones. The code below was copied from
|
||||
// the private DefaultGenerator.processOperations() method to achieve this end.
|
||||
Set<String> allImports = new TreeSet<String>();
|
||||
Set<String> allImports = new TreeSet<>();
|
||||
for (CodegenOperation op : ops) {
|
||||
allImports.addAll(op.imports);
|
||||
}
|
||||
allImports.add("List");
|
||||
allImports.add("Map");
|
||||
|
||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||
List<Map<String, String>> imports = new ArrayList<>();
|
||||
for (String nextImport : allImports) {
|
||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||
Map<String, String> im = new LinkedHashMap<>();
|
||||
String mapping = importMapping().get(nextImport);
|
||||
if (mapping == null) {
|
||||
mapping = toModelImport(nextImport);
|
||||
|
@ -29,6 +29,8 @@ import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.GlobalFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.CaseFormatLambda;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -635,14 +637,13 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
if (RETROFIT_2.equals(getLibrary())) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
|
||||
@ -680,8 +681,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
|
||||
// camelize path variables for Feign client
|
||||
if (FEIGN.equals(getLibrary())) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
Pattern methodPattern = Pattern.compile("^(.*):([^:]*)$");
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = op.path;
|
||||
|
@ -25,6 +25,8 @@ import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -130,7 +132,7 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
List<CodegenOperation> opList = operations.get(basePath);
|
||||
if (opList == null) {
|
||||
opList = new ArrayList<CodegenOperation>();
|
||||
opList = new ArrayList<>();
|
||||
operations.put(basePath, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
@ -138,10 +140,10 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
|
@ -7,6 +7,8 @@ import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -318,14 +320,14 @@ public abstract class JavaMicronautAbstractCodegen extends AbstractJavaCodegen i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Map<String, CodegenModel> models = allModels.stream()
|
||||
.map(ModelMap::getModel)
|
||||
.collect(Collectors.toMap(v -> v.classname, v -> v));
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
// Set whether body is supported in request
|
||||
|
@ -4,6 +4,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -185,12 +187,12 @@ public class JavaMicronautServerCodegen extends JavaMicronautAbstractCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
// Add the controller classname to operations
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
String controllerClassname = StringUtils.camelize(controllerPrefix + "_" + operations.get("pathPrefix") + "_" + controllerSuffix);
|
||||
OperationMap operations = objs.getOperations();
|
||||
String controllerClassname = StringUtils.camelize(controllerPrefix + "_" + operations.getPathPrefix() + "_" + controllerSuffix);
|
||||
objs.put("controllerClassname", controllerClassname);
|
||||
|
||||
List<CodegenOperation> allOperations = (List<CodegenOperation>) operations.get("operation");
|
||||
|
@ -25,6 +25,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -311,12 +313,11 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
serviceName + "IT.java"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (final CodegenOperation operation : ops) {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
|
@ -23,6 +23,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -305,11 +307,11 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
|
||||
for (CodegenParameter param : operation.allParams) {
|
||||
|
@ -23,6 +23,8 @@ import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -120,10 +122,10 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -191,11 +193,11 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> newObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) newObjs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap newObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
OperationMap operations = newObjs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
||||
|
@ -21,6 +21,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@ -126,13 +128,12 @@ public class JavaVertXWebServerCodegen extends AbstractJavaCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> newObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) newObjs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap newObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
OperationMap operations = newObjs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
||||
|
@ -29,6 +29,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -908,13 +910,13 @@ public class JavascriptApolloClientCodegen extends DefaultCodegen implements Cod
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// Generate and store argument list string of each operation into
|
||||
// vendor-extension: x-codegen-argList.
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
List<String> argList = new ArrayList<>();
|
||||
boolean hasOptionalParams = false;
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -969,15 +971,14 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return Arrays.asList(primitives).contains(type);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// Generate and store argument list string of each operation into
|
||||
// vendor-extension: x-codegen-argList.
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
List<String> argList = new ArrayList<>();
|
||||
boolean hasOptionalParams = false;
|
||||
|
@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -272,16 +273,10 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
if (objs.get("imports") instanceof List) {
|
||||
List<Map<String, String>> imports = (ArrayList<Map<String, String>>)objs.get("imports");
|
||||
Collections.sort(imports, new Comparator<Map<String, String>>() {
|
||||
public int compare(Map<String, String> o1, Map<String, String> o2) {
|
||||
return o1.get("import").compareTo(o2.get("import"));
|
||||
}
|
||||
});
|
||||
objs.put("imports", imports);
|
||||
}
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
imports.sort(Comparator.comparing(o -> o.get("import")));
|
||||
objs.put("imports", imports);
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -767,12 +769,11 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
|
||||
if (JVM_RETROFIT2.equals(getLibrary()) && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
||||
@ -789,22 +790,22 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
// match on first part in mediaTypes like 'application/json; charset=utf-8'
|
||||
int endIndex = mediaTypeValue.indexOf(';');
|
||||
String mediaType = (endIndex == -1
|
||||
? mediaTypeValue
|
||||
: mediaTypeValue.substring(0, endIndex)
|
||||
? mediaTypeValue
|
||||
: mediaTypeValue.substring(0, endIndex)
|
||||
).trim();
|
||||
return "multipart/form-data".equals(mediaType)
|
||||
|| "application/x-www-form-urlencoded".equals(mediaType)
|
||||
|| (mediaType.startsWith("application/") && mediaType.endsWith("json"));
|
||||
|| "application/x-www-form-urlencoded".equals(mediaType)
|
||||
|| (mediaType.startsWith("application/") && mediaType.endsWith("json"));
|
||||
};
|
||||
operation.consumes = operation.consumes == null ? null : operation.consumes.stream()
|
||||
.filter(isSerializable)
|
||||
.limit(1)
|
||||
.collect(Collectors.toList());
|
||||
.filter(isSerializable)
|
||||
.limit(1)
|
||||
.collect(Collectors.toList());
|
||||
operation.hasConsumes = operation.consumes != null && !operation.consumes.isEmpty();
|
||||
|
||||
operation.produces = operation.produces == null ? null : operation.produces.stream()
|
||||
.filter(isSerializable)
|
||||
.collect(Collectors.toList());
|
||||
.filter(isSerializable)
|
||||
.collect(Collectors.toList());
|
||||
operation.hasProduces = operation.produces != null && !operation.produces.isEmpty();
|
||||
}
|
||||
|
||||
@ -850,7 +851,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
}
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
return objs;
|
||||
}
|
||||
|
||||
private static boolean isMultipartType(List<Map<String, String>> consumes) {
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -578,10 +580,10 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
ops.forEach(operation -> {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -420,11 +422,9 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation op : operations) {
|
||||
|
||||
String[] items = op.path.split("/", -1);
|
||||
|
@ -25,6 +25,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -258,11 +260,9 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -238,11 +241,9 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
||||
@ -272,13 +273,11 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
return objs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Map<String, Object>> getOperations(Map<String, Object> objs) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
|
||||
for (Map<String, Object> api : apis) {
|
||||
result.add((Map<String, Object>) api.get("operations"));
|
||||
private static List<OperationMap> getOperations(Map<String, Object> objs) {
|
||||
List<OperationMap> result = new ArrayList<>();
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) objs.get("apiInfo");
|
||||
for (OperationsMap api : apiInfo.getApis()) {
|
||||
result.add(api.getOperations());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -401,9 +400,8 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateYAMLSpecFile(objs);
|
||||
|
||||
for (Map<String, Object> operations : getOperations(objs)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (OperationMap operations : getOperations(objs)) {
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
|
||||
List<Map<String, Object>> opsByPathList = sortOperationsByPath(ops);
|
||||
operations.put("operationsByPath", opsByPathList);
|
||||
|
@ -27,6 +27,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -713,11 +715,9 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
|
||||
|
@ -23,6 +23,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -652,11 +654,11 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (!operation.allParams.isEmpty()) {
|
||||
String firstParamName = operation.allParams.get(0).paramName;
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@ -234,11 +236,9 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
// override with any special post-processing
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
for (CodegenOperation op : operations) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
@ -261,12 +261,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
// sort the endpoints in ascending to avoid the route priority issue.
|
||||
// https://github.com/swagger-api/swagger-codegen/issues/2643
|
||||
Collections.sort(operations, new Comparator<CodegenOperation>() {
|
||||
@Override
|
||||
public int compare(CodegenOperation lhs, CodegenOperation rhs) {
|
||||
return lhs.path.compareTo(rhs.path);
|
||||
}
|
||||
});
|
||||
operations.sort(Comparator.comparing(lhs -> lhs.path));
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@ -166,23 +168,16 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
// override with any special post-processing
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
|
||||
for (CodegenOperation op : operations) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// sort the endpoints in ascending to avoid the route priority issue.
|
||||
Collections.sort(operations, new Comparator<CodegenOperation>() {
|
||||
@Override
|
||||
public int compare(CodegenOperation lhs, CodegenOperation rhs) {
|
||||
return lhs.path.compareTo(rhs.path);
|
||||
}
|
||||
});
|
||||
operations.sort(Comparator.comparing(lhs -> lhs.path));
|
||||
|
||||
escapeMediaType(operations);
|
||||
|
||||
|
@ -31,6 +31,8 @@ import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -416,10 +418,10 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
String httpMethodDeclaration;
|
||||
String pathPattern = null;
|
||||
for (CodegenOperation op : operationList) {
|
||||
|
@ -23,6 +23,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
@ -260,9 +262,9 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = op.path;
|
||||
String[] items = path.split("/", -1);
|
||||
|
@ -30,7 +30,10 @@ import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -254,9 +257,9 @@ public class PhpSlim4ServerCodegen extends AbstractPhpCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
addUserClassnameToOperations(operations);
|
||||
escapeMediaType(operationList);
|
||||
return objs;
|
||||
@ -264,21 +267,16 @@ public class PhpSlim4ServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<HashMap<String, Object>> apiList = (List<HashMap<String, Object>>) apiInfo.get("apis");
|
||||
for (HashMap<String, Object> api : apiList) {
|
||||
HashMap<String, Object> operations = (HashMap<String, Object>) api.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) objs.get("apiInfo");
|
||||
for (OperationsMap api : apiInfo.getApis()) {
|
||||
List<CodegenOperation> operationList = api.getOperations().getOperation();
|
||||
|
||||
// Sort operations to avoid static routes shadowing
|
||||
// ref: https://github.com/nikic/FastRoute/blob/master/src/DataGenerator/RegexBasedAbstract.php#L92-L101
|
||||
Collections.sort(operationList, new Comparator<CodegenOperation>() {
|
||||
@Override
|
||||
public int compare(CodegenOperation one, CodegenOperation another) {
|
||||
operationList.sort((one, another) -> {
|
||||
if (one.getHasPathParams() && !another.getHasPathParams()) return 1;
|
||||
if (!one.getHasPathParams() && another.getHasPathParams()) return -1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -310,8 +308,8 @@ public class PhpSlim4ServerCodegen extends AbstractPhpCodegen {
|
||||
*
|
||||
* @param operations codegen object with operations
|
||||
*/
|
||||
private void addUserClassnameToOperations(Map<String, Object> operations) {
|
||||
String classname = (String) operations.get("classname");
|
||||
private void addUserClassnameToOperations(OperationMap operations) {
|
||||
String classname = operations.getClassname();
|
||||
classname = classname.replaceAll("^" + abstractNamePrefix, "");
|
||||
classname = classname.replaceAll(abstractNameSuffix + "$", "");
|
||||
operations.put(USER_CLASSNAME_KEY, classname);
|
||||
|
@ -26,7 +26,10 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -157,9 +160,9 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
addUserClassnameToOperations(operations);
|
||||
escapeMediaType(operationList);
|
||||
return objs;
|
||||
@ -167,21 +170,16 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<HashMap<String, Object>> apiList = (List<HashMap<String, Object>>) apiInfo.get("apis");
|
||||
for (HashMap<String, Object> api : apiList) {
|
||||
HashMap<String, Object> operations = (HashMap<String, Object>) api.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) objs.get("apiInfo");
|
||||
for (OperationsMap api : apiInfo.getApis()) {
|
||||
List<CodegenOperation> operationList = api.getOperations().getOperation();
|
||||
|
||||
// Sort operations to avoid static routes shadowing
|
||||
// ref: https://github.com/nikic/FastRoute/blob/master/src/DataGenerator/RegexBasedAbstract.php#L92-L101
|
||||
Collections.sort(operationList, new Comparator<CodegenOperation>() {
|
||||
@Override
|
||||
public int compare(CodegenOperation one, CodegenOperation another) {
|
||||
operationList.sort((one, another) -> {
|
||||
if (one.getHasPathParams() && !another.getHasPathParams()) return 1;
|
||||
if (!one.getHasPathParams() && another.getHasPathParams()) return -1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return objs;
|
||||
@ -217,8 +215,8 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
*
|
||||
* @param operations codegen object with operations
|
||||
*/
|
||||
private void addUserClassnameToOperations(Map<String, Object> operations) {
|
||||
String classname = (String) operations.get("classname");
|
||||
private void addUserClassnameToOperations(OperationMap operations) {
|
||||
String classname = operations.getClassname();
|
||||
classname = classname.replaceAll("^" + abstractNamePrefix, "");
|
||||
classname = classname.replaceAll(abstractNameSuffix + "$", "");
|
||||
operations.put(USER_CLASSNAME_KEY, classname);
|
||||
|
@ -24,6 +24,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -391,15 +393,15 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
operations.put("controllerName", toControllerName((String) operations.get("pathPrefix")));
|
||||
operations.put("symfonyService", toSymfonyService((String) operations.get("pathPrefix")));
|
||||
OperationMap operations = objs.getOperations();
|
||||
operations.put("controllerName", toControllerName(operations.getPathPrefix()));
|
||||
operations.put("symfonyService", toSymfonyService(operations.getPathPrefix()));
|
||||
|
||||
List<CodegenSecurity> authMethods = new ArrayList<>();
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
// Loop through all input parameters to determine, whether we have to import something to
|
||||
|
@ -27,6 +27,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -1012,8 +1014,8 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<>();
|
||||
|
||||
@ -1022,7 +1024,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
int index = 0;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -541,9 +543,9 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
int index = 1;
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
|
@ -31,6 +31,8 @@ import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.ProcessUtils;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
@ -365,13 +367,13 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// fix the imports that each model has, add the module reference to the model
|
||||
// loops through imports and converts them all
|
||||
// from 'Pet' to 'from petstore_api.model.pet import Pet'
|
||||
|
||||
HashMap<String, Object> val = (HashMap<String, Object>) objs.get("operations");
|
||||
ArrayList<CodegenOperation> operations = (ArrayList<CodegenOperation>) val.get("operation");
|
||||
OperationMap val = objs.getOperations();
|
||||
List<CodegenOperation> operations = val.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
if (operation.imports.isEmpty()) {
|
||||
continue;
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.api.TemplatePathLocator;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.*;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
@ -424,12 +426,12 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
|
||||
It is very verbose to write all of this info into the api template
|
||||
This ingests all operations under a tag in the objs input and writes out one file for each endpoint
|
||||
*/
|
||||
protected void generateEndpoints(Map<String, Object> objs) {
|
||||
protected void generateEndpoints(OperationsMap objs) {
|
||||
if (!(Boolean) additionalProperties.get(CodegenConstants.GENERATE_APIS)) {
|
||||
return;
|
||||
}
|
||||
HashMap<String, Object> operations = (HashMap<String, Object>) objs.get("operations");
|
||||
ArrayList<CodegenOperation> codegenOperations = (ArrayList<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> codegenOperations = operations.getOperation();
|
||||
for (CodegenOperation co: codegenOperations) {
|
||||
for (Tag tag: co.tags) {
|
||||
String tagName = tag.getName();
|
||||
@ -442,7 +444,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
|
||||
String templateName = "endpoint.handlebars";
|
||||
String filename = endpointFilename(templateName, pythonTagName, co.operationId);
|
||||
try {
|
||||
File written = processTemplateToFile(operationMap, templateName, filename, true, CodegenConstants.APIS);
|
||||
processTemplateToFile(operationMap, templateName, filename, true, CodegenConstants.APIS);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Error when writing template file {}", e.toString());
|
||||
}
|
||||
@ -671,14 +673,14 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
// fix the imports that each model has, add the module reference to the model
|
||||
// loops through imports and converts them all
|
||||
// from 'Pet' to 'from petstore_api.model.pet import Pet'
|
||||
|
||||
HashMap<String, Object> val = (HashMap<String, Object>) objs.get("operations");
|
||||
ArrayList<CodegenOperation> operations = (ArrayList<CodegenOperation>) val.get("operation");
|
||||
ArrayList<HashMap<String, String>> imports = (ArrayList<HashMap<String, String>>) objs.get("imports");
|
||||
OperationMap val = objs.getOperations();
|
||||
List<CodegenOperation> operations = val.getOperation();
|
||||
List<Map<String, String>> imports = objs.getImports();
|
||||
for (CodegenOperation operation : operations) {
|
||||
if (operation.imports.size() == 0) {
|
||||
continue;
|
||||
|
@ -30,6 +30,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -188,12 +190,12 @@ public class PythonFastAPIServerCodegen extends AbstractPythonCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
// Set will make sure that no duplicated items are used.
|
||||
Set<String> securityImports = new HashSet<>();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (final CodegenOperation operation : ops) {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
@ -230,7 +232,7 @@ public class PythonFastAPIServerCodegen extends AbstractPythonCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
objs.put("securityImports", new ArrayList<String>(securityImports));
|
||||
objs.put("securityImports", new ArrayList<>(securityImports));
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -689,16 +691,16 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
for (ModelMap modelMap : allModels) {
|
||||
CodegenModel m = modelMap.getModel();
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
for (CodegenParameter cp : operation.allParams) {
|
||||
cp.vendorExtensions.put("x-r-example", constructExampleCode(cp, modelMaps));
|
||||
|
@ -23,6 +23,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -573,18 +575,18 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<String, Integer>();
|
||||
OperationMap operations = objs.getOperations();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
HashMap<String, Integer> processedModelMaps = new HashMap<>();
|
||||
|
||||
for (ModelMap modelMap : allModels) {
|
||||
CodegenModel m = modelMap.getModel();
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenParameter p : op.allParams) {
|
||||
p.vendorExtensions.put("x-ruby-example", constructExampleCode(p, modelMaps, processedModelMaps));
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -525,11 +527,9 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
|
||||
if (HYPER_LIBRARY.equals(getLibrary())) {
|
||||
|
@ -33,8 +33,11 @@ import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -968,9 +971,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
postProcessOperationWithModels(op, allModels);
|
||||
@ -1370,12 +1373,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
* @return true if any operation has a callback, false otherwise
|
||||
*/
|
||||
private static boolean haveCallbacks(Map<String, Object> bundle) {
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) bundle.get("apiInfo");
|
||||
List<Object> apis = (List<Object>) apiInfo.get("apis");
|
||||
for (Object api : apis) {
|
||||
Map<String, Object> apiData = (Map<String, Object>) api;
|
||||
Map<String, Object> opss = (Map<String, Object>) apiData.get("operations");
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) opss.get("operation");
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) bundle.get("apiInfo");
|
||||
for (OperationsMap api : apiInfo.getApis()) {
|
||||
List<CodegenOperation> ops = api.getOperations().getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
if (!op.callbacks.isEmpty()) {
|
||||
return true;
|
||||
|
@ -26,6 +26,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -212,13 +214,12 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
if (registerNonStandardStatusCodes) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, ArrayList<CodegenOperation>> opsMap = (Map<String, ArrayList<CodegenOperation>>) objs.get("operations");
|
||||
HashSet<Integer> unknownCodes = new HashSet<Integer>();
|
||||
for (CodegenOperation operation : opsMap.get("operation")) {
|
||||
OperationMap opsMap = objs.getOperations();
|
||||
HashSet<Integer> unknownCodes = new HashSet<>();
|
||||
for (CodegenOperation operation : opsMap.getOperation()) {
|
||||
for (CodegenResponse response : operation.responses) {
|
||||
if ("default".equals(response.code)) {
|
||||
continue;
|
||||
@ -251,13 +252,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
|
||||
}
|
||||
|
||||
// Remove OAuth securities
|
||||
Iterator<CodegenSecurity> it = codegenSecurities.iterator();
|
||||
while (it.hasNext()) {
|
||||
final CodegenSecurity security = it.next();
|
||||
if (security.isOAuth) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
codegenSecurities.removeIf(security -> security.isOAuth);
|
||||
if (codegenSecurities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -282,8 +284,8 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> baseObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationsMap baseObjs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
pathMatcherPatternsPostProcessor(baseObjs);
|
||||
marshallingPostProcessor(baseObjs);
|
||||
return baseObjs;
|
||||
@ -344,13 +346,12 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
|
||||
public static String PATH_MATCHER_PATTERNS_KEY = "pathMatcherPatterns";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void pathMatcherPatternsPostProcessor(Map<String, Object> objs) {
|
||||
private static void pathMatcherPatternsPostProcessor(OperationsMap objs) {
|
||||
if (objs != null) {
|
||||
HashMap<String, PathMatcherPattern> patternMap = new HashMap<>();
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
for (CodegenParameter parameter : operation.pathParams) {
|
||||
if (parameter.pattern != null && !parameter.pattern.isEmpty()) {
|
||||
@ -371,8 +372,7 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
}
|
||||
|
||||
// Responsible for setting up Marshallers/Unmarshallers
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void marshallingPostProcessor(Map<String, Object> objs) {
|
||||
public static void marshallingPostProcessor(OperationsMap objs) {
|
||||
|
||||
if (objs == null) {
|
||||
return;
|
||||
@ -384,9 +384,9 @@ public class ScalaAkkaHttpServerCodegen extends AbstractScalaCodegen implements
|
||||
boolean hasCookieParams = false;
|
||||
boolean hasMultipart = false;
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
|
||||
for (CodegenOperation op : operationList) {
|
||||
boolean isMultipart = op.isMultipart;
|
||||
|
@ -22,6 +22,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -229,11 +231,10 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
|
||||
return outputFolder + File.separator + sourceFolder + File.separator + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
|
||||
// Converts GET /foo/bar => get("foo" :: "bar")
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -202,9 +204,9 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
ArrayList<CodegenOperation> oplist = (ArrayList<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> oplist = operations.getOperation();
|
||||
|
||||
for (CodegenOperation codegenOperation : oplist) {
|
||||
String path = codegenOperation.path;
|
||||
|
@ -23,8 +23,11 @@ import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ApiInfoMap;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -223,9 +226,8 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
|
||||
.put("indented_4", new IndentedLambda(4, " "));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
Map<String, CodegenModel> models = new HashMap<>();
|
||||
|
||||
for (ModelMap _mo : allModels) {
|
||||
@ -233,9 +235,9 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
|
||||
models.put(model.classname, _mo.getModel());
|
||||
}
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
Pattern pathVariableMatcher = Pattern.compile("\\{([^}]+)}");
|
||||
Matcher match = pathVariableMatcher.matcher(operation.path);
|
||||
@ -277,18 +279,15 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
|
||||
return objs;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
objs = super.postProcessSupportingFileData(objs);
|
||||
generateJSONSpecFile(objs);
|
||||
|
||||
// Prettify routes file
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<Map<String, Object>> apis = (List<Map<String, Object>>) apiInfo.get("apis");
|
||||
List<CodegenOperation> ops = apis.stream()
|
||||
.map(api -> (Map<String, Object>) api.get("operations"))
|
||||
.flatMap(operations -> ((List<CodegenOperation>) operations.get("operation")).stream())
|
||||
ApiInfoMap apiInfo = (ApiInfoMap) objs.get("apiInfo");
|
||||
List<CodegenOperation> ops = apiInfo.getApis().stream()
|
||||
.flatMap(api -> api.getOperations().getOperation().stream())
|
||||
.collect(Collectors.toList());
|
||||
int maxPathLength = ops.stream()
|
||||
.mapToInt(op -> op.httpMethod.length() + op.path.length())
|
||||
|
@ -30,6 +30,8 @@ import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -313,13 +315,12 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
if (registerNonStandardStatusCodes) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, ArrayList<CodegenOperation>> opsMap = (Map<String, ArrayList<CodegenOperation>>) objs.get("operations");
|
||||
HashSet<Integer> unknownCodes = new HashSet<Integer>();
|
||||
for (CodegenOperation operation : opsMap.get("operation")) {
|
||||
OperationMap opsMap = objs.getOperations();
|
||||
HashSet<Integer> unknownCodes = new HashSet<>();
|
||||
for (CodegenOperation operation : opsMap.getOperation()) {
|
||||
for (CodegenResponse response : operation.responses) {
|
||||
if ("default".equals(response.code)) {
|
||||
continue;
|
||||
@ -352,13 +353,7 @@ public class ScalaSttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
}
|
||||
|
||||
// Remove OAuth securities
|
||||
Iterator<CodegenSecurity> it = codegenSecurities.iterator();
|
||||
while (it.hasNext()) {
|
||||
final CodegenSecurity security = it.next();
|
||||
if (security.isOAuth) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
codegenSecurities.removeIf(security -> security.isOAuth);
|
||||
if (codegenSecurities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@ -167,9 +169,9 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
// force http method to lower case
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
|
@ -62,6 +62,8 @@ import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.SplitStringLambda;
|
||||
import org.openapitools.codegen.templating.mustache.TrimWhitespaceLambda;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
@ -622,10 +624,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
final Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
final OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
final List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
final List<CodegenOperation> ops = operations.getOperation();
|
||||
for (final CodegenOperation operation : ops) {
|
||||
final List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
|
@ -29,6 +29,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.Markdown;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -142,9 +144,9 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
for (CodegenResponse response : op.responses) {
|
||||
|
@ -26,6 +26,8 @@ import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.Markdown;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
@ -125,9 +127,9 @@ public class StaticHtmlGenerator extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
for (CodegenResponse response : op.responses) {
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -1182,16 +1184,16 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap objectMap = objs.getOperations();
|
||||
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<String, CodegenModel>();
|
||||
HashMap<String, CodegenModel> modelMaps = new HashMap<>();
|
||||
for (ModelMap modelMap: allModels) {
|
||||
CodegenModel m = modelMap.getModel();
|
||||
modelMaps.put(m.classname, m);
|
||||
}
|
||||
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
List<CodegenOperation> operations = objectMap.getOperation();
|
||||
for (CodegenOperation operation : operations) {
|
||||
for (CodegenParameter cp : operation.allParams) {
|
||||
cp.vendorExtensions.put("x-swift-example", constructExampleCode(cp, modelMaps, new HashSet<>()));
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.SemVer;
|
||||
import org.slf4j.Logger;
|
||||
@ -385,13 +387,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
|
||||
// Add filename information for api imports
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.get("classname").toString()));
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.getClassname()));
|
||||
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
boolean hasSomeFormParams = false;
|
||||
for (CodegenOperation op : ops) {
|
||||
if (op.getHasFormParams()) {
|
||||
@ -446,8 +448,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
operations.put("hasSomeFormParams", hasSomeFormParams);
|
||||
|
||||
// Add additional filename information for model imports in the services
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
// This property is not used in the templates any more, subject for removal
|
||||
im.put("filename", im.get("import"));
|
||||
im.put("classname", im.get("classname"));
|
||||
|
@ -20,6 +20,8 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -84,12 +86,12 @@ public class TypeScriptAureliaClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
HashSet<String> modelImports = new HashSet<>();
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
for (CodegenOperation op : operationList) {
|
||||
// Aurelia uses "asGet", "asPost", ... methods; change the method format
|
||||
op.httpMethod = camelize(op.httpMethod.toLowerCase(Locale.ROOT));
|
||||
|
@ -24,6 +24,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.util.*;
|
||||
@ -145,10 +147,10 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
objs = super.postProcessOperationsWithModels(objs, allModels);
|
||||
Map<String, Object> vals = (Map<String, Object>) objs.getOrDefault("operations", new HashMap<>());
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) vals.getOrDefault("operation", new ArrayList<>());
|
||||
OperationMap vals = objs.getOperations();
|
||||
List<CodegenOperation> operations = vals.getOperation();
|
||||
/*
|
||||
Filter all the operations that are multipart/form-data operations and set the vendor extension flag
|
||||
'multipartFormData' for the template to work with.
|
||||
@ -156,9 +158,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
operations.stream()
|
||||
.filter(op -> op.hasConsumes)
|
||||
.filter(op -> op.consumes.stream().anyMatch(opc -> opc.values().stream().anyMatch("multipart/form-data"::equals)))
|
||||
.forEach(op -> {
|
||||
op.vendorExtensions.putIfAbsent("multipartFormData", true);
|
||||
});
|
||||
.forEach(op -> op.vendorExtensions.putIfAbsent("multipartFormData", true));
|
||||
return objs;
|
||||
}
|
||||
|
||||
@ -191,7 +191,6 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
List<ModelMap> models = postProcessModelsEnum(objs).getModels();
|
||||
|
||||
|
@ -35,6 +35,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -318,18 +320,17 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> models) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> models) {
|
||||
|
||||
// Add additional filename information for model imports in the apis
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
im.put("filename", ((String) im.get("import")).replace(".", "/"));
|
||||
im.put("classname", getModelnameFromModelFilename(im.get("import").toString()));
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
im.put("filename", im.get("import").replace(".", "/"));
|
||||
im.put("classname", getModelnameFromModelFilename(im.get("import")));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> operationsMap = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operationsMap.get("operation");
|
||||
OperationMap operationsMap = operations.getOperations();
|
||||
List<CodegenOperation> operationList = operationsMap.getOperation();
|
||||
for (CodegenOperation operation: operationList) {
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
operation.returnType = this.getReturnType(responses);
|
||||
|
@ -30,6 +30,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
@ -572,9 +574,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
// Add supporting file only if we plan to generate files in /apis
|
||||
if (operations.size() > 0 && !addedApiIndex) {
|
||||
if (!operations.isEmpty() && !addedApiIndex) {
|
||||
addedApiIndex = true;
|
||||
supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts"));
|
||||
if (this.getSagasAndRecords()) {
|
||||
@ -584,7 +586,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
|
||||
// Add supporting file only if we plan to generate files in /models
|
||||
if (allModels.size() > 0 && !addedModelIndex) {
|
||||
if (!allModels.isEmpty() && !addedModelIndex) {
|
||||
addedModelIndex = true;
|
||||
supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts"));
|
||||
}
|
||||
@ -763,10 +765,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
return var.items.isNullable || (var.items.items != null && var.items.items.isNullable);
|
||||
}
|
||||
|
||||
private void escapeOperationIds(Map<String, Object> operations) {
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
private void escapeOperationIds(OperationsMap operations) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
String param = op.operationIdCamelCase + "Request";
|
||||
if (op.imports.contains(param)) {
|
||||
// we import a model with the same name as the generated operation, escape it
|
||||
@ -777,26 +778,25 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
|
||||
private void addOperationModelImportInformation(Map<String, Object> operations) {
|
||||
private void addOperationModelImportInformation(OperationsMap operations) {
|
||||
// This method will add extra information to the operations.imports array.
|
||||
// The api template uses this information to import all the required
|
||||
// models for a given operation.
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
List<String> existingRecordClassNames = new ArrayList<String>();
|
||||
List<String> existingClassNames = new ArrayList<String>();
|
||||
for (Map<String, Object> im : imports) {
|
||||
String className = im.get("import").toString().replace(modelPackage() + ".", "");
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
List<String> existingRecordClassNames = new ArrayList<>();
|
||||
List<String> existingClassNames = new ArrayList<>();
|
||||
for (Map<String, String> im : imports) {
|
||||
String className = im.get("import").replace(modelPackage() + ".", "");
|
||||
existingClassNames.add(className);
|
||||
existingRecordClassNames.add(className + "Record");
|
||||
im.put("className", className);
|
||||
}
|
||||
|
||||
if (this.getSagasAndRecords()) {
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
Set<String> additionalPassthroughImports = new TreeSet<String>();
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
if (op.returnPassthrough != null && op.returnBaseTypeAlternate instanceof String) {
|
||||
Set<String> additionalPassthroughImports = new TreeSet<>();
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
if (op.returnPassthrough != null && op.returnBaseTypeAlternate != null) {
|
||||
if (op.returnTypeSupportsEntities && !existingRecordClassNames.contains(op.returnBaseTypeAlternate)) {
|
||||
additionalPassthroughImports.add(op.returnBaseTypeAlternate);
|
||||
} else if (!op.returnTypeSupportsEntities && !existingClassNames.contains(op.returnBaseTypeAlternate)) {
|
||||
@ -809,14 +809,13 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOperationParameterForEnum(Map<String, Object> operations) {
|
||||
private void updateOperationParameterForEnum(OperationsMap operations) {
|
||||
// This method will add extra information as to whether or not we have enums and
|
||||
// update their names with the operation.id prefixed.
|
||||
// It will also set the uniqueId status if provided.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
boolean hasEnum = false;
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
for (CodegenParameter cpParam : op.allParams) {
|
||||
ExtendedCodegenParameter param = (ExtendedCodegenParameter) cpParam;
|
||||
|
||||
@ -831,13 +830,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
operations.put("hasEnums", hasEnum);
|
||||
}
|
||||
|
||||
private void updateOperationParameterForSagaAndRecords(Map<String, Object> operations) {
|
||||
private void updateOperationParameterForSagaAndRecords(OperationsMap operations) {
|
||||
// This method will add extra information as to whether or not we have enums and
|
||||
// update their names with the operation.id prefixed.
|
||||
// It will also set the uniqueId status if provided.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
for (CodegenParameter cpParam : op.allParams) {
|
||||
ExtendedCodegenParameter param = (ExtendedCodegenParameter) cpParam;
|
||||
|
||||
@ -881,13 +879,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
}
|
||||
|
||||
private void addOperationObjectResponseInformation(Map<String, Object> operations) {
|
||||
private void addOperationObjectResponseInformation(OperationsMap operations) {
|
||||
// This method will modify the information on the operations' return type.
|
||||
// The api template uses this information to know when to return a text
|
||||
// response for a given simple response operation.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
if ("object".equals(op.returnType)) {
|
||||
op.isMap = true;
|
||||
op.returnSimpleType = false;
|
||||
@ -896,7 +893,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
}
|
||||
|
||||
private void addOperationPrefixParameterInterfacesInformation(Map<String, Object> operations) {
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
operations.put("prefixParameterInterfaces", getPrefixParameterInterfaces());
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@ -197,13 +199,13 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
|
||||
// Add filename information for api imports
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.get("classname").toString()));
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.getClassname()));
|
||||
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
for (CodegenOperation op : ops) {
|
||||
// Prep a string buffer where we're going to set up our new version of the string.
|
||||
StringBuilder pathBuffer = new StringBuilder();
|
||||
@ -246,10 +248,10 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
|
||||
}
|
||||
|
||||
// Add additional filename information for model imports in the services
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
im.put("filename", im.get("import"));
|
||||
im.put("classname", getModelnameFromModelFilename(im.get("filename").toString()));
|
||||
im.put("classname", getModelnameFromModelFilename(im.get("filename")));
|
||||
}
|
||||
|
||||
return operations;
|
||||
|
@ -22,6 +22,8 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.SemVer;
|
||||
import org.slf4j.Logger;
|
||||
@ -267,13 +269,13 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
|
||||
// Add filename information for api imports
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.get("classname").toString()));
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.getClassname()));
|
||||
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
List<CodegenOperation> ops = objs.getOperation();
|
||||
boolean hasSomeFormParams = false;
|
||||
for (CodegenOperation op : ops) {
|
||||
if (op.getHasFormParams()) {
|
||||
@ -327,8 +329,8 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
|
||||
operations.put("hasSomeFormParams", hasSomeFormParams);
|
||||
|
||||
// Add additional filename information for model imports in the services
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
im.put("filename", im.get("import"));
|
||||
im.put("classname", im.get("classname"));
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -198,13 +200,13 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
OperationMap objs = operations.getOperations();
|
||||
|
||||
// The api.mustache template requires all of the auth methods for the whole api
|
||||
// Loop over all the operations and pick out each unique auth method
|
||||
Map<String, CodegenSecurity> authMethodsMap = new HashMap<>();
|
||||
for (CodegenOperation op : (List<CodegenOperation>) objs.get("operation")) {
|
||||
for (CodegenOperation op : objs.getOperation()) {
|
||||
if (op.hasAuthMethods) {
|
||||
for (CodegenSecurity sec : op.authMethods) {
|
||||
authMethodsMap.put(sec.name, sec);
|
||||
@ -219,12 +221,12 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
}
|
||||
|
||||
// Add filename information for api imports
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.get("classname").toString()));
|
||||
objs.put("apiFilename", getApiFilenameFromClassname(objs.getClassname()));
|
||||
|
||||
// Add additional filename information for model imports in the apis
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
im.put("filename", im.get("import").toString());
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
im.put("filename", im.get("import"));
|
||||
}
|
||||
|
||||
return operations;
|
||||
|
@ -22,6 +22,7 @@ import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -185,15 +186,15 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
// Add supporting file only if we plan to generate files in /apis
|
||||
if (operations.size() > 0 && !addedApiIndex) {
|
||||
if (!operations.isEmpty() && !addedApiIndex) {
|
||||
addedApiIndex = true;
|
||||
supportingFiles.add(new SupportingFile("apis.index.mustache", apiPackage().replace('.', File.separatorChar), "index.ts"));
|
||||
}
|
||||
|
||||
// Add supporting file only if we plan to generate files in /models
|
||||
if (allModels.size() > 0 && !addedModelIndex) {
|
||||
if (!allModels.isEmpty() && !addedModelIndex) {
|
||||
addedModelIndex = true;
|
||||
supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts"));
|
||||
}
|
||||
@ -204,13 +205,13 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC
|
||||
return operations;
|
||||
}
|
||||
|
||||
private void addOperationModelImportInformation(Map<String, Object> operations) {
|
||||
private void addOperationModelImportInformation(OperationsMap operations) {
|
||||
// This method will add extra information to the operations.imports array.
|
||||
// The api template uses this information to import all the required
|
||||
// models for a given operation.
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
String[] parts = im.get("import").toString().replace(modelPackage() + ".", "").split("( [|&] )|[<>]");
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
String[] parts = im.get("import").replace(modelPackage() + ".", "").split("( [|&] )|[<>]");
|
||||
for (String s : parts) {
|
||||
if (needToImport(s)) {
|
||||
im.put("filename", im.get("import"));
|
||||
@ -220,13 +221,11 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOperationParameterEnumInformation(Map<String, Object> operations) {
|
||||
private void updateOperationParameterEnumInformation(OperationsMap operations) {
|
||||
// This method will add extra information as to whether or not we have enums and
|
||||
// update their names with the operation.id prefixed.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
|
||||
boolean hasEnum = false;
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenOperation op : operations.getOperations().getOperation()) {
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
if (Boolean.TRUE.equals(param.isEnum)) {
|
||||
hasEnum = true;
|
||||
@ -239,13 +238,11 @@ public class TypeScriptReduxQueryClientCodegen extends AbstractTypeScriptClientC
|
||||
operations.put("hasEnums", hasEnum);
|
||||
}
|
||||
|
||||
private void addOperationObjectResponseInformation(Map<String, Object> operations) {
|
||||
private void addOperationObjectResponseInformation(OperationsMap operations) {
|
||||
// This method will modify the information on the operations' return type.
|
||||
// The api template uses this information to know when to return a text
|
||||
// response for a given simple response operation.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
for (CodegenOperation op : operations.getOperations().getOperation()) {
|
||||
if("object".equals(op.returnType)) {
|
||||
op.isMap = true;
|
||||
op.returnSimpleType = false;
|
||||
|
@ -23,6 +23,7 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -196,15 +197,14 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<ModelMap> allModels) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap operations, List<ModelMap> allModels) {
|
||||
// Convert List of CodegenOperation to List of ExtendedCodegenOperation
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) _operations.get("operation");
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<ExtendedCodegenOperation>();
|
||||
List<CodegenOperation> os = operations.getOperations().getOperation();
|
||||
List<ExtendedCodegenOperation> newOs = new ArrayList<>();
|
||||
for (CodegenOperation o : os) {
|
||||
newOs.add(new ExtendedCodegenOperation(o));
|
||||
}
|
||||
_operations.put("operation", newOs);
|
||||
operations.getOperations().setOperation(newOs);
|
||||
|
||||
this.addOperationModelImportInformation(operations);
|
||||
this.updateOperationParameterEnumInformation(operations);
|
||||
@ -213,23 +213,22 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
return operations;
|
||||
}
|
||||
|
||||
private void addOperationModelImportInformation(Map<String, Object> operations) {
|
||||
private void addOperationModelImportInformation(OperationsMap operations) {
|
||||
// This method will add extra information to the operations.imports array.
|
||||
// The api template uses this information to import all the required
|
||||
// models for a given operation.
|
||||
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
|
||||
for (Map<String, Object> im : imports) {
|
||||
im.put("className", im.get("import").toString().replace("models.", ""));
|
||||
List<Map<String, String>> imports = operations.getImports();
|
||||
for (Map<String, String> im : imports) {
|
||||
im.put("className", im.get("import").replace("models.", ""));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOperationParameterEnumInformation(Map<String, Object> operations) {
|
||||
private void updateOperationParameterEnumInformation(OperationsMap operations) {
|
||||
// This method will add extra information as to whether or not we have enums and
|
||||
// update their names with the operation.id prefixed.
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
boolean hasEnums = false;
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
if (Boolean.TRUE.equals(param.isEnum)) {
|
||||
hasEnums = true;
|
||||
@ -249,10 +248,8 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
}
|
||||
}
|
||||
|
||||
private void addConditionalImportInformation(Map<String, Object> operations) {
|
||||
private void addConditionalImportInformation(OperationsMap operations) {
|
||||
// This method will determine if there are required parameters and if there are list containers
|
||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||
List<ExtendedCodegenOperation> operationList = (List<ExtendedCodegenOperation>) _operations.get("operation");
|
||||
|
||||
boolean hasRequiredParams = false;
|
||||
boolean hasListContainers = false;
|
||||
@ -260,7 +257,8 @@ public class TypeScriptRxjsClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
boolean hasQueryParams = false;
|
||||
boolean hasPathParams = false;
|
||||
|
||||
for (ExtendedCodegenOperation op : operationList) {
|
||||
for (CodegenOperation _op : operations.getOperations().getOperation()) {
|
||||
ExtendedCodegenOperation op = (ExtendedCodegenOperation) _op;
|
||||
if (op.getHasRequiredParams()) {
|
||||
hasRequiredParams = true;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.Normalizer;
|
||||
@ -94,12 +95,8 @@ public class WsdlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs,
|
||||
List<ModelMap> allModels) {
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
for (CodegenOperation op : objs.getOperations().getOperation()) {
|
||||
op.operationId = this.generateOperationId(op);
|
||||
|
||||
// for xml compliant primitives, lowercase dataType of openapi
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.openapitools.codegen.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiInfoMap extends HashMap<String, Object> {
|
||||
|
||||
public void setApis(List<OperationsMap> apis) {
|
||||
put("apis", apis);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<OperationsMap> getApis() {
|
||||
return (List<OperationsMap>) get("apis");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package org.openapitools.codegen.model;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
|
||||
public class OperationMap extends HashMap<String, Object> {
|
||||
|
||||
public void setOperation(CodegenOperation ops) {
|
||||
put("operation", Collections.singletonList(ops));
|
||||
}
|
||||
|
||||
public void setOperation(List<? extends CodegenOperation> ops) {
|
||||
put("operation", ops);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<CodegenOperation> getOperation() {
|
||||
return (List<CodegenOperation>) get("operation");
|
||||
}
|
||||
|
||||
public void setClassname(String classname) {
|
||||
put("classname", classname);
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return (String) get("classname");
|
||||
}
|
||||
|
||||
public void setPathPrefix(String pathPrefix) {
|
||||
put("pathPrefix", pathPrefix);
|
||||
}
|
||||
|
||||
public String getPathPrefix() {
|
||||
return (String) get("pathPrefix");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package org.openapitools.codegen.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
|
||||
public class OperationsMap extends HashMap<String, Object> {
|
||||
|
||||
public void setOperation(OperationMap objs) {
|
||||
put("operations", objs);
|
||||
}
|
||||
|
||||
public OperationMap getOperations() {
|
||||
return (OperationMap) get("operations");
|
||||
}
|
||||
|
||||
public void setImports(List<Map<String, String>> imports) {
|
||||
put("imports", imports);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Map<String, String>> getImports() {
|
||||
return (List<Map<String, String>>) get("imports");
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user