forked from loafle/openapi-generator-original
Optimize: entrySet is faster than keySet + get to prevent N lookups (#10496)
* Optimize: replace keySet + N get calls with entrySet saving N calls to get method in a few places * missed one performance optimization * Rolling back a change that was dependent on Java 11
This commit is contained in:
parent
768c76ea33
commit
10b310d33f
@ -721,8 +721,9 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
getLog().warn("environmentVariables is deprecated and will be removed in version 5.1. Use globalProperties instead.");
|
getLog().warn("environmentVariables is deprecated and will be removed in version 5.1. Use globalProperties instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : globalProperties.keySet()) {
|
for (Map.Entry<String, String> globalPropertiesEntry : globalProperties.entrySet()) {
|
||||||
String value = globalProperties.get(key);
|
String key = globalPropertiesEntry.getKey();
|
||||||
|
String value = globalPropertiesEntry.getValue();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
configurator.addGlobalProperty(key, value);
|
configurator.addGlobalProperty(key, value);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -541,8 +542,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let parent know about all its children
|
// Let parent know about all its children
|
||||||
for (String name : allModels.keySet()) {
|
for (Map.Entry<String, CodegenModel> allModelsEntry : allModels.entrySet()) {
|
||||||
CodegenModel cm = allModels.get(name);
|
String name = allModelsEntry.getKey();
|
||||||
|
CodegenModel cm = allModelsEntry.getValue();
|
||||||
CodegenModel parent = allModels.get(cm.getParent());
|
CodegenModel parent = allModels.get(cm.getParent());
|
||||||
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
|
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
|
||||||
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
|
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
|
||||||
@ -3950,8 +3952,9 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||||
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
|
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
|
||||||
for (String key : operation.getResponses().keySet()) {
|
for (Map.Entry<String, ApiResponse> operationGetResponsesEntry : operation.getResponses().entrySet()) {
|
||||||
ApiResponse response = operation.getResponses().get(key);
|
String key = operationGetResponsesEntry.getKey();
|
||||||
|
ApiResponse response = operationGetResponsesEntry.getValue();
|
||||||
addProducesInfo(response, op);
|
addProducesInfo(response, op);
|
||||||
CodegenResponse r = fromResponse(key, response);
|
CodegenResponse r = fromResponse(key, response);
|
||||||
if (r.baseType != null &&
|
if (r.baseType != null &&
|
||||||
@ -5110,14 +5113,14 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loop through list to update property name with toVarName
|
// loop through list to update property name with toVarName
|
||||||
Set<String> renamedMandatory = new TreeSet<String>();
|
Set<String> renamedMandatory = new ConcurrentSkipListSet<String>();
|
||||||
Iterator<String> mandatoryIterator = m.mandatory.iterator();
|
Iterator<String> mandatoryIterator = m.mandatory.iterator();
|
||||||
while (mandatoryIterator.hasNext()) {
|
while (mandatoryIterator.hasNext()) {
|
||||||
renamedMandatory.add(toVarName(mandatoryIterator.next()));
|
renamedMandatory.add(toVarName(mandatoryIterator.next()));
|
||||||
}
|
}
|
||||||
m.mandatory = renamedMandatory;
|
m.mandatory = renamedMandatory;
|
||||||
|
|
||||||
Set<String> renamedAllMandatory = new TreeSet<String>();
|
Set<String> renamedAllMandatory = new ConcurrentSkipListSet<String>();
|
||||||
Iterator<String> allMandatoryIterator = m.allMandatory.iterator();
|
Iterator<String> allMandatoryIterator = m.allMandatory.iterator();
|
||||||
while (allMandatoryIterator.hasNext()) {
|
while (allMandatoryIterator.hasNext()) {
|
||||||
renamedAllMandatory.add(toVarName(allMandatoryIterator.next()));
|
renamedAllMandatory.add(toVarName(allMandatoryIterator.next()));
|
||||||
@ -6059,7 +6062,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> produces = new TreeSet<String>();
|
Set<String> produces = new ConcurrentSkipListSet<String>();
|
||||||
|
|
||||||
for (ApiResponse r : operation.getResponses().values()) {
|
for (ApiResponse r : operation.getResponses().values()) {
|
||||||
ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, r);
|
ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, r);
|
||||||
|
@ -62,6 +62,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -335,8 +336,9 @@ public class DefaultGenerator implements Generator {
|
|||||||
|
|
||||||
private void generateModelTests(List<File> files, Map<String, Object> models, String modelName) throws IOException {
|
private void generateModelTests(List<File> files, Map<String, Object> models, String modelName) throws IOException {
|
||||||
// to generate model test files
|
// to generate model test files
|
||||||
for (String templateName : config.modelTestTemplateFiles().keySet()) {
|
for (Map.Entry<String, String> configModelTestTemplateFilesEntry : config.modelTestTemplateFiles().entrySet()) {
|
||||||
String suffix = config.modelTestTemplateFiles().get(templateName);
|
String templateName = configModelTestTemplateFilesEntry.getKey();
|
||||||
|
String suffix = configModelTestTemplateFilesEntry.getValue();
|
||||||
String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(modelName) + suffix;
|
String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(modelName) + suffix;
|
||||||
|
|
||||||
if (generateModelTests) {
|
if (generateModelTests) {
|
||||||
@ -1055,8 +1057,9 @@ public class DefaultGenerator implements Generator {
|
|||||||
if(paths == null) {
|
if(paths == null) {
|
||||||
return ops;
|
return ops;
|
||||||
}
|
}
|
||||||
for (String resourcePath : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(resourcePath);
|
String resourcePath = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
processOperation(resourcePath, "get", path.getGet(), ops, path);
|
processOperation(resourcePath, "get", path.getGet(), ops, path);
|
||||||
processOperation(resourcePath, "head", path.getHead(), ops, path);
|
processOperation(resourcePath, "head", path.getHead(), ops, path);
|
||||||
processOperation(resourcePath, "put", path.getPut(), ops, path);
|
processOperation(resourcePath, "put", path.getPut(), ops, path);
|
||||||
@ -1199,7 +1202,7 @@ public class DefaultGenerator implements Generator {
|
|||||||
operations.put("operations", objs);
|
operations.put("operations", objs);
|
||||||
operations.put("package", config.apiPackage());
|
operations.put("package", config.apiPackage());
|
||||||
|
|
||||||
Set<String> allImports = new TreeSet<>();
|
Set<String> allImports = new ConcurrentSkipListSet<>();
|
||||||
for (CodegenOperation op : ops) {
|
for (CodegenOperation op : ops) {
|
||||||
allImports.addAll(op.imports);
|
allImports.addAll(op.imports);
|
||||||
}
|
}
|
||||||
@ -1267,8 +1270,9 @@ public class DefaultGenerator implements Generator {
|
|||||||
objs.put("package", config.modelPackage());
|
objs.put("package", config.modelPackage());
|
||||||
List<Object> models = new ArrayList<>();
|
List<Object> models = new ArrayList<>();
|
||||||
Set<String> allImports = new LinkedHashSet<>();
|
Set<String> allImports = new LinkedHashSet<>();
|
||||||
for (String key : definitions.keySet()) {
|
for (Map.Entry<String, Schema> definitionsEntry : definitions.entrySet()) {
|
||||||
Schema schema = definitions.get(key);
|
String key = definitionsEntry.getKey();
|
||||||
|
Schema schema = definitionsEntry.getValue();
|
||||||
if (schema == null)
|
if (schema == null)
|
||||||
throw new RuntimeException("schema cannot be null in processModels");
|
throw new RuntimeException("schema cannot be null in processModels");
|
||||||
CodegenModel cm = config.fromModel(key, schema);
|
CodegenModel cm = config.fromModel(key, schema);
|
||||||
@ -1282,7 +1286,7 @@ public class DefaultGenerator implements Generator {
|
|||||||
allImports.addAll(cm.imports);
|
allImports.addAll(cm.imports);
|
||||||
}
|
}
|
||||||
objs.put("models", models);
|
objs.put("models", models);
|
||||||
Set<String> importSet = new TreeSet<>();
|
Set<String> importSet = new ConcurrentSkipListSet<>();
|
||||||
for (String nextImport : allImports) {
|
for (String nextImport : allImports) {
|
||||||
String mapping = config.importMapping().get(nextImport);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
if (mapping == null) {
|
if (mapping == null) {
|
||||||
|
@ -79,8 +79,9 @@ public class InlineModelResolver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String pathname : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
String pathname = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
List<Operation> operations = new ArrayList<>(path.readOperations());
|
List<Operation> operations = new ArrayList<>(path.readOperations());
|
||||||
|
|
||||||
// Include callback operation as well
|
// Include callback operation as well
|
||||||
@ -263,8 +264,9 @@ public class InlineModelResolver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : responses.keySet()) {
|
for (Map.Entry<String, ApiResponse> responsesEntry : responses.entrySet()) {
|
||||||
ApiResponse response = responses.get(key);
|
String key = responsesEntry.getKey();
|
||||||
|
ApiResponse response = responsesEntry.getValue();
|
||||||
if (ModelUtils.getSchemaFromResponse(response) == null) {
|
if (ModelUtils.getSchemaFromResponse(response) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -561,8 +563,9 @@ public class InlineModelResolver {
|
|||||||
}
|
}
|
||||||
Map<String, Schema> propsToUpdate = new HashMap<String, Schema>();
|
Map<String, Schema> propsToUpdate = new HashMap<String, Schema>();
|
||||||
Map<String, Schema> modelsToAdd = new HashMap<String, Schema>();
|
Map<String, Schema> modelsToAdd = new HashMap<String, Schema>();
|
||||||
for (String key : properties.keySet()) {
|
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
|
||||||
Schema property = properties.get(key);
|
String key = propertiesEntry.getKey();
|
||||||
|
Schema property = propertiesEntry.getValue();
|
||||||
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
|
if (property instanceof ObjectSchema && ((ObjectSchema) property).getProperties() != null
|
||||||
&& ((ObjectSchema) property).getProperties().size() > 0) {
|
&& ((ObjectSchema) property).getProperties().size() > 0) {
|
||||||
ObjectSchema op = (ObjectSchema) property;
|
ObjectSchema op = (ObjectSchema) property;
|
||||||
|
@ -81,8 +81,9 @@ public class XmlExampleGenerator {
|
|||||||
// TODO: map objects will not enter this block
|
// TODO: map objects will not enter this block
|
||||||
Map<String, Schema> properties = schema.getProperties();
|
Map<String, Schema> properties = schema.getProperties();
|
||||||
if (properties != null && !properties.isEmpty()) {
|
if (properties != null && !properties.isEmpty()) {
|
||||||
for (String pName : properties.keySet()) {
|
for (Map.Entry<String, Schema> propertiesEntry : properties.entrySet()) {
|
||||||
Schema property = properties.get(pName);
|
String pName = propertiesEntry.getKey();
|
||||||
|
Schema property = propertiesEntry.getValue();
|
||||||
if (property != null && property.getXml() != null && property.getXml().getAttribute() != null && property.getXml().getAttribute()) {
|
if (property != null && property.getXml() != null && property.getXml().getAttribute() != null && property.getXml().getAttribute()) {
|
||||||
attributes.put(pName, property);
|
attributes.put(pName, property);
|
||||||
} else {
|
} else {
|
||||||
@ -93,14 +94,16 @@ public class XmlExampleGenerator {
|
|||||||
|
|
||||||
sb.append(indent(indent)).append(TAG_START);
|
sb.append(indent(indent)).append(TAG_START);
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
for (String pName : attributes.keySet()) {
|
for (Map.Entry<String, Schema> attributesEntry : attributes.entrySet()) {
|
||||||
Schema s = attributes.get(pName);
|
String pName = attributesEntry.getKey();
|
||||||
|
Schema s = attributesEntry.getValue();
|
||||||
sb.append(" ").append(pName).append("=").append(quote(toXml(null, s, 0, selfPath)));
|
sb.append(" ").append(pName).append("=").append(quote(toXml(null, s, 0, selfPath)));
|
||||||
}
|
}
|
||||||
sb.append(CLOSE_TAG);
|
sb.append(CLOSE_TAG);
|
||||||
sb.append(NEWLINE);
|
sb.append(NEWLINE);
|
||||||
for (String pName : elements.keySet()) {
|
for (Map.Entry<String, Schema> elementsEntry : elements.entrySet()) {
|
||||||
Schema s = elements.get(pName);
|
String pName = elementsEntry.getKey();
|
||||||
|
Schema s = elementsEntry.getValue();
|
||||||
final String asXml = toXml(pName, s, indent + 1, selfPath);
|
final String asXml = toXml(pName, s, indent + 1, selfPath);
|
||||||
if (StringUtils.isEmpty(asXml)) {
|
if (StringUtils.isEmpty(asXml)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -40,6 +40,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -1338,7 +1339,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
Collection<String> operationImports = new TreeSet<String>();
|
Collection<String> operationImports = new ConcurrentSkipListSet<String>();
|
||||||
for (CodegenParameter p : op.allParams) {
|
for (CodegenParameter p : op.allParams) {
|
||||||
if (importMapping.containsKey(p.dataType)) {
|
if (importMapping.containsKey(p.dataType)) {
|
||||||
operationImports.add(importMapping.get(p.dataType));
|
operationImports.add(importMapping.get(p.dataType));
|
||||||
@ -1356,8 +1357,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (openAPI.getPaths() != null) {
|
if (openAPI.getPaths() != null) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() == null) {
|
if (path.readOperations() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -142,8 +142,9 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openAPI.getPaths() != null) {
|
if (openAPI.getPaths() != null) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() != null) {
|
if (path.readOperations() != null) {
|
||||||
for (Operation operation : path.readOperations()) {
|
for (Operation operation : path.readOperations()) {
|
||||||
if (operation.getTags() != null) {
|
if (operation.getTags() != null) {
|
||||||
|
@ -332,7 +332,7 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
PathItem path = paths.get(pathname);
|
PathItem path = paths.get(pathname);
|
||||||
// Fix path parameters to be in snake_case
|
// Fix path parameters to be in snake_case
|
||||||
if (pathname.contains("{")) {
|
if (pathname.contains("{")) {
|
||||||
String fixedPath = new String();
|
String fixedPath = "";
|
||||||
for (String token : pathname.substring(1).split("/")) {
|
for (String token : pathname.substring(1).split("/")) {
|
||||||
if (token.startsWith("{")) {
|
if (token.startsWith("{")) {
|
||||||
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length() - 1)) + "}";
|
String snake_case_token = "{" + this.toParamName(token.substring(1, token.length() - 1)) + "}";
|
||||||
@ -353,8 +353,9 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
}
|
}
|
||||||
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
if (operationMap != null) {
|
if (operationMap != null) {
|
||||||
for (HttpMethod method : operationMap.keySet()) {
|
for (Map.Entry<HttpMethod, Operation> operationMapEntry : operationMap.entrySet()) {
|
||||||
Operation operation = operationMap.get(method);
|
HttpMethod method = operationMapEntry.getKey();
|
||||||
|
Operation operation = operationMapEntry.getValue();
|
||||||
String tag = "default";
|
String tag = "default";
|
||||||
if (operation.getTags() != null && operation.getTags().size() > 0) {
|
if (operation.getTags() != null && operation.getTags().size() > 0) {
|
||||||
tag = operation.getTags().get(0);
|
tag = operation.getTags().get(0);
|
||||||
@ -424,8 +425,9 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
Components components = openAPI.getComponents();
|
Components components = openAPI.getComponents();
|
||||||
if (components != null && components.getSecuritySchemes() != null) {
|
if (components != null && components.getSecuritySchemes() != null) {
|
||||||
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
|
Map<String, SecurityScheme> securitySchemes = components.getSecuritySchemes();
|
||||||
for (String securityName : securitySchemes.keySet()) {
|
for (Map.Entry<String, SecurityScheme> securitySchemesEntry : securitySchemes.entrySet()) {
|
||||||
SecurityScheme securityScheme = securitySchemes.get(securityName);
|
String securityName = securitySchemesEntry.getKey();
|
||||||
|
SecurityScheme securityScheme = securitySchemesEntry.getValue();
|
||||||
String baseFunctionName = controllerPackage + ".security_controller_.";
|
String baseFunctionName = controllerPackage + ".security_controller_.";
|
||||||
switch (securityScheme.getType()) {
|
switch (securityScheme.getType()) {
|
||||||
case APIKEY:
|
case APIKEY:
|
||||||
@ -512,8 +514,9 @@ public abstract class AbstractPythonConnexionServerCodegen extends AbstractPytho
|
|||||||
|
|
||||||
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
if (operationMap != null) {
|
if (operationMap != null) {
|
||||||
for (HttpMethod method : operationMap.keySet()) {
|
for (Map.Entry<HttpMethod, Operation> operationMapEntry : operationMap.entrySet()) {
|
||||||
Operation operation = operationMap.get(method);
|
HttpMethod method = operationMapEntry.getKey();
|
||||||
|
Operation operation = operationMapEntry.getValue();
|
||||||
if (operation.getParameters() != null) {
|
if (operation.getParameters() != null) {
|
||||||
for (Parameter parameter : operation.getParameters()) {
|
for (Parameter parameter : operation.getParameters()) {
|
||||||
Map<String, Object> parameterExtensions = parameter.getExtensions();
|
Map<String, Object> parameterExtensions = parameter.getExtensions();
|
||||||
|
@ -32,6 +32,7 @@ import java.io.File;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig {
|
public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
|
||||||
@ -149,8 +150,9 @@ public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
if (openAPI != null && openAPI.getPaths() != null) {
|
if (openAPI != null && openAPI.getPaths() != null) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() != null) {
|
if (path.readOperations() != null) {
|
||||||
for (Operation operation : path.readOperations()) {
|
for (Operation operation : path.readOperations()) {
|
||||||
String pathWithDollars = pathname.replaceAll("\\{", "\\$\\{");
|
String pathWithDollars = pathname.replaceAll("\\{", "\\$\\{");
|
||||||
|
@ -543,8 +543,9 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
|||||||
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
this.additionalProperties.put("serverPort", URLPathUtils.getPort(url, 8080));
|
||||||
|
|
||||||
if (openAPI.getPaths() != null) {
|
if (openAPI.getPaths() != null) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() != null) {
|
if (path.readOperations() != null) {
|
||||||
for (Operation operation : path.readOperations()) {
|
for (Operation operation : path.readOperations()) {
|
||||||
if (operation.getTags() != null) {
|
if (operation.getTags() != null) {
|
||||||
|
@ -360,12 +360,14 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
|
|||||||
// need vendor extensions
|
// need vendor extensions
|
||||||
Paths paths = openAPI.getPaths();
|
Paths paths = openAPI.getPaths();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (String pathname : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
String pathname = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
if (operationMap != null) {
|
if (operationMap != null) {
|
||||||
for (HttpMethod method : operationMap.keySet()) {
|
for (Map.Entry<HttpMethod, Operation> operationMapEntry : operationMap.entrySet()) {
|
||||||
Operation operation = operationMap.get(method);
|
HttpMethod method = operationMapEntry.getKey();
|
||||||
|
Operation operation = operationMapEntry.getValue();
|
||||||
String tag = "default";
|
String tag = "default";
|
||||||
if (operation.getTags() != null && operation.getTags().size() > 0) {
|
if (operation.getTags() != null && operation.getTags().size() > 0) {
|
||||||
tag = toApiName(operation.getTags().get(0));
|
tag = toApiName(operation.getTags().get(0));
|
||||||
|
@ -300,8 +300,9 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void collectEnumSchemas(String parentName, Map<String, Schema> schemas) {
|
private void collectEnumSchemas(String parentName, Map<String, Schema> schemas) {
|
||||||
for (String sName : schemas.keySet()) {
|
for (Map.Entry<String, Schema> schemasEntry : schemas.entrySet()) {
|
||||||
Schema schema = schemas.get(sName);
|
String sName = schemasEntry.getKey();
|
||||||
|
Schema schema = schemasEntry.getValue();
|
||||||
|
|
||||||
collectEnumSchemas(parentName, sName, schema);
|
collectEnumSchemas(parentName, sName, schema);
|
||||||
|
|
||||||
@ -339,8 +340,9 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (operation.getResponses() != null) {
|
if (operation.getResponses() != null) {
|
||||||
for (String s : operation.getResponses().keySet()) {
|
for (Map.Entry<String, ApiResponse> operationGetResponsesEntry : operation.getResponses().entrySet()) {
|
||||||
ApiResponse apiResponse = operation.getResponses().get(s);
|
String s = operationGetResponsesEntry.getKey();
|
||||||
|
ApiResponse apiResponse = operationGetResponsesEntry.getValue();
|
||||||
if (apiResponse.getContent() != null) {
|
if (apiResponse.getContent() != null) {
|
||||||
Content content = apiResponse.getContent();
|
Content content = apiResponse.getContent();
|
||||||
for (String p : content.keySet()) {
|
for (String p : content.keySet()) {
|
||||||
@ -349,8 +351,9 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
if (apiResponse.getHeaders() != null) {
|
if (apiResponse.getHeaders() != null) {
|
||||||
Map<String, Header> headers = apiResponse.getHeaders();
|
Map<String, Header> headers = apiResponse.getHeaders();
|
||||||
for (String h : headers.keySet()) {
|
for (Map.Entry<String, Header> headersEntry : headers.entrySet()) {
|
||||||
Header header = headers.get(h);
|
String h = headersEntry.getKey();
|
||||||
|
Header header = headersEntry.getValue();
|
||||||
collectEnumSchemas(h, header.getSchema());
|
collectEnumSchemas(h, header.getSchema());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,8 +407,9 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
Paths paths = openAPI.getPaths();
|
Paths paths = openAPI.getPaths();
|
||||||
if (paths != null && !paths.isEmpty()) {
|
if (paths != null && !paths.isEmpty()) {
|
||||||
for (String path : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem item = paths.get(path);
|
String path = pathsEntry.getKey();
|
||||||
|
PathItem item = pathsEntry.getValue();
|
||||||
collectEnumSchemas(item.getGet());
|
collectEnumSchemas(item.getGet());
|
||||||
collectEnumSchemas(item.getPost());
|
collectEnumSchemas(item.getPost());
|
||||||
collectEnumSchemas(item.getPut());
|
collectEnumSchemas(item.getPut());
|
||||||
|
@ -201,12 +201,14 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
|||||||
protected void generateParameterSchemas(OpenAPI openAPI) {
|
protected void generateParameterSchemas(OpenAPI openAPI) {
|
||||||
Map<String, PathItem> paths = openAPI.getPaths();
|
Map<String, PathItem> paths = openAPI.getPaths();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (String pathname : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
String pathname = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
if (operationMap != null) {
|
if (operationMap != null) {
|
||||||
for (HttpMethod method : operationMap.keySet()) {
|
for (Map.Entry<HttpMethod, Operation> operationMapEntry : operationMap.entrySet()) {
|
||||||
Operation operation = operationMap.get(method);
|
HttpMethod method = operationMapEntry.getKey();
|
||||||
|
Operation operation = operationMapEntry.getValue();
|
||||||
Map<String, Schema> propertySchemas = new HashMap<>();
|
Map<String, Schema> propertySchemas = new HashMap<>();
|
||||||
if (operation == null || operation.getParameters() == null) {
|
if (operation == null || operation.getParameters() == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -424,8 +426,9 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
|||||||
protected void quoteMediaTypes(OpenAPI openAPI) {
|
protected void quoteMediaTypes(OpenAPI openAPI) {
|
||||||
Map<String, PathItem> paths = openAPI.getPaths();
|
Map<String, PathItem> paths = openAPI.getPaths();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (String pathname : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
String pathname = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
List<Operation> operations = path.readOperations();
|
List<Operation> operations = path.readOperations();
|
||||||
if (operations != null) {
|
if (operations != null) {
|
||||||
for (Operation operation : operations) {
|
for (Operation operation : operations) {
|
||||||
|
@ -197,12 +197,14 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
|
|||||||
protected void generateParameterSchemas(OpenAPI openAPI) {
|
protected void generateParameterSchemas(OpenAPI openAPI) {
|
||||||
Map<String, PathItem> paths = openAPI.getPaths();
|
Map<String, PathItem> paths = openAPI.getPaths();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (String pathname : paths.keySet()) {
|
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||||
PathItem path = paths.get(pathname);
|
String pathname = pathsEntry.getKey();
|
||||||
|
PathItem path = pathsEntry.getValue();
|
||||||
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
Map<HttpMethod, Operation> operationMap = path.readOperationsMap();
|
||||||
if (operationMap != null) {
|
if (operationMap != null) {
|
||||||
for (HttpMethod method : operationMap.keySet()) {
|
for (Map.Entry<HttpMethod, Operation> operationMapEntry : operationMap.entrySet()) {
|
||||||
Operation operation = operationMap.get(method);
|
HttpMethod method = operationMapEntry.getKey();
|
||||||
|
Operation operation = operationMapEntry.getValue();
|
||||||
Map<String, Schema> propertySchemas = new HashMap<>();
|
Map<String, Schema> propertySchemas = new HashMap<>();
|
||||||
if (operation == null || operation.getParameters() == null) {
|
if (operation == null || operation.getParameters() == null) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -251,8 +251,9 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() == null) {
|
if (path.readOperations() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -556,8 +556,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openAPI.getPaths() != null) {
|
if (openAPI.getPaths() != null) {
|
||||||
for (String pathname : openAPI.getPaths().keySet()) {
|
for (Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
|
||||||
PathItem path = openAPI.getPaths().get(pathname);
|
String pathname = openAPIGetPathsEntry.getKey();
|
||||||
|
PathItem path = openAPIGetPathsEntry.getValue();
|
||||||
if (path.readOperations() != null) {
|
if (path.readOperations() != null) {
|
||||||
for (Operation operation : path.readOperations()) {
|
for (Operation operation : path.readOperations()) {
|
||||||
if (operation.getTags() != null) {
|
if (operation.getTags() != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user