forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
@@ -48,6 +48,7 @@ import io.swagger.models.properties.RefProperty;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
import io.swagger.models.properties.UUIDProperty;
|
||||
import io.swagger.util.Json;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -2688,9 +2689,23 @@ public class DefaultCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
sec.hasMore = it.hasNext();
|
||||
secs.add(sec);
|
||||
}
|
||||
|
||||
// sort auth methods to maintain the same order
|
||||
Collections.sort(secs, new Comparator<CodegenSecurity>() {
|
||||
@Override
|
||||
public int compare(CodegenSecurity one, CodegenSecurity another) {
|
||||
return ObjectUtils.compare(one.name, another.name);
|
||||
}
|
||||
});
|
||||
// set 'hasMore'
|
||||
Iterator<CodegenSecurity> it = secs.iterator();
|
||||
while (it.hasNext()) {
|
||||
final CodegenSecurity security = it.next();
|
||||
security.hasMore = it.hasNext();
|
||||
}
|
||||
|
||||
return secs;
|
||||
}
|
||||
|
||||
|
||||
@@ -625,13 +625,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
bundle.put("modelPackage", config.modelPackage());
|
||||
List<CodegenSecurity> authMethods = config.fromSecurity(swagger.getSecurityDefinitions());
|
||||
if (authMethods != null && !authMethods.isEmpty()) {
|
||||
// sort auth methods to maintain the same order
|
||||
Collections.sort(authMethods, new Comparator<CodegenSecurity>() {
|
||||
@Override
|
||||
public int compare(CodegenSecurity one, CodegenSecurity another) {
|
||||
return ObjectUtils.compare(one.name, another.name);
|
||||
}
|
||||
});
|
||||
bundle.put("authMethods", authMethods);
|
||||
bundle.put("hasAuthMethods", true);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.CodegenType;
|
||||
import io.swagger.codegen.DefaultCodegen;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.BooleanProperty;
|
||||
import io.swagger.models.properties.DateProperty;
|
||||
@@ -27,6 +24,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
public static final String CPP_NAMESPACE = "cppNamespace";
|
||||
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
|
||||
|
||||
protected final String PREFIX = "SWG";
|
||||
protected Set<String> foundationClasses = new HashSet<String>();
|
||||
// source folder where to write the files
|
||||
@@ -34,6 +34,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
protected String apiVersion = "1.0.0";
|
||||
protected Map<String, String> namespaces = new HashMap<String, String>();
|
||||
protected Set<String> systemIncludes = new HashSet<String>();
|
||||
protected String cppNamespace = "Swagger";
|
||||
|
||||
public Qt5CPPGenerator() {
|
||||
super();
|
||||
@@ -74,6 +75,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
embeddedTemplateDir = templateDir = "qt5cpp";
|
||||
|
||||
// CLI options
|
||||
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
|
||||
|
||||
/*
|
||||
* Reserved words. Override this with reserved words specific to your language
|
||||
*/
|
||||
@@ -90,6 +94,11 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
additionalProperties().put("prefix", PREFIX);
|
||||
|
||||
// Write defaults namespace in properties so that it can be accessible in templates.
|
||||
// At this point command line has not been parsed so if value is given
|
||||
// in command line it will superseed this content
|
||||
additionalProperties.put("cppNamespace",cppNamespace);
|
||||
|
||||
/*
|
||||
* Language Specific Primitives. These types will not trigger imports by
|
||||
* the client generator
|
||||
@@ -148,6 +157,24 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
systemIncludes.add("QByteArray");
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("cppNamespace")){
|
||||
cppNamespace = (String) additionalProperties.get("cppNamespace");
|
||||
}
|
||||
|
||||
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the type of generator.
|
||||
*
|
||||
@@ -203,7 +230,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
* @return the escaped term
|
||||
*/
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
public String escapeReservedWord(String name) {
|
||||
if(this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
@@ -266,6 +293,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Property p) {
|
||||
if (p instanceof StringProperty) {
|
||||
@@ -310,7 +338,6 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Optional - swagger type conversion. This is used to map swagger types in a `Property` into
|
||||
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.ModelImpl;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.models.parameters.HeaderParameter;
|
||||
@@ -62,6 +63,16 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
return "Generates a swift client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, ModelImpl swaggerModel) {
|
||||
|
||||
final Property additionalProperties = swaggerModel.getAdditionalProperties();
|
||||
|
||||
if(additionalProperties != null) {
|
||||
codegenModel.additionalPropertiesType = getSwaggerType(additionalProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public Swift3Codegen() {
|
||||
super();
|
||||
outputFolder = "generated-code" + File.separator + "swift";
|
||||
@@ -348,7 +359,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (p instanceof MapProperty) {
|
||||
MapProperty ap = (MapProperty) p;
|
||||
String inner = getSwaggerType(ap.getAdditionalProperties());
|
||||
return "[String:" + inner + "]";
|
||||
return inner;
|
||||
} else if (p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
String inner = getSwaggerType(ap.getItems());
|
||||
|
||||
Reference in New Issue
Block a user