serverVariables;
+ private String gitHost;
private String gitUserId;
private String gitRepoId;
private String releaseNote;
@@ -256,6 +258,17 @@ public final class GeneratorSettings implements Serializable {
return serverVariables;
}
+ /**
+ * Gets git host. e.g. gitlab.com .
+ *
+ * Generally used by git_push.sh in generated sources which support it.
+ * This value may also be used by templates in maven style references, READMEs, or other documentation.
+ *
+ * @return the git host
+ */
+ public String getGitHost() {
+ return gitHost;
+ }
/**
* Gets git user id. e.g. openapitools .
@@ -324,6 +337,7 @@ public final class GeneratorSettings implements Serializable {
languageSpecificPrimitives = ImmutableSet.copyOf(builder.languageSpecificPrimitives);
reservedWordMappings = ImmutableMap.copyOf(builder.reservedWordMappings);
serverVariables = ImmutableMap.copyOf(builder.serverVariables);
+ gitHost = builder.gitHost;
gitUserId = builder.gitUserId;
gitRepoId = builder.gitRepoId;
releaseNote = builder.releaseNote;
@@ -358,6 +372,9 @@ public final class GeneratorSettings implements Serializable {
if (isNotEmpty(modelNameSuffix)) {
additional.put("modelNameSuffix", modelNameSuffix);
}
+ if (isNotEmpty(gitHost)) {
+ additional.put("gitHost", gitHost);
+ }
if (isNotEmpty(gitUserId)) {
additional.put("gitUserId", gitUserId);
}
@@ -390,6 +407,7 @@ public final class GeneratorSettings implements Serializable {
}
private void setDefaults() {
+ gitHost = DEFAULT_GIT_HOST;
gitUserId = DEFAULT_GIT_USER_ID;
gitRepoId = DEFAULT_GIT_REPO_ID;
releaseNote = DEFAULT_RELEASE_NOTE;
@@ -442,6 +460,7 @@ public final class GeneratorSettings implements Serializable {
if (copy.getServerVariables() != null) {
builder.serverVariables.putAll(copy.getServerVariables());
}
+ builder.gitHost = copy.getGitHost();
builder.gitUserId = copy.getGitUserId();
builder.gitRepoId = copy.getGitRepoId();
builder.releaseNote = copy.getReleaseNote();
@@ -473,6 +492,7 @@ public final class GeneratorSettings implements Serializable {
private Set languageSpecificPrimitives;
private Map reservedWordMappings;
private Map serverVariables;
+ private String gitHost;
private String gitUserId;
private String gitRepoId;
private String releaseNote;
@@ -490,6 +510,7 @@ public final class GeneratorSettings implements Serializable {
reservedWordMappings = new HashMap<>();
serverVariables = new HashMap<>();
+ gitHost = DEFAULT_GIT_HOST;
gitUserId = DEFAULT_GIT_USER_ID;
gitRepoId = DEFAULT_GIT_REPO_ID;
releaseNote = DEFAULT_RELEASE_NOTE;
@@ -783,6 +804,17 @@ public final class GeneratorSettings implements Serializable {
return this;
}
+ /**
+ * Sets the {@code gitHost} and returns a reference to this Builder so that the methods can be chained together.
+ *
+ * @param gitHost the {@code gitHost} to set
+ * @return a reference to this Builder
+ */
+ public Builder withGitHost(String gitHost) {
+ this.gitHost = gitHost;
+ return this;
+ }
+
/**
* Sets the {@code gitUserId} and returns a reference to this Builder so that the methods can be chained together.
*
@@ -860,6 +892,7 @@ public final class GeneratorSettings implements Serializable {
", importMappings=" + importMappings +
", languageSpecificPrimitives=" + languageSpecificPrimitives +
", reservedWordMappings=" + reservedWordMappings +
+ ", gitHost='" + gitHost + '\'' +
", gitUserId='" + gitUserId + '\'' +
", gitRepoId='" + gitRepoId + '\'' +
", releaseNote='" + releaseNote + '\'' +
@@ -889,6 +922,7 @@ public final class GeneratorSettings implements Serializable {
Objects.equals(getImportMappings(), that.getImportMappings()) &&
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
+ Objects.equals(getGitHost(), that.getGitHost()) &&
Objects.equals(getGitUserId(), that.getGitUserId()) &&
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
Objects.equals(getReleaseNote(), that.getReleaseNote()) &&
@@ -915,6 +949,7 @@ public final class GeneratorSettings implements Serializable {
getImportMappings(),
getLanguageSpecificPrimitives(),
getReservedWordMappings(),
+ getGitHost(),
getGitUserId(),
getGitRepoId(),
getReleaseNote(),
diff --git a/modules/openapi-generator-gradle-plugin/README.adoc b/modules/openapi-generator-gradle-plugin/README.adoc
index e62e5e4afb6..68d9947f4d3 100644
--- a/modules/openapi-generator-gradle-plugin/README.adoc
+++ b/modules/openapi-generator-gradle-plugin/README.adoc
@@ -202,6 +202,11 @@ apply plugin: 'org.openapi.generator'
|None
|Reference the library template (sub-template) of a generator.
+|gitHost
+|String
+|github.com
+|Git user ID, e.g. gitlab.com.
+
|gitUserId
|String
|None
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
index 7a2a4ab6e4d..07afe14b5e9 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt
@@ -116,6 +116,7 @@ class OpenApiGeneratorPlugin : Plugin {
id.set(generate.id)
version.set(generate.version)
library.set(generate.library)
+ gitHost.set(generate.gitHost)
gitUserId.set(generate.gitUserId)
gitRepoId.set(generate.gitRepoId)
releaseNote.set(generate.releaseNote)
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
index fe44ddaf26d..01e959447ff 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt
@@ -160,6 +160,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
*/
val library = project.objects.property()
+ /**
+ * Git host, e.g. gitlab.com.
+ */
+ val gitHost = project.objects.property()
+
/**
* Git user ID, e.g. openapitools.
*/
diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
index 7f6be14382f..83f206fd491 100644
--- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
+++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt
@@ -204,6 +204,12 @@ open class GenerateTask : DefaultTask() {
@get:Internal
val library = project.objects.property()
+ /**
+ * Git host, e.g. gitlab.com.
+ */
+ @get:Internal
+ val gitHost = project.objects.property()
+
/**
* Git user ID, e.g. openapitools.
*/
@@ -510,6 +516,10 @@ open class GenerateTask : DefaultTask() {
configurator.setLibrary(value)
}
+ gitHost.ifNotEmpty { value ->
+ configurator.setGitHost(value)
+ }
+
gitUserId.ifNotEmpty { value ->
configurator.setGitUserId(value)
}
diff --git a/modules/openapi-generator-maven-plugin/README.md b/modules/openapi-generator-maven-plugin/README.md
index 3f267b41f7e..2d02194aab3 100644
--- a/modules/openapi-generator-maven-plugin/README.md
+++ b/modules/openapi-generator-maven-plugin/README.md
@@ -91,6 +91,7 @@ mvn clean compile
| `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_` is used. For example `id=identifier`. You can also have multiple occurrences of this option
| `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property)
| `engine` | `openapi.generator.maven.plugin.engine` | The name of templating engine to use, "mustache" (default) or "handlebars" (beta)
+| `httpUserAgent` | `openapi.generator.maven.plugin.httpUserAgent` | Sets custom User-Agent header value
### Custom Generator
diff --git a/modules/openapi-generator-maven-plugin/examples/java-client.xml b/modules/openapi-generator-maven-plugin/examples/java-client.xml
index bdff77783b2..634b674ab82 100644
--- a/modules/openapi-generator-maven-plugin/examples/java-client.xml
+++ b/modules/openapi-generator-maven-plugin/examples/java-client.xml
@@ -13,10 +13,11 @@
org.openapitools
openapi-generator-maven-plugin
- 4.1.2-SNAPSHOT
+ 4.1.3-SNAPSHOT
+ default
generate
@@ -39,6 +40,36 @@
jersey2
+
+ remote
+ generate-sources
+
+ generate
+
+
+
+ https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml
+
+
+ java
+
+
+
+
+
+ joda
+
+
+
+ jersey2
+
+ ${project.build.directory}/generated-sources/remote-openapi
+ remote.org.openapitools.client.api
+ remote.org.openapitools.client.model
+ remote.org.openapitools.client
+
+
diff --git a/modules/openapi-generator-maven-plugin/pom.xml b/modules/openapi-generator-maven-plugin/pom.xml
index c745f942276..09b824b7750 100644
--- a/modules/openapi-generator-maven-plugin/pom.xml
+++ b/modules/openapi-generator-maven-plugin/pom.xml
@@ -66,7 +66,7 @@
org.apache.maven.plugins
maven-plugin-plugin
- 3.5.2
+ 3.6.0
true
diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
index 552a44f2563..6a709267e40 100644
--- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
+++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
@@ -20,7 +20,18 @@ package org.openapitools.codegen.plugin;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
+import io.swagger.v3.parser.core.models.AuthorizationValue;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.ReadableByteChannel;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,6 +53,7 @@ import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
+import org.openapitools.codegen.auth.AuthParser;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.config.GlobalSettings;
import org.sonatype.plexus.build.incremental.BuildContext;
@@ -97,6 +109,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
private String inputSpec;
+ /**
+ * Git host, e.g. gitlab.com.
+ */
+ @Parameter(name = "gitHost", property = "openapi.generator.maven.plugin.gitHost", required = false)
+ private String gitHost;
+
/**
* Git user ID, e.g. swagger-api.
*/
@@ -206,6 +224,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false)
private String ignoreFileOverride;
+ /**
+ * Sets custom User-Agent header value
+ */
+ @Parameter(name = "httpUserAgent", property = "openapi.generator.maven.plugin.httpUserAgent", required = false)
+ private String httpUserAgent;
+
/**
* To remove operationId prefix (e.g. user_getName => getName)
*/
@@ -417,7 +441,7 @@ public class CodeGenMojo extends AbstractMojo {
if (inputSpecFile.exists()) {
File storedInputSpecHashFile = getHashFile(inputSpecFile);
if(storedInputSpecHashFile.exists()) {
- String inputSpecHash = Files.asByteSource(inputSpecFile).hash(Hashing.sha256()).toString();
+ String inputSpecHash = calculateInputSpecHash(inputSpecFile);
String storedInputSpecHash = Files.asCharSource(storedInputSpecHashFile, Charsets.UTF_8).read();
if (inputSpecHash.equals(storedInputSpecHash)) {
getLog().info(
@@ -450,6 +474,10 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setInputSpec(inputSpec);
}
+ if (isNotEmpty(gitHost)) {
+ configurator.setGitHost(gitHost);
+ }
+
if (isNotEmpty(gitUserId)) {
configurator.setGitUserId(gitUserId);
}
@@ -462,6 +490,10 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setIgnoreFileOverride(ignoreFileOverride);
}
+ if (isNotEmpty(httpUserAgent)) {
+ configurator.setHttpUserAgent(httpUserAgent);
+ }
+
if (skipValidateSpec != null) {
configurator.setValidateSpec(!skipValidateSpec);
}
@@ -700,12 +732,7 @@ public class CodeGenMojo extends AbstractMojo {
// Store a checksum of the input spec
File storedInputSpecHashFile = getHashFile(inputSpecFile);
- ByteSource inputSpecByteSource =
- inputSpecFile.exists()
- ? Files.asByteSource(inputSpecFile)
- : CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecFile.toString().replaceAll("\\\\","/")))
- .asByteSource(Charsets.UTF_8);
- String inputSpecHash =inputSpecByteSource.hash(Hashing.sha256()).toString();
+ String inputSpecHash = calculateInputSpecHash(inputSpecFile);
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
File parent = new File(storedInputSpecHashFile.getParent());
@@ -726,8 +753,75 @@ public class CodeGenMojo extends AbstractMojo {
}
}
+ /**
+ * Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
+ *
+ * @param inputSpecFile - Openapi specification input file to calculate it's hash.
+ * Does not taken into account if input spec is hosted on remote resource
+ * @return openapi specification file hash
+ * @throws IOException
+ */
+ private String calculateInputSpecHash(File inputSpecFile) throws IOException {
+
+ URL inputSpecRemoteUrl = inputSpecRemoteUrl();
+
+ File inputSpecTempFile = inputSpecFile;
+
+ if (inputSpecRemoteUrl != null) {
+ inputSpecTempFile = File.createTempFile("openapi-spec", ".tmp");
+
+ URLConnection conn = inputSpecRemoteUrl.openConnection();
+ if (isNotEmpty(auth)) {
+ List authList = AuthParser.parse(auth);
+ for (AuthorizationValue auth : authList) {
+ conn.setRequestProperty(auth.getKeyName(), auth.getValue());
+ }
+ }
+ ReadableByteChannel readableByteChannel = Channels.newChannel(conn.getInputStream());
+
+ FileOutputStream fileOutputStream = new FileOutputStream(inputSpecTempFile);
+ FileChannel fileChannel = fileOutputStream.getChannel();
+
+ fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
+ }
+
+ ByteSource inputSpecByteSource =
+ inputSpecTempFile.exists()
+ ? Files.asByteSource(inputSpecTempFile)
+ : CharSource.wrap(ClasspathHelper.loadFileFromClasspath(inputSpecTempFile.toString().replaceAll("\\\\","/")))
+ .asByteSource(Charsets.UTF_8);
+
+ return inputSpecByteSource.hash(Hashing.sha256()).toString();
+ }
+
+ /**
+ * Try to parse inputSpec setting string into URL
+ * @return A valid URL or null if inputSpec is not a valid URL
+ */
+ private URL inputSpecRemoteUrl(){
+ try {
+ return new URI(inputSpec).toURL();
+ } catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Get specification hash file
+ * @param inputSpecFile - Openapi specification input file to calculate it's hash.
+ * Does not taken into account if input spec is hosted on remote resource
+ * @return a file with previously calculated hash
+ */
private File getHashFile(File inputSpecFile) {
- return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + inputSpecFile.getName() + ".sha256");
+ String name = inputSpecFile.getName();
+
+ URL url = inputSpecRemoteUrl();
+ if (url != null) {
+ String[] segments = url.getPath().split("/");
+ name = Files.getNameWithoutExtension(segments[segments.length - 1]);
+ }
+
+ return new File(output.getPath() + File.separator + ".openapi-generator" + File.separator + name + ".sha256");
}
private String getCompileSourceRoot() {
@@ -737,8 +831,7 @@ public class CodeGenMojo extends AbstractMojo {
final String sourceFolder =
sourceFolderObject == null ? "src/main/java" : sourceFolderObject.toString();
- String sourceJavaFolder = output.toString() + "/" + sourceFolder;
- return sourceJavaFolder;
+ return output.toString() + "/" + sourceFolder;
}
private void addCompileSourceRootIfConfigured() {
@@ -783,4 +876,4 @@ public class CodeGenMojo extends AbstractMojo {
}
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/pom.xml b/modules/openapi-generator/pom.xml
index 6db57e7f760..7e6cecd94dc 100644
--- a/modules/openapi-generator/pom.xml
+++ b/modules/openapi-generator/pom.xml
@@ -74,7 +74,7 @@
maven-compiler-plugin
- 3.5.1
+ 3.8.1
1.8
1.8
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java
index f7141d1fe07..69e5cc53cda 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java
@@ -222,6 +222,10 @@ public interface CodegenConfig {
*/
String getLibrary();
+ void setGitHost(String gitHost);
+
+ String getGitHost();
+
void setGitUserId(String gitUserId);
String getGitUserId();
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
index 0cf95af984d..ef235748f26 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
@@ -202,12 +202,19 @@ public class CodegenConstants {
public static final String ENUM_PROPERTY_NAMING = "enumPropertyNaming";
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
+ // Allow different language generators to offer an option of serialization library. Each language specific
+ // Codegen constants should define a description and provide proper input validation for the value of serializationLibrary
+ public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
+
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
+ public static final String GIT_HOST = "gitHost";
+ public static final String GIT_HOST_DESC = "Git host, e.g. gitlab.com.";
+
public static final String GIT_USER_ID = "gitUserId";
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 4a99f26be63..682ca581355 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -111,7 +111,7 @@ public class DefaultCodegen implements CodegenConfig {
protected Boolean sortParamsByRequiredFlag = true;
protected Boolean ensureUniqueParams = true;
protected Boolean allowUnicodeIdentifiers = false;
- protected String gitUserId, gitRepoId, releaseNote;
+ protected String gitHost, gitUserId, gitRepoId, releaseNote;
protected String httpUserAgent;
protected Boolean hideGenerationTimestamp = true;
// How to encode special characters like $
@@ -1247,7 +1247,7 @@ public class DefaultCodegen implements CodegenConfig {
return instantiationTypes.get("map") + "";
} else if (ModelUtils.isArraySchema(schema)) {
ArraySchema arraySchema = (ArraySchema) schema;
- String inner = getSchemaType(arraySchema.getItems());
+ String inner = getSchemaType(getSchemaItems(arraySchema));
return instantiationTypes.get("array") + "<" + inner + ">";
} else {
return null;
@@ -1462,6 +1462,15 @@ public class DefaultCodegen implements CodegenConfig {
}
+ protected Schema> getSchemaItems(ArraySchema schema) {
+ if (schema.getItems() != null) {
+ return schema.getItems();
+ } else {
+ LOGGER.error("Undefined array inner type for `{}`. Default to String.", schema.getName());
+ return new StringSchema().description("TODO default missing array inner type to string");
+ }
+ }
+
/**
* Return the name of the allOf schema
*
@@ -2180,11 +2189,10 @@ public class DefaultCodegen implements CodegenConfig {
property.isFreeFormObject = true;
} else if (ModelUtils.isArraySchema(p)) {
// default to string if inner item is undefined
- Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
- if (innerSchema == null) {
- LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
- innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
- ((ArraySchema) p).setItems(innerSchema);
+ ArraySchema arraySchema = (ArraySchema) p;
+ Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
+ if (arraySchema.getItems() == null) {
+ arraySchema.setItems(innerSchema);
}
} else if (ModelUtils.isMapSchema(p)) {
Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
@@ -2262,11 +2270,10 @@ public class DefaultCodegen implements CodegenConfig {
if (itemName == null) {
itemName = property.name;
}
- Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
- if (innerSchema == null) {
- LOGGER.error("Undefined array inner type for `{}`. Default to String.", p.getName());
- innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
- ((ArraySchema) p).setItems(innerSchema);
+ ArraySchema arraySchema = (ArraySchema) p;
+ Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, getSchemaItems(arraySchema));
+ if (arraySchema.getItems() == null) {
+ arraySchema.setItems(innerSchema);
}
CodegenProperty cp = fromProperty(itemName, innerSchema);
updatePropertyForArray(property, cp);
@@ -2296,8 +2303,9 @@ public class DefaultCodegen implements CodegenConfig {
// property.baseType = getSimpleRef(p.get$ref());
//}
// --END of revision
- property.isModel = ModelUtils.isModel(p);
setNonArrayMapProperty(property, type);
+ Schema refOrCurrent = ModelUtils.getReferencedSchema(this.openAPI, p);
+ property.isModel = (ModelUtils.isComposedSchema(refOrCurrent) || ModelUtils.isObjectSchema(refOrCurrent)) && ModelUtils.isModel(refOrCurrent);
}
LOGGER.debug("debugging from property return: " + property);
@@ -2584,7 +2592,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
- CodegenProperty innerProperty = fromProperty("response", as.getItems());
+ CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
op.returnBaseType = innerProperty.baseType;
} else if (ModelUtils.isMapSchema(responseSchema)) {
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
@@ -2854,7 +2862,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(responseSchema)) {
ArraySchema as = (ArraySchema) responseSchema;
- CodegenProperty innerProperty = fromProperty("response", as.getItems());
+ CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as));
CodegenProperty innerCp = innerProperty;
while (innerCp != null) {
r.baseType = innerCp.baseType;
@@ -3062,10 +3070,8 @@ public class DefaultCodegen implements CodegenConfig {
String collectionFormat = null;
if (ModelUtils.isArraySchema(parameterSchema)) { // for array parameter
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
- Schema inner = arraySchema.getItems();
- if (inner == null) {
- LOGGER.warn("warning! No inner type supplied for array parameter \"" + parameter.getName() + "\", using String");
- inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing iner type definition in the spec");
+ Schema inner = getSchemaItems(arraySchema);
+ if (arraySchema.getItems() == null) {
arraySchema.setItems(inner);
}
@@ -3901,6 +3907,24 @@ public class DefaultCodegen implements CodegenConfig {
return library;
}
+ /**
+ * Set Git host.
+ *
+ * @param gitHost Git host
+ */
+ public void setGitHost(String gitHost) {
+ this.gitHost = gitHost;
+ }
+
+ /**
+ * Git host.
+ *
+ * @return Git host
+ */
+ public String getGitHost() {
+ return gitHost;
+ }
+
/**
* Set Git user ID.
*
@@ -4598,10 +4622,8 @@ public class DefaultCodegen implements CodegenConfig {
// array of schema
if (ModelUtils.isArraySchema(s)) {
final ArraySchema arraySchema = (ArraySchema) s;
- Schema inner = arraySchema.getItems();
- if (inner == null) {
- LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", s.getName());
- inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing inner type definition in the spec");
+ Schema inner = getSchemaItems(arraySchema);
+ if (arraySchema.getItems() == null) {
arraySchema.setItems(inner);
}
@@ -4798,10 +4820,8 @@ public class DefaultCodegen implements CodegenConfig {
setParameterNullable(codegenParameter, codegenProperty);
} else if (ModelUtils.isArraySchema(schema)) {
final ArraySchema arraySchema = (ArraySchema) schema;
- Schema inner = arraySchema.getItems();
- if (inner == null) {
- LOGGER.error("No inner type supplied for array parameter `{}`. Default to type:string", schema.getName());
- inner = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
+ Schema inner = getSchemaItems(arraySchema);
+ if (arraySchema.getItems() == null) {
arraySchema.setItems(inner);
}
CodegenProperty codegenProperty = fromProperty("property", arraySchema);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java
index b4a078e8b40..c2df323731b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java
@@ -222,6 +222,11 @@ public class CodegenConfigurator {
return this;
}
+ public CodegenConfigurator setGitHost(String gitHost) {
+ generatorSettingsBuilder.withGitHost(gitHost);
+ return this;
+ }
+
public CodegenConfigurator setGitUserId(String gitUserId) {
generatorSettingsBuilder.withGitUserId(gitUserId);
return this;
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
index 038414054e6..70f251d33cf 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java
@@ -374,6 +374,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
boolean addedOptionalImport = false;
boolean addedTimeImport = false;
boolean addedOSImport = false;
+ boolean addedReflectImport = false;
for (CodegenOperation operation : operations) {
for (CodegenParameter param : operation.allParams) {
// import "os" if the operation uses files
@@ -391,8 +392,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
}
// import "reflect" package if the parameter is collectionFormat=multi
- if (param.isCollectionFormatMulti) {
+ if (!addedReflectImport && param.isCollectionFormatMulti) {
imports.add(createMapping("import", "reflect"));
+ addedReflectImport = true;
}
// import "optionals" package if the parameter is optional
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
index 1e77a694db8..f04d4ac1379 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
@@ -686,14 +686,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
- ArraySchema ap = (ArraySchema) p;
- Schema inner = ap.getItems();
- if (inner == null) {
- LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", ap.getName());
- inner = new StringSchema().description("TODO default missing array inner type to string");
- ap.setItems(inner);
- }
- return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
+ Schema> items = getSchemaItems((ArraySchema) p);
+ return getSchemaType(p) + "<" + getTypeDeclaration(items) + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
if (inner == null) {
@@ -725,13 +719,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
pattern = "new ArrayList<%s>()";
}
- Schema> items;
- if (p instanceof ArraySchema && ((ArraySchema) p).getItems() != null) {
- items = ((ArraySchema) p).getItems();
- } else {
- LOGGER.error("`{}` (array property) does not have a proper inner type defined. Default to type:string", p.getName());
- items = new StringSchema().description("TODO default missing array inner type to string");
- }
+ Schema> items = getSchemaItems((ArraySchema) p);
String typeDeclaration = getTypeDeclaration(items);
Object java8obj = additionalProperties.get("java8");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
index 148cbb547ae..5351c1fe2d4 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
@@ -35,6 +35,10 @@ import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
+
+ public static final String SERIALIZATION_LIBRARY_DESC = "What serialization library to use: 'moshi' (default), or 'gson'";
+ public enum SERIALIZATION_LIBRARY_TYPE {moshi, gson}
+
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
protected String artifactId;
@@ -51,6 +55,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
protected boolean parcelizeModels = false;
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.camelCase;
+ protected SERIALIZATION_LIBRARY_TYPE serializationLibrary = SERIALIZATION_LIBRARY_TYPE.moshi;
public AbstractKotlinCodegen() {
super();
@@ -205,6 +210,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
CliOption enumPropertyNamingOpt = new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC);
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
+
+ CliOption serializationLibraryOpt = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_DESC);
+ cliOptions.add(serializationLibraryOpt.defaultValue(serializationLibrary.name()));
+
cliOptions.add(new CliOption(CodegenConstants.PARCELIZE_MODELS, CodegenConstants.PARCELIZE_MODELS_DESC));
}
@@ -244,6 +253,10 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return this.enumPropertyNaming;
}
+ public SERIALIZATION_LIBRARY_TYPE getSerializationLibrary() {
+ return this.serializationLibrary;
+ }
+
/**
* Sets the naming convention for Kotlin enum properties
*
@@ -261,6 +274,24 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
}
}
+ /**
+ * Sets the serialization engine for Kotlin
+ *
+ * @param enumSerializationLibrary The string representation of the serialization library as defined by
+ * {@link org.openapitools.codegen.languages.AbstractKotlinCodegen.SERIALIZATION_LIBRARY_TYPE}
+ */
+ public void setSerializationLibrary(final String enumSerializationLibrary) {
+ try {
+ this.serializationLibrary = SERIALIZATION_LIBRARY_TYPE.valueOf(enumSerializationLibrary);
+ } catch (IllegalArgumentException ex) {
+ StringBuilder sb = new StringBuilder(enumSerializationLibrary + " is an invalid enum property naming option. Please choose from:");
+ for (SERIALIZATION_LIBRARY_TYPE t : SERIALIZATION_LIBRARY_TYPE.values()) {
+ sb.append("\n ").append(t.name());
+ }
+ throw new RuntimeException(sb.toString());
+ }
+ }
+
/**
* returns the swagger type for the property
*
@@ -330,6 +361,14 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
setEnumPropertyNaming((String) additionalProperties.get(CodegenConstants.ENUM_PROPERTY_NAMING));
}
+ if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
+ setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));
+ additionalProperties.put(this.serializationLibrary.name(), true);
+ }
+ else {
+ additionalProperties.put(this.serializationLibrary.name(), true);
+ }
+
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
this.setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
} else {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java
new file mode 100644
index 00000000000..5e8e788209a
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AsciidocDocumentationCodegen.java
@@ -0,0 +1,274 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import org.openapitools.codegen.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.samskivert.mustache.Mustache;
+import com.samskivert.mustache.Template;
+
+import io.swagger.v3.oas.models.OpenAPI;
+
+/**
+ * basic asciidoc markup generator.
+ *
+ * @see asciidoctor
+ */
+public class AsciidocDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AsciidocDocumentationCodegen.class);
+
+ public static final String SPEC_DIR = "specDir";
+ public static final String SNIPPET_DIR = "snippetDir";
+
+ /**
+ * Lambda emitting an asciidoc "include::filename.adoc[]" if file is found in
+ * path. Use:
+ *
+ *
+ * {{#includemarkup}}{{name}}/description.adoc{{/includemarkup}}
+ *
+ */
+ public class IncludeMarkupLambda implements Mustache.Lambda {
+
+ private long includeCount = 0;
+ private long notFoundCount = 0;
+ private String basePath;
+
+ public IncludeMarkupLambda(final String basePath) {
+ this.basePath = basePath;
+ }
+
+ public String resetCounter() {
+ String msg = "included: " + includeCount + " notFound: " + notFoundCount + " from " + basePath;
+ includeCount = 0;
+ notFoundCount = 0;
+ return msg;
+ }
+
+ @Override
+ public void execute(final Template.Fragment frag, final Writer out) throws IOException {
+
+ final String relativeFileName = AsciidocDocumentationCodegen.sanitize(frag.execute());
+ final Path filePathToInclude = Paths.get(basePath, relativeFileName).toAbsolutePath();
+
+ if (Files.isRegularFile(filePathToInclude)) {
+ LOGGER.debug(
+ "including " + ++includeCount + ". file into markup from: " + filePathToInclude.toString());
+ out.write("\ninclude::" + relativeFileName + "[]\n");
+ } else {
+ LOGGER.debug(++notFoundCount + ". file not found, skip include for: " + filePathToInclude.toString());
+ out.write("\n// markup not found, no include ::" + relativeFileName + "[]\n");
+ }
+ }
+ }
+
+ /**
+ * Lambda emitting an asciidoc "http link" if file is found in path. Use:
+ *
+ *
+ * {{#snippetLink}}markup until koma, /{{name}}.json{{/snippetLink}}
+ *
+ */
+ public class LinkMarkupLambda implements Mustache.Lambda {
+
+ private long linkedCount = 0;
+ private long notFoundLinkCount = 0;
+ private String basePath;
+
+ public LinkMarkupLambda(final String basePath) {
+ this.basePath = basePath;
+ }
+
+ public String resetCounter() {
+ String msg = "linked:" + linkedCount + " notFound: " + notFoundLinkCount + " from " + basePath;
+ linkedCount = 0;
+ notFoundLinkCount = 0;
+ return msg;
+ }
+
+ @Override
+ public void execute(final Template.Fragment frag, final Writer out) throws IOException {
+
+ final String content = frag.execute();
+ final String[] tokens = content.split(",", 2);
+
+ final String linkName = tokens.length > 0 ? tokens[0] : "";
+
+ final String relativeFileName = AsciidocDocumentationCodegen
+ .sanitize(tokens.length > 1 ? tokens[1] : linkName);
+
+ final Path filePathToLinkTo = Paths.get(basePath, relativeFileName).toAbsolutePath();
+
+ if (Files.isRegularFile(filePathToLinkTo)) {
+ LOGGER.debug("linking " + ++linkedCount + ". file into markup from: " + filePathToLinkTo.toString());
+ out.write("\n" + linkName + " link:" + relativeFileName + "[]\n");
+ } else {
+ LOGGER.debug(++notFoundLinkCount + ". file not found, skip link for: " + filePathToLinkTo.toString());
+ out.write("\n// file not found, no " + linkName + " link :" + relativeFileName + "[]\n");
+ }
+ }
+ }
+
+ protected String invokerPackage = "org.openapitools.client";
+ protected String groupId = "org.openapitools";
+ protected String artifactId = "openapi-client";
+ protected String artifactVersion = "1.0.0";
+
+ private IncludeMarkupLambda includeSpecMarkupLambda;
+ private IncludeMarkupLambda includeSnippetMarkupLambda;
+ private LinkMarkupLambda linkSnippetMarkupLambda;
+
+ public CodegenType getTag() {
+ return CodegenType.DOCUMENTATION;
+ }
+
+ /**
+ * extracted filter value should be relative to be of use as link or include
+ * file.
+ *
+ * @param name filename to sanitize
+ * @return trimmed and striped path part or empty string.
+ */
+ static String sanitize(final String name) {
+ String sanitized = name == null ? "" : name.trim();
+ return sanitized.startsWith(File.separator) || sanitized.startsWith("/") ? sanitized.substring(1) : sanitized;
+ }
+
+ public String getName() {
+ return "asciidoc";
+ }
+
+ public String getHelp() {
+ return "Generates asciidoc markup based documentation.";
+ }
+
+ public String getSpecDir() {
+ return additionalProperties.get("specDir").toString();
+ }
+
+ public String getSnippetDir() {
+ return additionalProperties.get("snippetDir").toString();
+ }
+
+ public AsciidocDocumentationCodegen() {
+ super();
+
+ LOGGER.trace("start asciidoc codegen");
+
+ outputFolder = "generated-code" + File.separator + "asciidoc";
+ embeddedTemplateDir = templateDir = "asciidoc-documentation";
+
+ defaultIncludes = new HashSet();
+
+ cliOptions.add(new CliOption("appName", "short name of the application"));
+ cliOptions.add(new CliOption("appDescription", "description of the application"));
+ cliOptions.add(new CliOption("infoUrl", "a URL where users can get more information about the application"));
+ cliOptions.add(new CliOption("infoEmail", "an email address to contact for inquiries about the application"));
+ cliOptions.add(new CliOption("licenseInfo", "a short description of the license"));
+ cliOptions.add(new CliOption(CodegenConstants.LICENSE_URL, "a URL pointing to the full license"));
+ cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
+ cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
+ cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
+ cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
+
+ cliOptions.add(new CliOption(SNIPPET_DIR,
+ "path with includable markup snippets (e.g. test output generated by restdoc, default: .")
+ .defaultValue("."));
+ cliOptions.add(new CliOption(SPEC_DIR,
+ "path with includable markup spec files (e.g. handwritten additional docs, default: .")
+ .defaultValue(".."));
+
+ additionalProperties.put("appName", "OpenAPI Sample description");
+ additionalProperties.put("appDescription", "A sample OpenAPI documentation");
+ additionalProperties.put("infoUrl", "https://openapi-generator.tech");
+ additionalProperties.put("infoEmail", "team@openapitools.org");
+ additionalProperties.put("licenseInfo", "All rights reserved");
+ additionalProperties.put(CodegenConstants.LICENSE_URL, "http://apache.org/licenses/LICENSE-2.0.html");
+ additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
+ additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
+ additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
+ additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
+
+ supportingFiles.add(new SupportingFile("index.mustache", "", "index.adoc"));
+ reservedWords = new HashSet();
+
+ languageSpecificPrimitives = new HashSet();
+ importMapping = new HashMap();
+
+ }
+
+ @Override
+ public String escapeQuotationMark(String input) {
+ return input; // just return the original string
+ }
+
+ @Override
+ public String escapeUnsafeCharacters(String input) {
+ return input; // just return the original string
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ String specDir = this.additionalProperties.get(SPEC_DIR) + "";
+ if (!Files.isDirectory(Paths.get(specDir))) {
+ LOGGER.warn("base part for include markup lambda not found: " + specDir + " as "
+ + Paths.get(specDir).toAbsolutePath());
+ }
+
+ this.includeSpecMarkupLambda = new IncludeMarkupLambda(specDir);
+ additionalProperties.put("specinclude", this.includeSpecMarkupLambda);
+
+ String snippetDir = this.additionalProperties.get(SNIPPET_DIR) + "";
+ if (!Files.isDirectory(Paths.get(snippetDir))) {
+ LOGGER.warn("base part for include markup lambda not found: " + snippetDir + " as "
+ + Paths.get(snippetDir).toAbsolutePath());
+ }
+
+ this.includeSnippetMarkupLambda = new IncludeMarkupLambda(snippetDir);
+ additionalProperties.put("snippetinclude", this.includeSnippetMarkupLambda);
+
+ this.linkSnippetMarkupLambda = new LinkMarkupLambda(snippetDir);
+ additionalProperties.put("snippetlink", this.linkSnippetMarkupLambda);
+ }
+
+ @Override
+ public void processOpenAPI(OpenAPI openAPI) {
+ if (this.includeSpecMarkupLambda != null) {
+ LOGGER.debug("specs: " + ": " + this.includeSpecMarkupLambda.resetCounter());
+ }
+ if (this.includeSnippetMarkupLambda != null) {
+ LOGGER.debug("snippets: " + ": " + this.includeSnippetMarkupLambda.resetCounter());
+ }
+ super.processOpenAPI(openAPI);
+ }
+
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5AbstractCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5AbstractCodegen.java
index cfaac199a1c..ec03a45490f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5AbstractCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5AbstractCodegen.java
@@ -26,7 +26,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
protected Set systemIncludes = new HashSet();
protected Set nonFrameworkPrimitives = new HashSet();
-
+
public CppQt5AbstractCodegen() {
super();
// set modelNamePrefix as default for QHttpEngine Server
@@ -61,10 +61,10 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
"double")
);
nonFrameworkPrimitives.addAll(languageSpecificPrimitives);
-
+
foundationClasses.addAll(
Arrays.asList(
- "QString",
+ "QString",
"QDate",
"QDateTime",
"QByteArray")
@@ -78,7 +78,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
typeMapping.put("integer", "qint32");
typeMapping.put("long", "qint64");
typeMapping.put("boolean", "bool");
- typeMapping.put("number", "double");
+ typeMapping.put("number", "double");
typeMapping.put("array", "QList");
typeMapping.put("map", "QMap");
typeMapping.put("object", PREFIX + "Object");
@@ -90,8 +90,8 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// modifications on multiple templates)
typeMapping.put("UUID", "QString");
typeMapping.put("URI", "QString");
- typeMapping.put("file", "QIODevice");
- typeMapping.put("binary", "QIODevice");
+ typeMapping.put("file", "QByteArray");
+ typeMapping.put("binary", "QByteArray");
importMapping = new HashMap();
namespaces = new HashMap();
@@ -101,7 +101,6 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
systemIncludes.add("QDate");
systemIncludes.add("QDateTime");
systemIncludes.add("QByteArray");
- systemIncludes.add("QIODevice");
}
@Override
public void processOpts() {
@@ -119,7 +118,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
additionalProperties().put("prefix", modelNamePrefix);
}
}
-
+
@Override
public String toModelImport(String name) {
if( name.isEmpty() ) {
@@ -140,7 +139,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
return "#include \"" + folder + name + ".h\"";
}
-
+
/**
* Optional - type declaration. This is a String which is used by the templates to instantiate your
* types. There is typically special handling for different property types
@@ -160,9 +159,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
Schema inner = ModelUtils.getAdditionalProperties(p);
return getSchemaType(p) + "";
} else if (ModelUtils.isBinarySchema(p)) {
- return getSchemaType(p) + "*";
+ return getSchemaType(p);
} else if (ModelUtils.isFileSchema(p)) {
- return getSchemaType(p) + "*";
+ return getSchemaType(p);
}
if (foundationClasses.contains(openAPIType)) {
return openAPIType;
@@ -174,7 +173,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
@Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("rawtypes")
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
return "false";
@@ -211,7 +210,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
public String toModelFilename(String name) {
return toModelName(name);
}
-
+
/**
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
@@ -219,7 +218,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
* @return a string value of the type or complex model for this property
*/
@Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("rawtypes")
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
@@ -242,7 +241,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
public String toVarName(String name) {
// sanitize name
String varName = name;
- varName = sanitizeName(name);
+ varName = sanitizeName(name);
// if it's all uppper case, convert to lower case
if (varName.matches("^[A-Z_]*$")) {
@@ -270,7 +269,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
public String getTypeDeclaration(String str) {
return str;
}
-
+
@Override
protected boolean needToImport(String type) {
return StringUtils.isNotBlank(type) && !defaultIncludes.contains(type)
@@ -283,7 +282,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
public Map postProcessOperationsWithModels(Map objs, List allModels) {
Map objectMap = (Map) objs.get("operations");
List operations = (List) objectMap.get("operation");
-
+
List> imports = (List>) objs.get("imports");
Map codegenModels = new HashMap ();
for(Object moObj : allModels) {
@@ -298,7 +297,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
operation.vendorExtensions.put("returnsEnum", true);
}
}
- // Check all return parameter baseType if there is a necessity to include, include it if not
+ // Check all return parameter baseType if there is a necessity to include, include it if not
// already done
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
if(!isIncluded(operation.returnBaseType, imports)) {
@@ -308,7 +307,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
List params = new ArrayList();
if (operation.allParams != null)params.addAll(operation.allParams);
- // Check all parameter baseType if there is a necessity to include, include it if not
+ // Check all parameter baseType if there is a necessity to include, include it if not
// already done
for(CodegenParameter param : params) {
if(param.isPrimitiveType && needToImport(param.baseType)) {
@@ -321,7 +320,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// We use QString to pass path params, add it to include
if(!isIncluded("QString", imports)) {
imports.add(createMapping("import", "QString"));
- }
+ }
}
}
if(isIncluded("QMap", imports)) {
@@ -332,7 +331,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
return objs;
}
-
+
@Override
public Map postProcessModels(Map objs) {
return postProcessModelsEnum(objs);
@@ -342,18 +341,18 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
public String toEnumValue(String value, String datatype) {
return escapeText(value);
}
-
+
@Override
public boolean isDataTypeString(String dataType) {
return "QString".equals(dataType);
}
-
+
private Map createMapping(String key, String value) {
Map customImport = new HashMap();
customImport.put(key, toModelImport(value));
return customImport;
}
-
+
private boolean isIncluded(String type, List> imports) {
boolean included = false;
String inclStr = toModelImport(type);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java
index 62ea88cc658..73897d8cf74 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java
@@ -76,14 +76,15 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, PREFIX + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder, PREFIX + "HttpFileElement.h"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder, PREFIX + "HttpFileElement.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
- supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
+ supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, PREFIX + "Enum.h"));
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
}
- typeMapping.put("file", PREFIX + "HttpRequestInputFileElement");
- typeMapping.put("binary", PREFIX +"HttpRequestInputFileElement");
- importMapping.put(PREFIX + "HttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
+ typeMapping.put("file", PREFIX + "HttpFileElement");
+ importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
}
@Override
@@ -95,7 +96,7 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
} else {
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
}
-
+
if (additionalProperties.containsKey("modelNamePrefix")) {
supportingFiles.clear();
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, modelNamePrefix + "Helpers.h"));
@@ -103,11 +104,10 @@ public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements Codege
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
- supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
+ supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder, modelNamePrefix + "Enum.h"));
- typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
- typeMapping.put("binary", modelNamePrefix + "HttpRequestInputFileElement");
- importMapping.put(modelNamePrefix + "HttpRequestInputFileElement", "#include \"" + modelNamePrefix + "HttpRequest.h\"");
+ typeMapping.put("file", modelNamePrefix + "HttpFileElement");
+ importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri"));
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5QHttpEngineServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5QHttpEngineServerCodegen.java
index 393fafc8be6..a462164107d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5QHttpEngineServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5QHttpEngineServerCodegen.java
@@ -76,7 +76,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
apiTemplateFiles.put(
"apirequest.h.mustache", // the template to use
".h"); // the extension for each file to write
-
+
apiTemplateFiles.put(
"apirequest.cpp.mustache", // the template to use
".cpp"); // the extension for each file to write
@@ -86,11 +86,13 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
* will use the resource stream to attempt to read the templates.
*/
embeddedTemplateDir = templateDir = "cpp-qt5-qhttpengine-server";
-
+
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
- supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
+ supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, PREFIX + "Enum.h"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder + MODEL_DIR, PREFIX + "HttpFileElement.h"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder + MODEL_DIR, PREFIX + "HttpFileElement.cpp"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.h"));
supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, PREFIX + "ApiRouter.cpp"));
@@ -102,6 +104,8 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
+ typeMapping.put("file", PREFIX + "HttpFileElement");
+ importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
}
@@ -115,9 +119,12 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Object.h"));
supportingFiles.add(new SupportingFile("enum.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "Enum.h"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.h.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.h"));
+ supportingFiles.add(new SupportingFile("HttpFileElement.cpp.mustache", sourceFolder + MODEL_DIR, modelNamePrefix + "HttpFileElement.cpp"));
supportingFiles.add(new SupportingFile("apirouter.h.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.h"));
- supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
-
+ supportingFiles.add(new SupportingFile("apirouter.cpp.mustache", sourceFolder + APIHANDLER_DIR, modelNamePrefix + "ApiRouter.cpp"));
+
+
supportingFiles.add(new SupportingFile("main.cpp.mustache", sourceFolder + SRC_DIR, "main.cpp"));
supportingFiles.add(new SupportingFile("src-CMakeLists.txt.mustache", sourceFolder + SRC_DIR, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("README.md.mustache", sourceFolder, "README.MD"));
@@ -125,6 +132,8 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
supportingFiles.add(new SupportingFile("CMakeLists.txt.mustache", sourceFolder, "CMakeLists.txt"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", sourceFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("LICENSE.txt.mustache", sourceFolder, "LICENSE.txt"));
+ typeMapping.put("file", modelNamePrefix + "HttpFileElement");
+ importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
}
}
@@ -160,7 +169,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
public String getHelp() {
return "Generates a Qt5 C++ Server using the QHTTPEngine HTTP Library.";
}
-
+
/**
* Location to write model files. You can use the modelPackage() as defined when the class is
* instantiated
@@ -182,7 +191,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
private String requestFileFolder() {
return outputFolder + "/" + sourceFolder + APIREQUEST_DIR + "/" + apiPackage().replace("::", File.separator);
}
-
+
@Override
public String apiFilename(String templateName, String tag) {
String result = super.apiFilename(templateName, tag);
@@ -193,7 +202,7 @@ public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implem
}
return result;
}
-
+
@Override
public String toApiFilename(String name) {
return modelNamePrefix + sanitizeName(camelize(name)) + "ApiHandler";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
index ddfdcbb0e0b..25be57289d7 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
@@ -242,7 +242,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
if (response != null) {
CodegenProperty cm = fromProperty("response", response);
op.vendorExtensions.put("x-codegen-response", cm);
- if ("HttpContent".equals(cm.dataType)) {
+ if ("std::shared_ptr".equals(cm.dataType)) {
op.vendorExtensions.put("x-codegen-response-ishttpcontent", true);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
index fed61cd4c97..7e4f21d662e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
@@ -62,7 +62,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
outputFolder = "generated-code/dart";
modelTemplateFiles.put("model.mustache", ".dart");
apiTemplateFiles.put("api.mustache", ".dart");
- embeddedTemplateDir = templateDir = "dart";
+ embeddedTemplateDir = templateDir = "dart2";
apiPackage = "lib.api";
modelPackage = "lib.model";
modelDocTemplateFiles.put("object_doc.mustache", ".md");
@@ -124,7 +124,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "Source folder for generated code"));
- cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x").defaultValue(Boolean.TRUE.toString()));
+ cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "Support Dart 2.x (Dart 1.x support has been deprecated)").defaultValue(Boolean.TRUE.toString()));
}
@Override
@@ -139,7 +139,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getHelp() {
- return "Generates a Dart (1.x or 2.x) client library.";
+ return "Generates a Dart (1.x (deprecated) or 2.x) client library.";
}
@Override
@@ -202,7 +202,10 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
} else {
// dart 2.x
LOGGER.info("Dart version: 2.x");
- embeddedTemplateDir = templateDir = "dart2";
+ // check to not overwrite a custom templateDir
+ if (templateDir == null) {
+ embeddedTemplateDir = templateDir = "dart2";
+ }
}
final String libFolder = sourceFolder + File.separator + "lib";
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
index cc2516fee73..0dd404e52a1 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java
@@ -45,7 +45,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
modelToIgnore.add("object");
modelToIgnore.add("list");
modelToIgnore.add("file");
- modelToIgnore.add("uint8list");
+ modelToIgnore.add("list");
}
private static final String SERIALIZATION_JSON = "json";
@@ -63,8 +63,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
cliOptions.add(new CliOption(SERIALIZATION_FORMAT, "Choose serialization format JSON or PROTO is supported"));
- typeMapping.put("file", "Uint8List");
- typeMapping.put("binary", "Uint8List");
+ typeMapping.put("file", "List");
+ typeMapping.put("binary", "List");
protoTypeMapping.put("Array", "repeated");
protoTypeMapping.put("array", "repeated");
@@ -247,19 +247,19 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
}
for (CodegenParameter param : op.allParams) {
- if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
+ if (param.baseType != null && param.baseType.equalsIgnoreCase("List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
}
for (CodegenParameter param : op.formParams) {
- if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
+ if (param.baseType != null && param.baseType.equalsIgnoreCase("List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
}
for (CodegenParameter param : op.bodyParams) {
- if (param.baseType != null && param.baseType.equalsIgnoreCase("Uint8List") && isMultipart) {
+ if (param.baseType != null && param.baseType.equalsIgnoreCase("List") && isMultipart) {
param.baseType = "MultipartFile";
param.dataType = "MultipartFile";
}
@@ -274,8 +274,6 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
for (String item : op.imports) {
if (!modelToIgnore.contains(item.toLowerCase(Locale.ROOT))) {
imports.add(underscore(item));
- } else if (item.equalsIgnoreCase("Uint8List")) {
- fullImports.add("dart:typed_data");
}
}
modelImports.addAll(imports);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index fa3893d3219..f548ea530a5 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -78,7 +78,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String RETROFIT_2 = "retrofit2";
public static final String VERTX = "vertx";
- public static final String SERIALIZATION_LIBRARY = "serializationLibrary";
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
@@ -101,7 +100,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected String authFolder;
protected String serializationLibrary = null;
-
public JavaClientCodegen() {
super();
@@ -134,18 +132,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
- supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
- supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x");
- supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
+ supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
+ supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
+ supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.9.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
- supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x");
+ supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
- supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
- supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
- supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
- supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8");
+ supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x");
+ supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x");
+ supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
+ supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.9.x. Only for Java8");
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
@@ -155,7 +153,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(libraryOption);
setLibrary(OKHTTP_GSON);
- CliOption serializationLibrary = new CliOption(SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
+ CliOption serializationLibrary = new CliOption(CodegenConstants.SERIALIZATION_LIBRARY, "Serialization library, default depends from the library");
Map serializationOptions = new HashMap<>();
serializationOptions.put(SERIALIZATION_LIBRARY_GSON, "Use Gson as serialization library");
serializationOptions.put(SERIALIZATION_LIBRARY_JACKSON, "Use Jackson as serialization library");
@@ -295,8 +293,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
"BeanValidationException.java"));
}
- if (additionalProperties.containsKey(SERIALIZATION_LIBRARY)) {
- setSerializationLibrary(additionalProperties.get(SERIALIZATION_LIBRARY).toString());
+ if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
+ setSerializationLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
}
//TODO: add doc to retrofit1 and feign
@@ -372,12 +370,19 @@ public class JavaClientCodegen extends AbstractJavaCodegen
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
} else if (REST_ASSURED.equals(getLibrary())) {
- forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
+ if(getSerializationLibrary() == null) {
+ LOGGER.info("No serializationLibrary configured, using '"+SERIALIZATION_LIBRARY_GSON+"' as fallback");
+ setSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
+ }
+ if(SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary())) {
+ supportingFiles.add(new SupportingFile("JacksonObjectMapper.mustache", invokerFolder, "JacksonObjectMapper.java"));
+ } else if (SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary())) {
+ supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
+ supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
+ }
additionalProperties.put("convert", new CaseFormatLambda(LOWER_CAMEL, UPPER_UNDERSCORE));
apiTemplateFiles.put("api.mustache", ".java");
supportingFiles.add(new SupportingFile("ResponseSpecBuilders.mustache", invokerFolder, "ResponseSpecBuilders.java"));
- supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
- supportingFiles.add(new SupportingFile("GsonObjectMapper.mustache", invokerFolder, "GsonObjectMapper.java"));
} else {
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java
index 8b7736fce32..42251432c29 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java
@@ -239,6 +239,9 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public String toApiName(final String name) {
String computed = name;
if (computed.length() == 0) {
+ if (primaryResourceName == null) {
+ return "DefaultApi";
+ }
return primaryResourceName + "Api";
}
computed = sanitizeName(computed);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
index adb1eba7cf1..a0a92778058 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java
@@ -19,21 +19,42 @@ package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenModel;
+import org.openapitools.codegen.CodegenOperation;
+import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
public class KotlinClientCodegen extends AbstractKotlinCodegen {
+ protected static final String VENDOR_EXTENSION_ESCAPED_NAME = "x-escapedName";
+
+ protected static final String JVM = "jvm";
+ protected static final String MULTIPLATFORM = "multiplatform";
+
public static final String DATE_LIBRARY = "dateLibrary";
public static final String COLLECTION_TYPE = "collectionType";
protected String dateLibrary = DateLibrary.JAVA8.value;
protected String collectionType = CollectionType.ARRAY.value;
+ // https://kotlinlang.org/docs/reference/grammar.html#Identifier
+ protected static final Pattern IDENTIFIER_PATTERN =
+ Pattern.compile("[\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}_][\\p{Ll}\\p{Lm}\\p{Lo}\\p{Lt}\\p{Lu}\\p{Nl}\\p{Nd}_]*");
+
+ // https://kotlinlang.org/docs/reference/grammar.html#Identifier
+ protected static final String IDENTIFIER_REPLACEMENTS =
+ "[.;:/\\[\\]<>]";
+
public enum DateLibrary {
STRING("string"),
THREETENBP("threetenbp"),
@@ -81,9 +102,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
Map dateOptions = new HashMap<>();
- dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp");
+ dateOptions.put(DateLibrary.THREETENBP.value, "Threetenbp (jvm only)");
dateOptions.put(DateLibrary.STRING.value, "String");
- dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310");
+ dateOptions.put(DateLibrary.JAVA8.value, "Java 8 native JSR310 (jvm only)");
dateLibrary.setEnum(dateOptions);
dateLibrary.setDefault(this.dateLibrary);
cliOptions.add(dateLibrary);
@@ -95,6 +116,15 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
collectionType.setEnum(collectionOptions);
collectionType.setDefault(this.collectionType);
cliOptions.add(collectionType);
+
+ supportedLibraries.put(JVM, "Platform: Java Virtual Machine. HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1.");
+ supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.2.4. JSON processing: Kotlinx Serialization: 0.12.0.");
+
+ CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
+ libraryOption.setEnum(supportedLibraries);
+ libraryOption.setDefault(JVM);
+ cliOptions.add(libraryOption);
+ setLibrary(JVM);
}
public CodegenType getTag() {
@@ -121,10 +151,80 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
public void processOpts() {
super.processOpts();
+ if (MULTIPLATFORM.equals(getLibrary())) {
+ sourceFolder = "src/commonMain/kotlin";
+ }
+
+ // infrastructure destination folder
+ final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
+
+ // additional properties
if (additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
}
+ // common (jvm/multiplatform) supporting files
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
+ supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
+ supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
+
+ if (JVM.equals(getLibrary())) {
+ additionalProperties.put(JVM, true);
+
+ // jvm specific supporting files
+ supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
+ supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
+
+ } else if (MULTIPLATFORM.equals(getLibrary())) {
+ additionalProperties.put(MULTIPLATFORM, true);
+ setDateLibrary(DateLibrary.STRING.value);
+
+ // multiplatform default includes
+ defaultIncludes.add("io.ktor.client.request.forms.InputProvider");
+
+ // multiplatform type mapping
+ typeMapping.put("number", "kotlin.Double");
+ typeMapping.put("file", "InputProvider");
+
+ // multiplatform import mapping
+ importMapping.put("BigDecimal", "kotlin.Double");
+ importMapping.put("UUID", "kotlin.String");
+ importMapping.put("URI", "kotlin.String");
+ importMapping.put("InputProvider", "io.ktor.client.request.forms.InputProvider");
+ importMapping.put("File", "io.ktor.client.request.forms.InputProvider");
+ importMapping.put("Timestamp", "kotlin.String");
+ importMapping.put("LocalDateTime", "kotlin.String");
+ importMapping.put("LocalDate", "kotlin.String");
+ importMapping.put("LocalTime", "kotlin.String");
+
+ // multiplatform specific supporting files
+ supportingFiles.add(new SupportingFile("infrastructure/HttpResponse.kt.mustache", infrastructureFolder, "HttpResponse.kt"));
+
+ // multiplatform specific testing files
+ final String testFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
+ supportingFiles.add(new SupportingFile("commonTest/coroutine.mustache", "src/commonTest/kotlin/util", "Coroutine.kt"));
+ supportingFiles.add(new SupportingFile("iosTest/coroutine.mustache", "src/iosTest/kotlin/util", "Coroutine.kt"));
+ supportingFiles.add(new SupportingFile("jvmTest/coroutine.mustache", "src/jvmTest/kotlin/util", "Coroutine.kt"));
+
+ // gradle wrapper supporting files
+ supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
+ supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.properties"));
+ supportingFiles.add(new SupportingFile("gradle-wrapper.jar", "gradle.wrapper".replace(".", File.separator), "gradle-wrapper.jar"));
+ }
+
+ // date library processing
if (DateLibrary.THREETENBP.value.equals(dateLibrary)) {
additionalProperties.put(DateLibrary.THREETENBP.value, true);
typeMapping.put("date", "LocalDate");
@@ -151,25 +251,83 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
typeMapping.put("list", "kotlin.collections.List");
additionalProperties.put("isList", true);
}
+ }
- supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
- supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
- supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
+ @Override
+ public Map postProcessModels(Map objs) {
+ objs = super.postProcessModels(objs);
+ return postProcessModelsEscapeNames(objs);
+ }
- final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
+ @SuppressWarnings("unchecked")
+ private static Map postProcessModelsEscapeNames(Map objs) {
+ List models = (List) objs.get("models");
+ for (Object _mo : models) {
+ Map mo = (Map) _mo;
+ CodegenModel cm = (CodegenModel) mo.get("model");
- supportingFiles.add(new SupportingFile("infrastructure/ApiClient.kt.mustache", infrastructureFolder, "ApiClient.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/ApiAbstractions.kt.mustache", infrastructureFolder, "ApiAbstractions.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/ApiInfrastructureResponse.kt.mustache", infrastructureFolder, "ApiInfrastructureResponse.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/ApplicationDelegates.kt.mustache", infrastructureFolder, "ApplicationDelegates.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/RequestConfig.kt.mustache", infrastructureFolder, "RequestConfig.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/RequestMethod.kt.mustache", infrastructureFolder, "RequestMethod.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/LocalDateAdapter.kt.mustache", infrastructureFolder, "LocalDateAdapter.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/LocalDateTimeAdapter.kt.mustache", infrastructureFolder, "LocalDateTimeAdapter.kt"));
- supportingFiles.add(new SupportingFile("infrastructure/UUIDAdapter.kt.mustache", infrastructureFolder, "UUIDAdapter.kt"));
+ if (cm.vars != null) {
+ for (CodegenProperty var : cm.vars) {
+ var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
+ }
+ }
+ if (cm.requiredVars != null) {
+ for (CodegenProperty var : cm.requiredVars) {
+ var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
+ }
+ }
+ if (cm.optionalVars != null) {
+ for (CodegenProperty var : cm.optionalVars) {
+ var.vendorExtensions.put(VENDOR_EXTENSION_ESCAPED_NAME, escapeIdentifier(var.name));
+ }
+ }
+ }
+ return objs;
+ }
+
+ private static String escapeIdentifier(String identifier) {
+
+ // the kotlin grammar permits a wider set of characters in their identifiers that all target
+ // platforms permit (namely jvm). in order to remain compatible with target platforms, we
+ // initially replace all illegal target characters before escaping the identifier if required.
+ identifier = identifier.replaceAll(IDENTIFIER_REPLACEMENTS, "_");
+ if (IDENTIFIER_PATTERN.matcher(identifier).matches()) return identifier;
+ return '`' + identifier + '`';
+ }
+
+ private static void removeDuplicates(List list) {
+ Set set = new HashSet<>();
+ Iterator iterator = list.iterator();
+ while (iterator.hasNext()) {
+ CodegenProperty item = iterator.next();
+ if (set.contains(item.name)) iterator.remove();
+ else set.add(item.name);
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Map postProcessOperationsWithModels(Map objs, List allModels) {
+ super.postProcessOperationsWithModels(objs, allModels);
+ Map operations = (Map) objs.get("operations");
+ if (operations != null) {
+ List ops = (List) operations.get("operation");
+ for (CodegenOperation operation : ops) {
+ if (operation.hasConsumes == Boolean.TRUE) {
+ if (isMultipartType(operation.consumes)) {
+ operation.isMultipart = Boolean.TRUE;
+ }
+ }
+ }
+ }
+ return operations;
+ }
+
+ private static boolean isMultipartType(List> consumes) {
+ Map firstType = consumes.get(0);
+ if (firstType != null) {
+ return "multipart/form-data".equals(firstType.get("mediaType"));
+ }
+ return false;
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinVertxServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinVertxServerCodegen.java
new file mode 100644
index 00000000000..36fddf1812a
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinVertxServerCodegen.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.SupportingFile;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Locale;
+
+public class KotlinVertxServerCodegen extends AbstractKotlinCodegen {
+
+ protected String rootPackage = "org.openapitools.server.api";
+ protected String apiVersion = "1.0.0-SNAPSHOT";
+
+ public static final String ROOT_PACKAGE = "rootPackage";
+
+ public static final String PROJECT_NAME = "projectName";
+
+ static Logger LOGGER = LoggerFactory.getLogger(KotlinVertxServerCodegen.class);
+
+ public CodegenType getTag() {
+ return CodegenType.SERVER;
+ }
+
+ public String getName() {
+ return "kotlin-vertx";
+ }
+
+ public String getHelp() {
+ return "Generates a kotlin-vertx server.";
+ }
+
+ public KotlinVertxServerCodegen() {
+ super();
+
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.BETA)
+ .build();
+
+ outputFolder = "generated-code" + File.separator + "kotlin-vertx";
+ modelTemplateFiles.put("model.mustache", ".kt");
+
+ apiTestTemplateFiles.clear();
+ modelDocTemplateFiles.clear();
+ supportingFiles.clear();
+
+ apiTemplateFiles.clear();
+ apiTemplateFiles.put("api.mustache", ".kt");
+ apiTemplateFiles.put("apiProxy.mustache", "VertxProxyHandler.kt");
+ apiTemplateFiles.put("api_verticle.mustache", "Verticle.kt");
+
+ embeddedTemplateDir = templateDir = "kotlin-vertx-server";
+ apiPackage = rootPackage + ".verticle";
+ modelPackage = rootPackage + ".model";
+ artifactId = "openapi-kotlin-vertx-server";
+ artifactVersion = apiVersion;
+
+ updateOption(CodegenConstants.API_PACKAGE, apiPackage);
+ updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
+ additionalProperties.put(ROOT_PACKAGE, rootPackage);
+
+ supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+
+ }
+
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
new file mode 100644
index 00000000000..939f7e62498
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NimClientCodegen.java
@@ -0,0 +1,331 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.StringSchema;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.utils.ModelUtils;
+import org.openapitools.codegen.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.*;
+
+import static org.openapitools.codegen.utils.StringUtils.camelize;
+import static org.openapitools.codegen.utils.StringUtils.underscore;
+
+public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
+ static Logger LOGGER = LoggerFactory.getLogger(NimClientCodegen.class);
+
+ public static final String PROJECT_NAME = "projectName";
+
+ protected String packageName = "openapiclient";
+ protected String packageVersion = "1.0.0";
+
+ public CodegenType getTag() {
+ return CodegenType.CLIENT;
+ }
+
+ public String getName() {
+ return "nim";
+ }
+
+ public String getHelp() {
+ return "Generates a nim client (beta).";
+ }
+
+ public NimClientCodegen() {
+ super();
+
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.BETA)
+ .build();
+
+ outputFolder = "generated-code" + File.separator + "nim";
+ modelTemplateFiles.put("model.mustache", ".nim");
+ apiTemplateFiles.put("api.mustache", ".nim");
+ embeddedTemplateDir = templateDir = "nim-client";
+ apiPackage = File.separator + packageName + File.separator + "apis";
+ modelPackage = File.separator + packageName + File.separator + "models";
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ supportingFiles.add(new SupportingFile("sample_client.mustache", "", "sample_client.nim"));
+ supportingFiles.add(new SupportingFile("config.mustache", "", "config.nim"));
+
+ setReservedWordsLowerCase(
+ Arrays.asList(
+ "addr", "and", "as", "asm",
+ "bind", "block", "break",
+ "case", "cast", "concept", "const", "continue", "converter",
+ "defer", "discard", "distinct", "div", "do",
+ "elif", "else", "end", "enum", "except", "export",
+ "finally", "for", "from", "func",
+ "if", "import", "in", "include", "interface", "is", "isnot", "iterator",
+ "let",
+ "macro", "method", "mixin", "mod",
+ "nil", "not", "notin",
+ "object", "of", "or", "out",
+ "proc", "ptr",
+ "raise", "ref", "return",
+ "shl", "shr", "static",
+ "template", "try", "tuple", "type",
+ "using",
+ "var",
+ "when", "while",
+ "xor",
+ "yield"
+ )
+ );
+
+ defaultIncludes = new HashSet(
+ Arrays.asList(
+ "array"
+ )
+ );
+
+ languageSpecificPrimitives = new HashSet(
+ Arrays.asList(
+ "int",
+ "int8",
+ "int16",
+ "int32",
+ "int64",
+ "uint",
+ "uint8",
+ "uint16",
+ "uint32",
+ "uint64",
+ "float",
+ "float32",
+ "float64",
+ "bool",
+ "char",
+ "string",
+ "cstring",
+ "pointer")
+ );
+
+ typeMapping.clear();
+ typeMapping.put("integer", "int");
+ typeMapping.put("long", "int64");
+ typeMapping.put("number", "float");
+ typeMapping.put("float", "float");
+ typeMapping.put("double", "float64");
+ typeMapping.put("boolean", "bool");
+ typeMapping.put("UUID", "string");
+ typeMapping.put("URI", "string");
+ typeMapping.put("date", "string");
+ typeMapping.put("DateTime", "string");
+ typeMapping.put("password", "string");
+ typeMapping.put("file", "string");
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public void setPackageVersion(String packageVersion) {
+ this.packageVersion = packageVersion;
+ }
+
+ @Override
+ public Map postProcessModels(Map objs) {
+ return postProcessModelsEnum(objs);
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
+ setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
+ }
+
+ if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
+ setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
+ }
+
+ additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
+ additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
+
+ apiPackage = File.separator + packageName + File.separator + "apis";
+ modelPackage = File.separator + packageName + File.separator + "models";
+ supportingFiles.add(new SupportingFile("lib.mustache", "", packageName + ".nim"));
+ }
+
+ @Override
+ public String escapeReservedWord(String name) {
+ LOGGER.warn("A reserved word \"" + name + "\" is used. Consider renaming the field name");
+ if (this.reservedWordsMappings().containsKey(name)) {
+ return this.reservedWordsMappings().get(name);
+ }
+ return "`" + name + "`";
+ }
+
+ @Override
+ public String escapeQuotationMark(String input) {
+ return input.replace("\"", "");
+ }
+
+ @Override
+ public String escapeUnsafeCharacters(String input) {
+ return input.replace("*/", "*_/").replace("/*", "/_*");
+ }
+
+ @Override
+ public String toModelImport(String name) {
+ name = name.replaceAll("-", "_");
+ if (importMapping.containsKey(name)) {
+ return "model_" + StringUtils.underscore(importMapping.get(name));
+ } else {
+ return "model_" + StringUtils.underscore(name);
+ }
+ }
+
+ @Override
+ public String toApiImport(String name) {
+ name = name.replaceAll("-", "_");
+ if (importMapping.containsKey(name)) {
+ return "api_" + StringUtils.underscore(importMapping.get(name));
+ } else {
+ return "api_" + StringUtils.underscore(name);
+ }
+ }
+
+ @Override
+ public String toModelFilename(String name) {
+ name = name.replaceAll("-", "_");
+ return "model_" + StringUtils.underscore(name);
+ }
+
+ @Override
+ public String toApiFilename(String name) {
+ name = name.replaceAll("-", "_");
+ return "api_" + StringUtils.underscore(name);
+ }
+
+ @Override
+ public String toOperationId(String operationId) {
+ String sanitizedOperationId = sanitizeName(operationId);
+
+ if (isReservedWord(sanitizedOperationId)) {
+ sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId, false);
+ }
+
+ return StringUtils.camelize(sanitizedOperationId, true);
+ }
+
+ @Override
+ public Map postProcessOperationsWithModels(Map objs, List allModels) {
+ @SuppressWarnings("unchecked")
+ Map objectMap = (Map) objs.get("operations");
+ @SuppressWarnings("unchecked")
+ List operations = (List) objectMap.get("operation");
+ for (CodegenOperation operation : operations) {
+ operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
+ }
+
+ return objs;
+ }
+
+ @Override
+ public String getTypeDeclaration(Schema p) {
+ if (ModelUtils.isArraySchema(p)) {
+ ArraySchema ap = (ArraySchema) p;
+ Schema inner = ap.getItems();
+ if (inner == null) {
+ return null;
+ }
+ return "seq[" + getTypeDeclaration(inner) + "]";
+ } else if (ModelUtils.isMapSchema(p)) {
+ Schema inner = ModelUtils.getAdditionalProperties(p);
+ if (inner == null) {
+ inner = new StringSchema();
+ }
+ return "Table[string, " + getTypeDeclaration(inner) + "]";
+ }
+
+ String schemaType = getSchemaType(p);
+ if (typeMapping.containsKey(schemaType)) {
+ return typeMapping.get(schemaType);
+ }
+
+ if (schemaType.matches("\\d.*")) { // starts with number
+ return "`" + schemaType + "`";
+ } else {
+ return schemaType;
+ }
+ }
+
+ @Override
+ public String toVarName(String name) {
+ if (isReservedWord(name)) {
+ name = escapeReservedWord(name);
+ }
+
+ if (name.matches("^\\d.*")) {
+ name = "`" + name + "`";
+ }
+
+ return name;
+ }
+
+ @Override
+ public String toParamName(String name) {
+ return toVarName(name);
+ }
+
+ @Override
+ protected boolean needToImport(String type) {
+ if (defaultIncludes.contains(type)) {
+ return false;
+ } else if (languageSpecificPrimitives.contains(type)) {
+ return false;
+ } else if (typeMapping.containsKey(type) && languageSpecificPrimitives.contains(typeMapping.get(type))) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public String toEnumName(CodegenProperty property) {
+ String name = StringUtils.camelize(property.name, false);
+
+ if (name.matches("\\d.*")) { // starts with number
+ return "`" + name + "`";
+ } else {
+ return name;
+ }
+ }
+
+ @Override
+ public String toEnumVarName(String name, String datatype) {
+ name = name.replace(" ", "_");
+ name = StringUtils.camelize(name, false);
+
+ if (name.matches("\\d.*")) { // starts with number
+ return "`" + name + "`";
+ } else {
+ return name;
+ }
+ }
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
index 19a4b60d05b..9b9dd6ce409 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSExpressServerCodegen.java
@@ -163,11 +163,11 @@ public class NodeJSExpressServerCodegen extends DefaultCodegen implements Codege
if (templateName.equals("service.mustache")) {
String stringToMatch = File.separator + "controllers" + File.separator;
String replacement = File.separator + implFolder + File.separator;
- result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
-
+ result = result.replace(stringToMatch, replacement);
+
stringToMatch = "Controller.js";
replacement = "Service.js";
- result = result.replaceAll(Pattern.quote(stringToMatch), replacement);
+ result = result.replace(stringToMatch, replacement);
}
return result;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java
new file mode 100644
index 00000000000..93b7faf09e1
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java
@@ -0,0 +1,458 @@
+/*
+ * Copyright 2019 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen.languages;
+
+import io.swagger.v3.oas.models.media.ArraySchema;
+import io.swagger.v3.oas.models.media.Schema;
+
+import org.openapitools.codegen.CliOption;
+import org.openapitools.codegen.CodegenConfig;
+import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenType;
+import org.openapitools.codegen.*;
+import org.openapitools.codegen.meta.GeneratorMetadata;
+import org.openapitools.codegen.meta.Stability;
+import org.openapitools.codegen.utils.ProcessUtils;
+import org.openapitools.codegen.utils.ModelUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import static org.openapitools.codegen.utils.StringUtils.camelize;
+import static org.openapitools.codegen.utils.StringUtils.underscore;
+
+public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConfig {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ProtobufSchemaCodegen.class);
+
+ protected String packageName = "openapitools";
+
+ @Override
+ public CodegenType getTag() {
+ return CodegenType.CONFIG;
+ }
+
+ public String getName() {
+ return "protobuf-schema";
+ }
+
+ public String getHelp() {
+ return "Generates gRPC and protocol buffer schema files (beta)";
+ }
+
+ public ProtobufSchemaCodegen() {
+ super();
+
+ generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
+ .stability(Stability.BETA)
+ .build();
+
+ outputFolder = "generated-code/protobuf-schema";
+ modelTemplateFiles.put("model.mustache", ".proto");
+ apiTemplateFiles.put("api.mustache", ".proto");
+ embeddedTemplateDir = templateDir = "protobuf-schema";
+ hideGenerationTimestamp = Boolean.TRUE;
+ modelPackage = "messages";
+ apiPackage = "services";
+
+ /*setReservedWordsLowerCase(
+ Arrays.asList(
+ // data type
+ "nil", "string", "boolean", "number", "userdata", "thread",
+ "table",
+
+ // reserved words: http://www.lua.org/manual/5.1/manual.html#2.1
+ "and", "break", "do", "else", "elseif",
+ "end", "false", "for", "function", "if",
+ "in", "local", "nil", "not", "or",
+ "repeat", "return", "then", "true", "until", "while"
+ )
+ );*/
+
+ defaultIncludes = new HashSet(
+ Arrays.asList(
+ "map",
+ "array")
+ );
+
+ languageSpecificPrimitives = new HashSet(
+ Arrays.asList(
+ "map",
+ "array",
+ "bool",
+ "bytes",
+ "string",
+ "int32",
+ "int64",
+ "uint32",
+ "uint64",
+ "sint32",
+ "sint64",
+ "fixed32",
+ "fixed64",
+ "sfixed32",
+ "sfixed64",
+ "float",
+ "double")
+ );
+
+ instantiationTypes.clear();
+ instantiationTypes.put("array", "repeat");
+ //instantiationTypes.put("map", "map");
+
+ // ref: https://developers.google.com/protocol-buffers/docs/proto
+ typeMapping.clear();
+ typeMapping.put("array", "array");
+ typeMapping.put("map", "map");
+ typeMapping.put("integer", "int32");
+ typeMapping.put("long", "int64");
+ typeMapping.put("number", "float");
+ typeMapping.put("float", "float");
+ typeMapping.put("double", "double");
+ typeMapping.put("boolean", "bool");
+ typeMapping.put("string", "string");
+ typeMapping.put("UUID", "string");
+ typeMapping.put("URI", "string");
+ typeMapping.put("date", "string");
+ typeMapping.put("DateTime", "string");
+ typeMapping.put("password", "string");
+ // TODO fix file mapping
+ typeMapping.put("file", "string");
+ typeMapping.put("binary", "string");
+ typeMapping.put("ByteArray", "bytes");
+ typeMapping.put("object", "TODO_OBJECT_MAPPING");
+
+ importMapping.clear();
+ /*
+ importMapping = new HashMap();
+ importMapping.put("time.Time", "time");
+ importMapping.put("*os.File", "os");
+ importMapping.put("os", "io/ioutil");
+ */
+
+ modelDocTemplateFiles.put("model_doc.mustache", ".md");
+ apiDocTemplateFiles.put("api_doc.mustache", ".md");
+
+ cliOptions.clear();
+ /*cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "GraphQL package name (convention: lowercase).")
+ .defaultValue("openapi2graphql"));
+ cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "GraphQL package version.")
+ .defaultValue("1.0.0"));
+ cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
+ .defaultValue(Boolean.TRUE.toString()));*/
+
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+
+ //apiTestTemplateFiles.put("api_test.mustache", ".proto");
+ //modelTestTemplateFiles.put("model_test.mustache", ".proto");
+
+ apiDocTemplateFiles.clear(); // TODO: add api doc template
+ modelDocTemplateFiles.clear(); // TODO: add model doc template
+
+ modelPackage = "models";
+ apiPackage = "services";
+
+ if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
+ setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
+ }
+
+ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
+ //supportingFiles.add(new SupportingFile("root.mustache", "", packageName + ".proto"));
+ //supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
+ //supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"))
+ //supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
+ }
+
+ @Override
+ public String toOperationId(String operationId) {
+ // throw exception if method name is empty (should not occur as an auto-generated method name will be used)
+ if (StringUtils.isEmpty(operationId)) {
+ throw new RuntimeException("Empty method name (operationId) not allowed");
+ }
+
+ // method name cannot use reserved keyword, e.g. return
+ if (isReservedWord(operationId)) {
+ LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
+ operationId = "call_" + operationId;
+ }
+
+ return camelize(sanitizeName(operationId));
+ }
+
+ @Override
+ public Map postProcessModels(Map objs) {
+ objs = postProcessModelsEnum(objs);
+ List models = (List) objs.get("models");
+ // add x-index to properties
+ ProcessUtils.addIndexToProperties(models, 1);
+
+ for (Object _mo : models) {
+ Map mo = (Map) _mo;
+ CodegenModel cm = (CodegenModel) mo.get("model");
+
+ for (CodegenProperty var : cm.vars) {
+ // add x-protobuf-type: repeated if it's an array
+ if (Boolean.TRUE.equals(var.isListContainer)) {
+ var.vendorExtensions.put("x-protobuf-type", "repeated");
+ }
+
+ // add x-protobuf-data-type
+ // ref: https://developers.google.com/protocol-buffers/docs/proto3
+ if (!var.vendorExtensions.containsKey("x-protobuf-data-type")) {
+ if (var.isListContainer) {
+ var.vendorExtensions.put("x-protobuf-data-type", var.items.dataType);
+ } else {
+ var.vendorExtensions.put("x-protobuf-data-type", var.dataType);
+ }
+ }
+
+ if (var.isEnum && var.allowableValues.containsKey("enumVars")) {
+ List> enumVars = (List>) var.allowableValues.get("enumVars");
+ int enumIndex = 0;
+ for (Map enumVar : enumVars) {
+ enumVar.put("protobuf-enum-index", enumIndex);
+ enumIndex++;
+ }
+ }
+ }
+ }
+ return objs;
+ }
+
+ @Override
+ public String escapeUnsafeCharacters(String input) {
+ return input;
+ }
+
+ @Override
+ public String escapeQuotationMark(String input) {
+ return input;
+ }
+
+ /**
+ * Return the default value of the property
+ *
+ * @param p OpenAPI property object
+ * @return string presentation of the default value of the property
+ */
+ @Override
+ public String toDefaultValue(Schema p) {
+ if (ModelUtils.isBooleanSchema(p)) {
+ if (p.getDefault() != null) {
+ if (Boolean.valueOf(p.getDefault().toString()) == false)
+ return "false";
+ else
+ return "true";
+ }
+ } else if (ModelUtils.isDateSchema(p)) {
+ // TODO
+ } else if (ModelUtils.isDateTimeSchema(p)) {
+ // TODO
+ } else if (ModelUtils.isNumberSchema(p)) {
+ if (p.getDefault() != null) {
+ return p.getDefault().toString();
+ }
+ } else if (ModelUtils.isIntegerSchema(p)) {
+ if (p.getDefault() != null) {
+ return p.getDefault().toString();
+ }
+ } else if (ModelUtils.isStringSchema(p)) {
+ if (p.getDefault() != null) {
+ if (Pattern.compile("\r\n|\r|\n").matcher((String) p.getDefault()).find())
+ return "'''" + p.getDefault() + "'''";
+ else
+ return "'" + p.getDefault() + "'";
+ }
+ } else if (ModelUtils.isArraySchema(p)) {
+ if (p.getDefault() != null) {
+ return p.getDefault().toString();
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String apiFileFolder() {
+ return outputFolder + File.separatorChar + apiPackage;
+ }
+
+ @Override
+ public String modelFileFolder() {
+ return outputFolder + File.separatorChar + modelPackage;
+ }
+
+ @Override
+ public String toApiFilename(String name) {
+ // replace - with _ e.g. created-at => created_at
+ name = name.replaceAll("-", "_");
+
+ // e.g. PhoneNumber => phone_number
+ return underscore(name) + "_service";
+ }
+
+ @Override
+ public String toApiName(String name) {
+ if (name.length() == 0) {
+ return "DefaultService";
+ }
+ // e.g. phone_number => PhoneNumber
+ return camelize(name) + "Service";
+ }
+
+ @Override
+ public String toApiVarName(String name) {
+ if (name.length() == 0) {
+ return "default_service";
+ }
+ return underscore(name) + "_service";
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ @Override
+ public String toModelFilename(String name) {
+ // underscore the model file name
+ // PhoneNumber => phone_number
+ return underscore(toModelName(name));
+ }
+
+ @Override
+ public String toModelName(String name) {
+ name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
+ // remove dollar sign
+ name = name.replaceAll("$", "");
+
+ // model name cannot use reserved keyword, e.g. return
+ if (isReservedWord(name)) {
+ LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ name = "model_" + name; // e.g. return => ModelReturn (after camelize)
+ }
+
+ // model name starts with number
+ if (name.matches("^\\d.*")) {
+ LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
+ name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
+ }
+
+ if (!StringUtils.isEmpty(modelNamePrefix)) {
+ name = modelNamePrefix + "_" + name;
+ }
+
+ if (!StringUtils.isEmpty(modelNameSuffix)) {
+ name = name + "_" + modelNameSuffix;
+ }
+
+ // camelize the model name
+ // phone_number => PhoneNumber
+ return camelize(name);
+ }
+
+ @Override
+ public String getSchemaType(Schema p) {
+ String schemaType = super.getSchemaType(p);
+ String type = null;
+ if (typeMapping.containsKey(schemaType)) {
+ type = typeMapping.get(schemaType);
+ if (languageSpecificPrimitives.contains(type)) {
+ return type;
+ }
+ } else {
+ type = toModelName(schemaType);
+ }
+ return type;
+ }
+
+ @Override
+ public Map postProcessOperationsWithModels(Map objs, List allModels) {
+ Map operations = (Map) objs.get("operations");
+ List operationList = (List) operations.get("operation");
+ for (CodegenOperation op : operationList) {
+ int index = 1;
+ for (CodegenParameter p : op.allParams) {
+ // add x-protobuf-type: repeated if it's an array
+ if (Boolean.TRUE.equals(p.isListContainer)) {
+ p.vendorExtensions.put("x-protobuf-type", "repeated");
+ } else if (Boolean.TRUE.equals(p.isMapContainer)) {
+ LOGGER.warn("Map parameter (name: {}, operation ID: {}) not yet supported", p.paramName, op.operationId);
+ }
+
+ // add x-protobuf-data-type
+ // ref: https://developers.google.com/protocol-buffers/docs/proto3
+ if (!p.vendorExtensions.containsKey("x-protobuf-data-type")) {
+ if (Boolean.TRUE.equals(p.isListContainer)) {
+ p.vendorExtensions.put("x-protobuf-data-type", p.items.dataType);
+ } else {
+ p.vendorExtensions.put("x-protobuf-data-type", p.dataType);
+ }
+ }
+
+ p.vendorExtensions.put("x-index", index);
+ index++;
+ }
+
+ if (StringUtils.isEmpty(op.returnType)) {
+ op.vendorExtensions.put("x-grpc-response", "google.protobuf.Empty");
+ } else {
+ if (Boolean.FALSE.equals(op.returnTypeIsPrimitive) && StringUtils.isEmpty(op.returnContainer)) {
+ op.vendorExtensions.put("x-grpc-response", op.returnType);
+ } else {
+ if ("map".equals(op.returnContainer)) {
+ LOGGER.warn("Map response (operation ID: {}) not yet supported", op.operationId);
+ op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
+ } else if ("array".equals(op.returnContainer)) {
+ op.vendorExtensions.put("x-grpc-response-type", "repeated " + op.returnBaseType);
+ } else { // primitive type
+ op.vendorExtensions.put("x-grpc-response-type", op.returnBaseType);
+ }
+ }
+ }
+ }
+
+ return objs;
+ }
+
+ @Override
+ public String toModelImport(String name) {
+ return underscore(name);
+ }
+
+ @Override
+ public String getTypeDeclaration(Schema p) {
+ if (ModelUtils.isArraySchema(p)) {
+ ArraySchema ap = (ArraySchema) p;
+ Schema inner = ap.getItems();
+ return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
+ } else if (ModelUtils.isMapSchema(p)) {
+ Schema inner = ModelUtils.getAdditionalProperties(p);
+ return getSchemaType(p) + "[str, " + getTypeDeclaration(inner) + "]";
+ }
+ return super.getTypeDeclaration(p);
+ }
+}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
index 9ebb1df10f2..9e227b3eee0 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java
@@ -909,6 +909,12 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("usesXmlNamespaces", true);
}
+ Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
+
+ if (additionalProperties != null) {
+ mdl.additionalPropertiesType = getSchemaType(additionalProperties);
+ }
+
return mdl;
}
@@ -1123,20 +1129,34 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// 'null'. This ensures that we treat this model as a struct
// with multiple parameters.
cm.dataType = null;
- } else if (cm.dataType != null) {
- if (cm.dataType.equals("map")) {
- // We don't yet support `additionalProperties`. We ignore
- // the `additionalProperties` type ('map') and warn the
- // user. This will produce code that compiles, but won't
- // feature the `additionalProperties`.
+ } else if (cm.dataType != null && cm.dataType.equals("map")) {
+ if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
+ // We don't yet support `additionalProperties` that also have
+ // properties. If we see variables, we ignore the
+ // `additionalProperties` type ('map') and warn the user. This
+ // will produce code that compiles, but won't feature the
+ // `additionalProperties` - but that's likely more useful to
+ // the user than the alternative.
+ LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties");
cm.dataType = null;
- LOGGER.warn("Ignoring unsupported additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318)");
- } else {
- // We need to hack about with single-parameter models to
- // get them recognised correctly.
- cm.isAlias = false;
- cm.dataType = typeMapping.get(cm.dataType);
}
+ else
+ {
+ String type;
+
+ if (typeMapping.containsKey(cm.additionalPropertiesType)) {
+ type = typeMapping.get(cm.additionalPropertiesType);
+ } else {
+ type = toModelName(cm.additionalPropertiesType);
+ }
+
+ cm.dataType = "HashMap";
+ }
+ } else if (cm.dataType != null) {
+ // We need to hack about with single-parameter models to
+ // get them recognised correctly.
+ cm.isAlias = false;
+ cm.dataType = typeMapping.get(cm.dataType);
}
cm.vendorExtensions.put("isString", "String".equals(cm.dataType));
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
index cae047d280d..55201fadb2f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
@@ -67,6 +67,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
super();
this.outputFolder = "generated-code/typescript-angular";
+ supportsMultipleInheritance = true;
+
embeddedTemplateDir = templateDir = "typescript-angular";
modelTemplateFiles.put("model.mustache", ".ts");
apiTemplateFiles.put("api.service.mustache", ".ts");
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
index 3e21ef9f864..3e27363508b 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
@@ -34,12 +34,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public static final String WITH_INTERFACES = "withInterfaces";
public static final String USE_SINGLE_REQUEST_PARAMETER = "useSingleRequestParameter";
public static final String PREFIX_PARAMETER_INTERFACES = "prefixParameterInterfaces";
+ public static final String TYPESCRIPT_THREE_PLUS = "typescriptThreePlus";
protected String npmRepository = null;
private boolean useSingleRequestParameter = true;
private boolean prefixParameterInterfaces = false;
protected boolean addedApiIndex = false;
protected boolean addedModelIndex = false;
+ protected boolean typescriptThreePlus = false;
public TypeScriptFetchClientCodegen() {
@@ -62,6 +64,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(USE_SINGLE_REQUEST_PARAMETER, "Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
this.cliOptions.add(new CliOption(PREFIX_PARAMETER_INTERFACES, "Setting this property to true will generate parameter interface declarations prefixed with API class name to avoid name conflicts.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
+ this.cliOptions.add(new CliOption(TYPESCRIPT_THREE_PLUS, "Setting this property to true will generate TypeScript 3.6+ compatible code.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
}
@Override
@@ -82,6 +85,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.npmRepository = npmRepository;
}
+ public Boolean getTypescriptThreePlus() {
+ return typescriptThreePlus;
+ }
+
+ public void setTypescriptThreePlus(Boolean typescriptThreePlus) {
+ this.typescriptThreePlus = typescriptThreePlus;
+ }
+
@Override
public void processOpts() {
super.processOpts();
@@ -105,6 +116,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
if (additionalProperties.containsKey(NPM_NAME)) {
addNpmPackageGeneration();
}
+
+ if (additionalProperties.containsKey(TYPESCRIPT_THREE_PLUS)) {
+ this.setTypescriptThreePlus(convertPropertyToBoolean(TYPESCRIPT_THREE_PLUS));
+ }
}
@Override
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
index ad991f67954..d9cc61cbc03 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java
@@ -359,14 +359,7 @@ public class ModelUtils {
}
public static boolean isArraySchema(Schema schema) {
- if (schema instanceof ArraySchema) {
- return true;
- }
- // assume it's an array if maxItems, minItems is set
- if (schema != null && (schema.getMaxItems() != null || schema.getMinItems() != null)) {
- return true;
- }
- return false;
+ return (schema instanceof ArraySchema);
}
public static boolean isStringSchema(Schema schema) {
@@ -896,6 +889,8 @@ public class ModelUtils {
public static String getParentName(ComposedSchema composedSchema, Map allSchemas) {
List interfaces = getInterfaces(composedSchema);
+ List refedParentNames = new ArrayList<>();
+
if (interfaces != null && !interfaces.isEmpty()) {
for (Schema schema : interfaces) {
// get the actual schema
@@ -911,6 +906,7 @@ public class ModelUtils {
} else {
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
// not a parent since discriminator.propertyName is not set
+ refedParentNames.add(parentName);
}
} else {
// not a ref, doing nothing
@@ -918,6 +914,13 @@ public class ModelUtils {
}
}
+ // parent name only makes sense when there is a single obvious parent
+ if (refedParentNames.size() == 1) {
+ LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " +
+ "and will be removed in a future release. Generating model for {}", composedSchema.getName());
+ return refedParentNames.get(0);
+ }
+
return null;
}
diff --git a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
index c65fb3cea28..9e1142970ee 100644
--- a/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/build.gradle.mustache
@@ -138,6 +138,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
+ jackson-databind-nullable-version = "0.2.0"
jersey_version = "1.19.4"
jodatime_version = "2.9.9"
junit_version = "4.12"
@@ -152,6 +153,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/Java/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/Java/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
index 982faaa4628..febdd5d11bf 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
@@ -122,6 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
{{#threetenbp}}
threepane_version = "2.6.4"
{{/threetenbp}}
@@ -141,6 +142,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
index 84ae616aad6..f01cd1fc70f 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
@@ -122,6 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
google_api_client_version = "1.23.0"
jersey_common_version = "2.25.1"
jodatime_version = "2.9.9"
@@ -140,6 +141,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
index be8c28602dd..76ddf4325e2 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
@@ -304,7 +304,7 @@
UTF-8
1.5.22
- 1.23.0
+ 1.30.2
2.25.1
2.9.9
2.9.9
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
index 3f192edafd8..fdda0dc7ede 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
@@ -121,6 +121,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
{{#supportJava6}}
jersey_version = "2.6"
commons_io_version=2.5
@@ -144,6 +145,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#joda}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version"
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache
index 19ab0fa98c3..1a691ea9482 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/ApiClient.mustache
@@ -13,7 +13,8 @@ import java.util.function.Supplier;
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
import static io.restassured.config.RestAssuredConfig.config;
-import static {{invokerPackage}}.GsonObjectMapper.gson;
+import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
+
{{/fullJavaUtil}}
public class ApiClient {
@@ -42,7 +43,7 @@ public class ApiClient {
public static class Config {
private Supplier reqSpecSupplier = () -> new RequestSpecBuilder()
{{#basePath}}.setBaseUri(BASE_URI){{/basePath}}
- .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())));
+ .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})));
/**
* Use common specification for all operations
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/JacksonObjectMapper.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/JacksonObjectMapper.mustache
new file mode 100644
index 00000000000..9d87ce9ef46
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/JacksonObjectMapper.mustache
@@ -0,0 +1,64 @@
+{{>licenseInfo}}
+
+package {{invokerPackage}};
+
+{{#threetenbp}}
+import org.threeten.bp.*;
+{{/threetenbp}}
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+import org.openapitools.jackson.nullable.JsonNullableModule;
+{{#java8}}
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+{{/java8}}
+{{#joda}}
+import com.fasterxml.jackson.datatype.joda.JodaModule;
+{{/joda}}
+{{#threetenbp}}
+import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
+{{/threetenbp}}
+
+import io.restassured.internal.mapping.Jackson2Mapper;
+import io.restassured.path.json.mapper.factory.Jackson2ObjectMapperFactory;
+
+
+public class JacksonObjectMapper extends Jackson2Mapper {
+
+ private JacksonObjectMapper() {
+ super(createFactory());
+ }
+
+ private static Jackson2ObjectMapperFactory createFactory() {
+ return (cls, charset) -> {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ mapper.setDateFormat(new RFC3339DateFormat());
+ {{#java8}}
+ mapper.registerModule(new JavaTimeModule());
+ {{/java8}}
+ {{#joda}}
+ mapper.registerModule(new JodaModule());
+ {{/joda}}
+ {{#threetenbp}}
+ ThreeTenModule module = new ThreeTenModule();
+ module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
+ module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
+ module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
+ mapper.registerModule(module);
+ {{/threetenbp}}
+ JsonNullableModule jnm = new JsonNullableModule();
+ mapper.registerModule(jnm);
+ return mapper;
+ };
+ }
+
+ public static JacksonObjectMapper jackson() {
+ return new JacksonObjectMapper();
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache
index 75ea07db60a..db803e8f2e1 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache
@@ -2,7 +2,9 @@
package {{package}};
+{{#gson}}
import com.google.gson.reflect.TypeToken;
+{{/gson}}
{{#imports}}import {{import}};
{{/imports}}
@@ -15,6 +17,9 @@ import java.util.Map;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
+{{#jackson}}
+import io.restassured.common.mapper.TypeRef;
+{{/jackson}}
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.swagger.annotations.*;
@@ -24,8 +29,9 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
{{/fullJavaUtil}}
+{{#gson}}
import {{invokerPackage}}.JSON;
-
+{{/gson}}
import static io.restassured.http.Method.*;
@Api(value = "{{{baseName}}}")
@@ -139,8 +145,9 @@ public class {{classname}} {
* @return {{returnType}}
*/
public {{{returnType}}} executeAs(Function handler) {
- Type type = new TypeToken<{{{returnType}}}>(){}.getType();
- return execute(handler).as(type);
+ {{#gson}}Type type = new TypeToken<{{{returnType}}}>(){}.getType();
+ {{/gson}}{{#jackson}}TypeRef<{{{returnType}}}> type = new TypeRef<{{{returnType}}}>(){};
+ {{/jackson}}return execute(handler).as(type);
}
{{/returnType}}
{{#bodyParams}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api_test.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api_test.mustache
index 5c17db415e3..74a1c9f7e8c 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api_test.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api_test.mustache
@@ -20,7 +20,7 @@ import java.util.Map;
{{/fullJavaUtil}}
import static io.restassured.config.ObjectMapperConfig.objectMapperConfig;
import static io.restassured.config.RestAssuredConfig.config;
-import static {{invokerPackage}}.GsonObjectMapper.gson;
+import static {{invokerPackage}}.{{#gson}}GsonObjectMapper.gson{{/gson}}{{#jackson}}JacksonObjectMapper.jackson{{/jackson}};
/**
* API tests for {{classname}}
@@ -33,7 +33,8 @@ public class {{classname}}Test {
@Before
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
- () -> new RequestSpecBuilder().setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson())))
+ () -> new RequestSpecBuilder()
+ .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper({{#gson}}gson(){{/gson}}{{#jackson}}jackson(){{/jackson}})))
.addFilter(new ErrorLoggingFilter())
.setBaseUri("{{{basePath}}}"))).{{classVarName}}();
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
index b2d8683d3a4..d67815a76aa 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.gradle.mustache
@@ -98,8 +98,15 @@ ext {
swagger_annotations_version = "1.5.21"
rest_assured_version = "4.0.0"
junit_version = "4.12"
+{{#jackson}}
+ jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
+ jackson_databind_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}"
+ jackson-databind-nullable-version = 0.2.0
+{{/jackson}}
+{{#gson}}
gson_version = "2.8.5"
gson_fire_version = "1.8.3"
+{{/gson}}
{{#joda}}
jodatime_version = "2.9.9"
{{/joda}}
@@ -113,10 +120,19 @@ dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.findbugs:jsr305:3.0.2"
compile "io.rest-assured:scala-support:$rest_assured_version"
+{{#jackson}}
+ compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
+ compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
+ compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
+ compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
+{{/jackson}}
+{{#gson}}
compile "io.gsonfire:gson-fire:$gson_fire_version"
+ compile 'com.google.code.gson:gson:$gson_version'
+{{/gson}}
{{#joda}}
compile "joda-time:joda-time:$jodatime_version"
- compile 'com.google.code.gson:gson:$gson_version'
{{/joda}}
{{#threetenbp}}
compile "org.threeten:threetenbp:$threetenbp_version"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
index d8d817271cb..5f62ab21481 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/build.sbt.mustache
@@ -11,8 +11,15 @@ lazy val root = (project in file(".")).
libraryDependencies ++= Seq(
"io.swagger" % "swagger-annotations" % "1.5.21",
"io.rest-assured" % "scala-support" % "4.0.0",
+{{#jackson}}
+ "com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile",
+ "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile",
+{{/jackson}}
+{{#gson}}
"com.google.code.gson" % "gson" % "2.8.5",
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
+{{/gson}}
{{#joda}}
"joda-time" % "joda-time" % "2.9.9" % "compile",
{{/joda}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
index f8a8b5a1c88..383403811b8 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
@@ -217,11 +217,13 @@
rest-assured
${rest-assured.version}
+ {{#gson}}
com.google.code.gson
gson
${gson-version}
+ {{/gson}}
{{#joda}}
joda-time
@@ -236,16 +238,69 @@
${threetenbp-version}
{{/threetenbp}}
+ {{#gson}}
io.gsonfire
gson-fire
${gson-fire-version}
-
- com.squareup.okio
- okio
- ${okio-version}
-
+ {{/gson}}
+ {{#jackson}}
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson-databind-version}
+
+
+ org.openapitools
+ jackson-databind-nullable
+ ${jackson-databind-nullable-version}
+
+ {{#withXml}}
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+ ${jackson-version}
+
+ {{/withXml}}
+ {{#joda}}
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-joda
+ ${jackson-version}
+
+ {{/joda}}
+ {{#java8}}
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ ${jackson-version}
+
+ {{/java8}}
+ {{#threetenbp}}
+
+ com.github.joschi.jackson
+ jackson-datatype-threetenbp
+ ${jackson-threetenbp-version}
+
+ {{/threetenbp}}
+ {{/jackson}}
+
+ com.squareup.okio
+ okio
+ ${okio-version}
+
junit
@@ -267,6 +322,14 @@
{{#threetenbp}}
1.3.8
{{/threetenbp}}
+ {{#jackson}}
+ 2.9.9
+ 2.9.9
+ 0.2.0
+ {{#threetenbp}}
+ 2.6.4
+ {{/threetenbp}}
+ {{/jackson}}
1.13.0
4.12
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
index 4232b110be4..47b5e19323a 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resteasy/build.gradle.mustache
@@ -121,6 +121,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
threetenbp_version = "2.6.4"
resteasy_version = "3.1.3.Final"
{{^java8}}
@@ -143,6 +144,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$threetenbp_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
index a3a9716286a..e3cd4fa751e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
@@ -122,6 +122,7 @@ ext {
swagger_annotations_version = "1.5.22"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
spring_web_version = "4.3.9.RELEASE"
jodatime_version = "2.9.9"
junit_version = "4.12"
@@ -138,6 +139,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
{{#java8}}
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
{{/java8}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
index 41ba4811340..0d4d1ad995e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
@@ -133,6 +133,7 @@ ext {
{{#play26}}
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
+ jackson-databind-nullable-version = "0.2.0"
play_version = "2.6.7"
{{/play26}}
{{/usePlayWS}}
@@ -189,6 +190,7 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
+ compile "org.openapitools:jackson-databind-nullable:$jackson-databind-nullable-version"
compile "com.fasterxml.jackson.datatype:jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}:$jackson_version"
{{/usePlayWS}}
diff --git a/modules/openapi-generator/src/main/resources/Java/model.mustache b/modules/openapi-generator/src/main/resources/Java/model.mustache
index 08429bb58de..2194bbfdb39 100644
--- a/modules/openapi-generator/src/main/resources/Java/model.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/model.mustache
@@ -20,6 +20,7 @@ import {{import}};
import java.io.Serializable;
{{/serializableModel}}
{{#jackson}}
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
{{#withXml}}
import com.fasterxml.jackson.dataformat.xml.annotation.*;
{{/withXml}}
diff --git a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache
index 614e260c97f..101870341f5 100644
--- a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache
@@ -56,7 +56,7 @@
@Override
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
- {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}next{{{dataType}}}(){{/isInteger}}{{/isNumber}};
+ {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}} jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isInteger}}{{/isNumber}};
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/pojo.mustache
index 6ba1d72e2bc..309a42baced 100644
--- a/modules/openapi-generator/src/main/resources/Java/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/pojo.mustache
@@ -2,6 +2,13 @@
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
+{{#jackson}}
+@JsonPropertyOrder({
+{{#vars}}
+ {{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
+{{/vars}}
+})
+{{/jackson}}
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable {{/serializableModel}}{{/parcelableModel}}{
{{#serializableModel}}
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/model.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/model.mustache
index fce25592536..9e3aebc0a78 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/model.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/model.mustache
@@ -10,6 +10,9 @@ import org.apache.commons.lang3.ObjectUtils;
{{/supportJava6}}
{{#imports}}import {{import}};
{{/imports}}
+{{#jackson}}
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+{{/jackson}}
{{#serializableModel}}
import java.io.Serializable;
{{/serializableModel}}
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/pojo.mustache
index 018c60c2a56..302b7e257c8 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/pojo.mustache
@@ -2,6 +2,13 @@
* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
+{{#jackson}}
+@JsonPropertyOrder({
+{{#vars}}
+ {{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
+{{/vars}}
+})
+{{/jackson}}
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#vars}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
index 9bf21463079..bb173eef7e4 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
@@ -1 +1 @@
-{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
+{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/JavaVertXServer/pom.mustache b/modules/openapi-generator/src/main/resources/JavaVertXServer/pom.mustache
index 9b6f2fdf2a4..64aec46faf0 100644
--- a/modules/openapi-generator/src/main/resources/JavaVertXServer/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaVertXServer/pom.mustache
@@ -14,7 +14,7 @@
1.8
4.12
3.4.1
- 3.3
+ 3.8.1
{{vertxSwaggerRouterVersion}}
2.3
2.7.4
diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/git_push.sh.mustache
index 3d582557526..8b3f689c912 100644
--- a/modules/openapi-generator/src/main/resources/Javascript/es6/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript/es6/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -36,10 +42,10 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/Javascript/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/Javascript/git_push.sh.mustache
index 3d582557526..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/Javascript/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -36,10 +42,10 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
index f6ca902864d..5a6cb16c1ac 100644
--- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
+++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
@@ -28,6 +28,7 @@ org.openapitools.codegen.languages.ErlangClientCodegen
org.openapitools.codegen.languages.ErlangProperCodegen
org.openapitools.codegen.languages.ErlangServerCodegen
org.openapitools.codegen.languages.FlashClientCodegen
+org.openapitools.codegen.languages.FsharpGiraffeServerCodegen
org.openapitools.codegen.languages.GoClientCodegen
org.openapitools.codegen.languages.GoClientExperimentalCodegen
org.openapitools.codegen.languages.GoServerCodegen
@@ -38,6 +39,7 @@ org.openapitools.codegen.languages.GroovyClientCodegen
org.openapitools.codegen.languages.KotlinClientCodegen
org.openapitools.codegen.languages.KotlinServerCodegen
org.openapitools.codegen.languages.KotlinSpringServerCodegen
+org.openapitools.codegen.languages.KotlinVertxServerCodegen
org.openapitools.codegen.languages.HaskellHttpClientCodegen
org.openapitools.codegen.languages.HaskellServantCodegen
org.openapitools.codegen.languages.JavaClientCodegen
@@ -61,6 +63,7 @@ org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
org.openapitools.codegen.languages.JMeterClientCodegen
org.openapitools.codegen.languages.LuaClientCodegen
org.openapitools.codegen.languages.MysqlSchemaCodegen
+org.openapitools.codegen.languages.NimClientCodegen
org.openapitools.codegen.languages.NodeJSServerCodegen
org.openapitools.codegen.languages.NodeJSExpressServerCodegen
org.openapitools.codegen.languages.ObjcClientCodegen
@@ -76,6 +79,7 @@ org.openapitools.codegen.languages.PhpSilexServerCodegen
org.openapitools.codegen.languages.PhpSymfonyServerCodegen
org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen
org.openapitools.codegen.languages.PowerShellClientCodegen
+org.openapitools.codegen.languages.ProtobufSchemaCodegen
org.openapitools.codegen.languages.PythonClientCodegen
org.openapitools.codegen.languages.PythonClientExperimentalCodegen
org.openapitools.codegen.languages.PythonFlaskConnexionServerCodegen
@@ -112,3 +116,4 @@ org.openapitools.codegen.languages.TypeScriptJqueryClientCodegen
org.openapitools.codegen.languages.TypeScriptNodeClientCodegen
org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen
org.openapitools.codegen.languages.FsharpGiraffeServerCodegen
+org.openapitools.codegen.languages.AsciidocDocumentationCodegen
diff --git a/modules/openapi-generator/src/main/resources/android/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/android/git_push.sh.mustache
index c344020eab5..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/android/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/android/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/android/libraries/volley/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/android/libraries/volley/git_push.sh.mustache
index 90e9e063940..8b3f689c912 100644
--- a/modules/openapi-generator/src/main/resources/android/libraries/volley/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/android/libraries/volley/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,5 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
+
diff --git a/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache b/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
index 66f1be9033b..3e5b52e5394 100644
--- a/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/android/libraries/volley/pom.mustache
@@ -53,7 +53,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.5.1
+ 3.8.1
{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}
{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}
diff --git a/modules/openapi-generator/src/main/resources/apex/README_ant.mustache b/modules/openapi-generator/src/main/resources/apex/README_ant.mustache
index f9ebd628a72..ea68ac1ed00 100644
--- a/modules/openapi-generator/src/main/resources/apex/README_ant.mustache
+++ b/modules/openapi-generator/src/main/resources/apex/README_ant.mustache
@@ -45,10 +45,10 @@ For more information, see &1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/asciidoc-documentation/index.mustache b/modules/openapi-generator/src/main/resources/asciidoc-documentation/index.mustache
new file mode 100644
index 00000000000..425cb563715
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/asciidoc-documentation/index.mustache
@@ -0,0 +1,101 @@
+= {{{appName}}}
+{{infoEmail}}
+{{#version}}{{{version}}}{{/version}}
+:toc: left
+:numbered:
+:toclevels: 3
+:source-highlighter: highlightjs
+:keywords: openapi, rest, {{appName}}
+:specDir: {{specDir}}
+:snippetDir: {{snippetDir}}
+:generator-template: v1 2019-09-03
+:info-url: {{infoUrl}}
+:app-name: {{appName}}
+
+[abstract]
+.Abstract
+{{{appDescription}}}
+
+{{#specinclude}}intro.adoc{{/specinclude}}
+
+== Endpoints
+
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+
+[.{{baseName}}]
+=== {{baseName}}
+
+{{#operation}}
+
+[.{{nickname}}]
+==== {{nickname}}
+
+`{{httpMethod}} {{path}}`
+
+{{{summary}}}
+
+===== Description
+
+{{{notes}}}
+
+{{#specinclude}}{{path}}/{{httpMethod}}/spec.adoc{{/specinclude}}
+
+
+{{> params}}
+
+===== Return Type
+
+{{#hasReference}}
+{{^returnSimpleType}}{{returnContainer}}[{{/returnSimpleType}}<<{{returnBaseType}}>>{{^returnSimpleType}}]{{/returnSimpleType}}
+{{/hasReference}}
+
+{{^hasReference}}
+{{#returnType}}<<{{returnType}}>>{{/returnType}}
+{{^returnType}}-{{/returnType}}
+{{/hasReference}}
+
+{{#hasProduces}}
+===== Content Type
+
+{{#produces}}
+* {{{mediaType}}}
+{{/produces}}
+{{/hasProduces}}
+
+===== Responses
+
+.http response codes
+[cols="2,3,1"]
+|===
+| Code | Message | Datatype
+
+{{#responses}}
+
+| {{code}}
+| {{message}}
+| {{^simpleType}}{{dataType}}[<<{{baseType}}>>]{{/simpleType}} {{#simpleType}}<<{{dataType}}>>{{/simpleType}}
+
+{{/responses}}
+|===
+
+===== Samples
+
+{{#snippetinclude}}{{path}}/{{httpMethod}}/http-request.adoc{{/snippetinclude}}
+{{#snippetinclude}}{{path}}/{{httpMethod}}/http-response.adoc{{/snippetinclude}}
+
+{{#snippetlink}}* wiremock data, {{path}}/{{httpMethod}}/{{httpMethod}}.json{{/snippetlink}}
+
+ifdef::internal-generation[]
+===== Implementation
+{{#specinclude}}{{path}}/{{httpMethod}}/implementation.adoc{{/specinclude}}
+
+endif::internal-generation[]
+
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+
+{{> model}}
diff --git a/modules/openapi-generator/src/main/resources/asciidoc-documentation/model.mustache b/modules/openapi-generator/src/main/resources/asciidoc-documentation/model.mustache
new file mode 100644
index 00000000000..b36b7227c19
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/asciidoc-documentation/model.mustache
@@ -0,0 +1,28 @@
+[#models]
+== Models
+
+{{#models}}
+ {{#model}}
+
+[#{{classname}}]
+==== _{{classname}}_ {{title}}
+
+{{unescapedDescription}}
+
+[.fields-{{classname}}]
+[cols="2,1,2,4,1"]
+|===
+| Field Name| Required| Type| Description| Format
+
+{{#vars}}
+| {{name}}
+| {{#required}}X{{/required}}
+| {{dataType}} {{#isContainer}} of <<{{complexType}}>>{{/isContainer}}
+| {{description}}
+| {{{dataFormat}}} {{#isEnum}}Enum: _ {{#_enum}}{{this}}, {{/_enum}}{{/isEnum}} _
+
+{{/vars}}
+|===
+
+ {{/model}}
+{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/asciidoc-documentation/param.mustache b/modules/openapi-generator/src/main/resources/asciidoc-documentation/param.mustache
new file mode 100644
index 00000000000..863c7294891
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/asciidoc-documentation/param.mustache
@@ -0,0 +1,5 @@
+| {{paramName}}
+| {{description}} {{#baseType}}<<{{baseType}}>>{{/baseType}}
+| {{^required}}-{{/required}}{{#required}}X{{/required}}
+| {{defaultValue}}
+| {{{pattern}}}
diff --git a/modules/openapi-generator/src/main/resources/asciidoc-documentation/params.mustache b/modules/openapi-generator/src/main/resources/asciidoc-documentation/params.mustache
new file mode 100644
index 00000000000..9be5b8377f0
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/asciidoc-documentation/params.mustache
@@ -0,0 +1,53 @@
+===== Parameters
+
+{{#hasPathParams}}
+====== Path Parameters
+
+[cols="2,3,1,1,1"]
+|===
+|Name| Description| Required| Default| Pattern
+
+{{#pathParams}}
+{{>param}}
+{{/pathParams}}
+|===
+{{/hasPathParams}}
+
+{{#hasBodyParam}}
+===== Body Parameter
+
+[cols="2,3,1,1,1"]
+|===
+|Name| Description| Required| Default| Pattern
+
+{{#bodyParams}}
+{{>param}}
+{{/bodyParams}}
+|===
+{{/hasBodyParam}}
+
+{{#hasHeaderParams}}
+====== Header Parameters
+
+[cols="2,3,1,1,1"]
+|===
+|Name| Description| Required| Default| Pattern
+
+{{#headerParams}}
+{{>param}}
+{{/headerParams}}
+|===
+{{/hasHeaderParams}}
+
+{{#hasQueryParams}}
+====== Query Parameters
+
+[cols="2,3,1,1,1"]
+|===
+|Name| Description| Required| Default| Pattern
+
+{{#queryParams}}
+{{>param}}
+{{/queryParams}}
+|===
+{{/hasQueryParams}}
diff --git a/modules/openapi-generator/src/main/resources/asciidoc-documentation/stubs/empty.adoc b/modules/openapi-generator/src/main/resources/asciidoc-documentation/stubs/empty.adoc
new file mode 100644
index 00000000000..c6d8ea163e7
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/asciidoc-documentation/stubs/empty.adoc
@@ -0,0 +1 @@
+// openapi generator built documentation, see https://github.com/OpenAPITools/openapi-generator
diff --git a/modules/openapi-generator/src/main/resources/clojure/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/clojure/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/clojure/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/clojure/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache
index a05667766a9..b999e5997b4 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache
@@ -35,12 +35,10 @@ public:
///
/// {{description}}
///
- {{#isContainer}}{{{dataType}}}& {{getter}}();
- {{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
- void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);
- {{/isContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
- void unset{{name}}();
- {{/required}}
+ {{{dataType}}}{{#isContainer}}&{{/isContainer}} {{getter}}(){{^isContainer}} const{{/isContainer}};
+ void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);{{^required}}
+ bool {{nameInCamelCase}}IsSet() const;
+ void unset{{name}}();{{/required}}
{{/vars}}
friend void to_json(nlohmann::json& j, const {{classname}}& o);
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache
index e69d65cafc6..03b8d574df4 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache
@@ -29,7 +29,7 @@ void to_json(nlohmann::json& j, const {{classname}}& o)
{
j = nlohmann::json();
{{#vars}}
- {{#required}}j["{{baseName}}"] = o.m_{{name}};{{/required}}{{^required}}if(o.{{nameInCamelCase}}IsSet())
+ {{#required}}j["{{baseName}}"] = o.m_{{name}};{{/required}}{{^required}}if(o.{{nameInCamelCase}}IsSet(){{#isContainer}} || !o.m_{{name}}.empty(){{/isContainer}})
j["{{baseName}}"] = o.m_{{name}};{{/required}}
{{/vars}}
}
@@ -45,20 +45,15 @@ void from_json(const nlohmann::json& j, {{classname}}& o)
{{/vars}}
}
-{{#vars}}{{#isContainer}}{{{dataType}}}& {{classname}}::{{getter}}()
-{
- return m_{{name}};
-}
-{{/isContainer}}{{^isContainer}}{{{dataType}}} {{classname}}::{{getter}}() const
+{{#vars}}{{{dataType}}}{{#isContainer}}&{{/isContainer}} {{classname}}::{{getter}}(){{^isContainer}} const{{/isContainer}}
{
return m_{{name}};
}
void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value)
{
- m_{{name}} = value;
- {{^required}}m_{{name}}IsSet = true;{{/required}}
+ m_{{name}} = value;{{^required}}
+ m_{{name}}IsSet = true;{{/required}}
}
-{{/isContainer}}
{{^required}}bool {{classname}}::{{nameInCamelCase}}IsSet() const
{
return m_{{name}}IsSet;
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.cpp.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.cpp.mustache
new file mode 100644
index 00000000000..a4ff7f64c4a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.cpp.mustache
@@ -0,0 +1,155 @@
+{{>licenseInfo}}
+
+#include
+#include
+#include
+#include
+
+#include "{{prefix}}HttpFileElement.h"
+
+{{#cppNamespaceDeclarations}}
+namespace {{this}} {
+{{/cppNamespaceDeclarations}}
+
+void
+{{prefix}}HttpFileElement::setMimeType(const QString &mime){
+ mime_type = mime;
+}
+
+void
+{{prefix}}HttpFileElement::setFileName(const QString &name){
+ local_filename = name;
+}
+
+void
+{{prefix}}HttpFileElement::setVariableName(const QString &name){
+ variable_name = name;
+}
+
+void
+{{prefix}}HttpFileElement::setRequestFileName(const QString &name){
+ request_filename = name;
+}
+
+bool
+{{prefix}}HttpFileElement::isSet() const {
+ return !local_filename.isEmpty() || !request_filename.isEmpty();
+}
+
+QString
+{{prefix}}HttpFileElement::asJson() const{
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return QString(bArray);
+}
+
+QJsonValue
+{{prefix}}HttpFileElement::asJsonValue() const{
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return QJsonDocument::fromBinaryData(bArray.data()).object();
+}
+
+bool
+{{prefix}}HttpFileElement::fromStringValue(const QString &instr){
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()) {
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(instr.toUtf8());
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+bool
+{{prefix}}HttpFileElement::fromJsonValue(const QJsonValue &jval) {
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()) {
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(QJsonDocument(jval.toObject()).toBinaryData());
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+QByteArray
+{{prefix}}HttpFileElement::asByteArray() const {
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return bArray;
+}
+
+bool
+{{prefix}}HttpFileElement::fromByteArray(const QByteArray& bytes){
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()){
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(bytes);
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+bool
+{{prefix}}HttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray& bytes){
+ setMimeType(mime);
+ setFileName(localFName);
+ setVariableName(varName);
+ setRequestFileName(reqFname);
+ return fromByteArray(bytes);
+}
+
+QByteArray
+{{prefix}}HttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime){
+ setMimeType(mime);
+ setFileName(localFName);
+ setVariableName(varName);
+ setRequestFileName(reqFname);
+ return asByteArray();
+}
+
+{{#cppNamespaceDeclarations}}
+}
+{{/cppNamespaceDeclarations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.h.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.h.mustache
new file mode 100644
index 00000000000..9ebfe362356
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpFileElement.h.mustache
@@ -0,0 +1,42 @@
+{{>licenseInfo}}
+#ifndef {{prefix}}_HTTP_FILE_ELEMENT_H
+#define {{prefix}}_HTTP_FILE_ELEMENT_H
+
+#include
+#include
+#include
+
+
+{{#cppNamespaceDeclarations}}
+namespace {{this}} {
+{{/cppNamespaceDeclarations}}
+
+class {{prefix}}HttpFileElement {
+
+public:
+ QString variable_name;
+ QString local_filename;
+ QString request_filename;
+ QString mime_type;
+ void setMimeType(const QString &mime);
+ void setFileName(const QString &name);
+ void setVariableName(const QString &name);
+ void setRequestFileName(const QString &name);
+ bool isSet() const;
+ bool fromStringValue(const QString &instr);
+ bool fromJsonValue(const QJsonValue &jval);
+ bool fromByteArray(const QByteArray& bytes);
+ bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray& bytes);
+ QString asJson() const;
+ QJsonValue asJsonValue() const;
+ QByteArray asByteArray() const;
+ QByteArray loadFromFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime);
+};
+
+{{#cppNamespaceDeclarations}}
+}
+{{/cppNamespaceDeclarations}}
+
+Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}HttpFileElement)
+
+#endif // {{prefix}}_HTTP_FILE_ELEMENT_H
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.cpp.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.cpp.mustache
index 05bad7539e3..58f2398dfeb 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.cpp.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.cpp.mustache
@@ -1,11 +1,16 @@
{{>licenseInfo}}
-#include "{{prefix}}HttpRequest.h"
+
+
#include
+#include
+#include
#include
#include
#include
#include
+#include "{{prefix}}HttpRequest.h"
+
{{#cppNamespaceDeclarations}}
namespace {{this}} {
@@ -32,7 +37,7 @@ void {{prefix}}HttpRequestInput::add_var(QString key, QString value) {
}
void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
- {{prefix}}HttpRequestInputFileElement file;
+ {{prefix}}HttpFileElement file;
file.variable_name = variable_name;
file.local_filename = local_filename;
file.request_filename = request_filename;
@@ -48,6 +53,7 @@ void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_f
timeout = 0;
timer = new QTimer();
manager = new QNetworkAccessManager(this);
+ workingDirectory = QDir::currentPath();
connect(manager, &QNetworkAccessManager::finished, this, &{{prefix}}HttpRequestWorker::on_manager_finished);
}
@@ -58,16 +64,50 @@ void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_f
}
timer->deleteLater();
}
+ for (const auto & item: multiPartFields) {
+ if(item != nullptr) {
+ delete item;
+ }
+ }
}
-QMap {{prefix}}HttpRequestWorker::getResponseHeaders() const {
+QMap {{prefix}}HttpRequestWorker::getResponseHeaders() const {
return headers;
}
+{{prefix}}HttpFileElement {{prefix}}HttpRequestWorker::getHttpFileElement(const QString &fieldname){
+ if(!files.isEmpty()){
+ if(fieldname.isEmpty()){
+ return files.first();
+ }else if (files.contains(fieldname)){
+ return files[fieldname];
+ }
+ }
+ return OAIHttpFileElement();
+}
+
+QByteArray *{{prefix}}HttpRequestWorker::getMultiPartField(const QString &fieldname){
+ if(!multiPartFields.isEmpty()){
+ if(fieldname.isEmpty()){
+ return multiPartFields.first();
+ }else if (multiPartFields.contains(fieldname)){
+ return multiPartFields[fieldname];
+ }
+ }
+ return nullptr;
+}
+
void {{prefix}}HttpRequestWorker::setTimeOut(int tout){
timeout = tout;
}
+void {{prefix}}HttpRequestWorker::setWorkingDirectory(const QString &path){
+ if(!path.isEmpty()){
+ workingDirectory = path;
+ }
+}
+
+
QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
// result structure follows RFC 5987
bool need_utf_encoding = false;
@@ -196,7 +236,7 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
}
// add files
- for (QList<{{prefix}}HttpRequestInputFileElement>::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) {
+ for (QList<{{prefix}}HttpFileElement>::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) {
QFileInfo fi(file_info->local_filename);
// ensure necessary variables are available
@@ -276,8 +316,13 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
}
- if (request_content.size() > 0 && !isFormData) {
- request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
+ if (request_content.size() > 0 && !isFormData && (input->var_layout != MULTIPART)) {
+ if(!input->headers.contains("Content-Type")){
+ request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
+ }
+ else {
+ request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
+ }
}
else if (input->var_layout == URL_ENCODED) {
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@@ -331,9 +376,10 @@ void {{prefix}}HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
}
}
reply->deleteLater();
-
+ process_form_response();
emit on_execution_finished(this);
}
+
void {{prefix}}HttpRequestWorker::on_manager_timeout(QNetworkReply *reply) {
error_type = QNetworkReply::TimeoutError;
response = "";
@@ -341,9 +387,37 @@ void {{prefix}}HttpRequestWorker::on_manager_timeout(QNetworkReply *reply) {
disconnect(manager, nullptr, nullptr, nullptr);
reply->abort();
reply->deleteLater();
-
emit on_execution_finished(this);
}
+
+void {{prefix}}HttpRequestWorker::process_form_response() {
+ if(getResponseHeaders().contains(QString("Content-Disposition")) ) {
+ auto contentDisposition = getResponseHeaders().value(QString("Content-Disposition").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
+ auto contentType = getResponseHeaders().contains(QString("Content-Type")) ? getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts).first() : QString();
+ if((contentDisposition.count() > 0) && (contentDisposition.first() == QString("attachment"))){
+ QString filename = QUuid::createUuid().toString();
+ for(const auto &file : contentDisposition){
+ if(file.contains(QString("filename"))){
+ filename = file.split(QString("="), QString::SkipEmptyParts).at(1);
+ break;
+ }
+ }
+ {{prefix}}HttpFileElement felement;
+ felement.saveToFile(QString(), workingDirectory + QDir::separator() + filename, filename, contentType, response.data());
+ files.insert(filename, felement);
+ }
+
+ } else if(getResponseHeaders().contains(QString("Content-Type")) ) {
+ auto contentType = getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
+ if((contentType.count() > 0) && (contentType.first() == QString("multipart/form-data"))){
+
+ }
+ else {
+
+ }
+ }
+}
+
QSslConfiguration* {{prefix}}HttpRequestWorker::sslDefaultConfiguration;
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.h.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.h.mustache
index 0af88c40708..5138113d7dc 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.h.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/HttpRequest.h.mustache
@@ -16,6 +16,7 @@
#include
+#include "{{prefix}}HttpFileElement.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
@@ -23,16 +24,6 @@ namespace {{this}} {
enum {{prefix}}HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
-class {{prefix}}HttpRequestInputFileElement {
-
-public:
- QString variable_name;
- QString local_filename;
- QString request_filename;
- QString mime_type;
-
-};
-
class {{prefix}}HttpRequestInput {
@@ -42,7 +33,7 @@ public:
{{prefix}}HttpRequestVarLayout var_layout;
QMap vars;
QMap headers;
- QList<{{prefix}}HttpRequestInputFileElement> files;
+ QList<{{prefix}}HttpFileElement> files;
QByteArray request_body;
{{prefix}}HttpRequestInput();
@@ -65,19 +56,26 @@ public:
explicit {{prefix}}HttpRequestWorker(QObject *parent = nullptr);
virtual ~{{prefix}}HttpRequestWorker();
- QMap getResponseHeaders() const;
+ QMap getResponseHeaders() const;
QString http_attribute_encode(QString attribute_name, QString input);
void execute({{prefix}}HttpRequestInput *input);
static QSslConfiguration* sslDefaultConfiguration;
void setTimeOut(int tout);
+ void setWorkingDirectory(const QString &path);
+ {{prefix}}HttpFileElement getHttpFileElement(const QString &fieldname = QString());
+ QByteArray* getMultiPartField(const QString &fieldname = QString());
signals:
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
private:
QNetworkAccessManager *manager;
- QMap headers;
+ QMap headers;
+ QMap files;
+ QMap multiPartFields;
+ QString workingDirectory;
int timeout;
void on_manager_timeout(QNetworkReply *reply);
+ void process_form_response();
private slots:
void on_manager_finished(QNetworkReply *reply);
};
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/Project.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/Project.mustache
index 9f530b381aa..854841518e2 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/Project.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/Project.mustache
@@ -18,8 +18,9 @@ HEADERS += \
# Others
$${PWD}/{{prefix}}Helpers.h \
$${PWD}/{{prefix}}HttpRequest.h \
- $${PWD}/{{prefix}}Object.h
- $${PWD}/{{prefix}}Enum.h
+ $${PWD}/{{prefix}}Object.h \
+ $${PWD}/{{prefix}}Enum.h \
+ $${PWD}/{{prefix}}HttpFileElement.h
SOURCES += \
# Models
@@ -38,5 +39,6 @@ SOURCES += \
{{/apiInfo}}
# Others
$${PWD}/{{prefix}}Helpers.cpp \
- $${PWD}/{{prefix}}HttpRequest.cpp
+ $${PWD}/{{prefix}}HttpRequest.cpp \
+ $${PWD}/{{prefix}}HttpFileElement.cpp
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
index 184e1dd20a3..9b5d5973b1a 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-body.mustache
@@ -37,6 +37,10 @@ void {{classname}}::setApiTimeOutMs(const int tout){
timeout = tout;
}
+void {{classname}}::setWorkingDirectory(const QString& path){
+ workingDirectory = path;
+}
+
void {{classname}}::addHeaders(const QString& key, const QString& value){
defaultHeaders.insert(key, value);
}
@@ -104,20 +108,21 @@ void
{{/collectionFormat}}{{/queryParams}}
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this);
worker->setTimeOut(timeout);
+ worker->setWorkingDirectory(workingDirectory);
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
- {{#formParams}}
- if ({{paramName}} != nullptr) {
- {{^isFile}}input.add_var("{{baseName}}", {{paramName}});{{/isFile}}{{#isFile}}input.add_file("{{baseName}}", (*{{paramName}}).local_filename, (*{{paramName}}).request_filename, (*{{paramName}}).mime_type);{{/isFile}}
- }
- {{/formParams}}{{#bodyParams}}
+ {{#formParams}}{{^isFile}}
+ input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}}
+ input.add_file("{{baseName}}", {{paramName}}.local_filename, {{paramName}}.request_filename, {{paramName}}.mime_type);{{/isFile}}{{/formParams}}
+ {{#bodyParams}}
{{#isContainer}}{{#isListContainer}}
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}).toArray());{{/isListContainer}}{{#isMapContainer}}
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}).toObject());{{/isMapContainer}}
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
{{/isContainer}}{{^isContainer}}{{#isString}}
- QString output({{paramName}});{{/isString}}{{#isByteArray}}QString output({{paramName}});{{/isByteArray}}{{^isString}}{{^isByteArray}}
- QString output = {{paramName}}.asJson();{{/isByteArray}}{{/isString}}
+ QString output({{paramName}});{{/isString}}{{#isByteArray}}QString output({{paramName}});{{/isByteArray}}{{^isString}}{{^isByteArray}}{{^isFile}}
+ QString output = {{paramName}}.asJson();{{/isFile}}{{/isByteArray}}{{/isString}}{{#isFile}}{{#hasConsumes}}input.headers.insert("Content-Type", {{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}});{{/hasConsumes}}
+ QByteArray output = {{paramName}}.asByteArray();{{/isFile}}
input.request_body.append(output);
{{/isContainer}}{{/bodyParams}}
{{#headerParams}}
@@ -184,7 +189,7 @@ void
{{/isMapContainer}}
{{^isMapContainer}}
{{^returnTypeIsPrimitive}}
- {{{returnType}}} output(QString(worker->response));
+ {{{returnType}}} output{{^isResponseFile}}(QString(worker->response)){{/isResponseFile}}{{#isResponseFile}} = worker->getHttpFileElement(){{/isResponseFile}};
{{/returnTypeIsPrimitive}}
{{/isMapContainer}}
{{/isListContainer}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
index 5f023279754..aca810bfb78 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/api-header.mustache
@@ -24,6 +24,7 @@ public:
void setBasePath(const QString& basePath);
void setHost(const QString& host);
void setApiTimeOutMs(const int tout);
+ void setWorkingDirectory(const QString& path);
void addHeaders(const QString& key, const QString& value);
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}const {{{dataType}}}& {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
@@ -31,6 +32,7 @@ public:
private:
QString basePath;
QString host;
+ QString workingDirectory;
int timeout;
QMap defaultHeaders;
{{#operations}}{{#operation}}void {{nickname}}Callback ({{prefix}}HttpRequestWorker * worker);
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-body.mustache
index ddf83be2915..9b97b53e52c 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-body.mustache
@@ -55,11 +55,23 @@ toStringValue(const double &value){
return QString::number(value);
}
+QString
+toStringValue(const {{prefix}}Object &value){
+ return value.asJson();
+}
+
+
QString
toStringValue(const {{prefix}}Enum &value){
return value.asJson();
}
+QString
+toStringValue(const {{prefix}}HttpFileElement &value){
+ return value.asJson();
+}
+
+
QJsonValue
toJsonValue(const QString &value){
return QJsonValue(value);
@@ -115,6 +127,12 @@ toJsonValue(const {{prefix}}Enum &value){
return value.asJsonValue();
}
+QJsonValue
+toJsonValue(const {{prefix}}HttpFileElement &value){
+ return value.asJsonValue();
+}
+
+
bool
fromStringValue(const QString &inStr, QString &value){
value.clear();
@@ -209,6 +227,11 @@ fromStringValue(const QString &inStr, {{prefix}}Enum &value){
return true;
}
+bool
+fromStringValue(const QString &inStr, OAIHttpFileElement &value){
+ return value.fromStringValue(inStr);
+}
+
bool
fromJsonValue(QString &value, const QJsonValue &jval){
bool ok = true;
@@ -337,6 +360,11 @@ fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval){
return true;
}
+bool
+fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval){
+ return value.fromJsonValue(jval);
+}
+
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
index 6c8436c5543..f5275022a71 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/helpers-header.mustache
@@ -11,8 +11,10 @@
#include
#include
#include
+
#include "{{prefix}}Object.h"
#include "{{prefix}}Enum.h"
+#include "{{prefix}}HttpFileElement.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
@@ -27,7 +29,9 @@ namespace {{this}} {
QString toStringValue(const bool &value);
QString toStringValue(const float &value);
QString toStringValue(const double &value);
- QString toStringValue(const {{prefix}}Enum &value);
+ QString toStringValue(const {{prefix}}Object &value);
+ QString toStringValue(const {{prefix}}Enum &value);
+ QString toStringValue(const {{prefix}}HttpFileElement &value);
template
QString toStringValue(const QList &val) {
@@ -52,6 +56,7 @@ namespace {{this}} {
QJsonValue toJsonValue(const double &value);
QJsonValue toJsonValue(const {{prefix}}Object &value);
QJsonValue toJsonValue(const {{prefix}}Enum &value);
+ QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
template
QJsonValue toJsonValue(const QList &val) {
@@ -80,7 +85,9 @@ namespace {{this}} {
bool fromStringValue(const QString &inStr, bool &value);
bool fromStringValue(const QString &inStr, float &value);
bool fromStringValue(const QString &inStr, double &value);
- bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}Object &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value);
template
bool fromStringValue(const QList &inStr, QList &val) {
@@ -115,6 +122,7 @@ namespace {{this}} {
bool fromJsonValue(double &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
+ bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
template
bool fromJsonValue(QList &val, const QJsonValue &jval) {
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache
index 1e25f898277..0f71c97ca6c 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-body.mustache
@@ -2,13 +2,13 @@
{{#models}}{{#model}}
#include "{{classname}}.h"
-#include "{{prefix}}Helpers.h"
-
#include
#include
#include
#include
+#include "{{prefix}}Helpers.h"
+
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
@@ -70,7 +70,7 @@ void
if(varmap.count() > 0){
for(auto val : varmap.keys()){
{{^items.isContainer}}{{items.baseType}}{{/items.isContainer}}{{#items.isListContainer}}QList<{{items.items.baseType}}>{{/items.isListContainer}}{{#items.isMapContainer}}QMap{{/items.isMapContainer}} item;
- auto jval = QJsonValue::fromVariant(varmap.value(val));
+ auto jval = QJsonValue::fromVariant(varmap.value(val));
m_{{name}}_isValid &= ::{{cppNamespace}}::fromJsonValue(item, jval);
{{name}}.insert({{name}}.end(), val, item);
}
@@ -103,7 +103,7 @@ QString
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}
{{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
{{^isEnum}}QJsonObject obj;{{#vars}}
- {{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
+ {{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
}{{/isContainer}}{{#isContainer}}
if({{name}}.size() > 0){
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache
index 556139facfb..3c83c1f0d53 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-client/model-header.mustache
@@ -17,6 +17,7 @@
#include "{{prefix}}Object.h"
#include "{{prefix}}Enum.h"
+
{{#models}}
{{#model}}
{{#cppNamespaceDeclarations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.cpp.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.cpp.mustache
new file mode 100644
index 00000000000..a4ff7f64c4a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.cpp.mustache
@@ -0,0 +1,155 @@
+{{>licenseInfo}}
+
+#include
+#include
+#include
+#include
+
+#include "{{prefix}}HttpFileElement.h"
+
+{{#cppNamespaceDeclarations}}
+namespace {{this}} {
+{{/cppNamespaceDeclarations}}
+
+void
+{{prefix}}HttpFileElement::setMimeType(const QString &mime){
+ mime_type = mime;
+}
+
+void
+{{prefix}}HttpFileElement::setFileName(const QString &name){
+ local_filename = name;
+}
+
+void
+{{prefix}}HttpFileElement::setVariableName(const QString &name){
+ variable_name = name;
+}
+
+void
+{{prefix}}HttpFileElement::setRequestFileName(const QString &name){
+ request_filename = name;
+}
+
+bool
+{{prefix}}HttpFileElement::isSet() const {
+ return !local_filename.isEmpty() || !request_filename.isEmpty();
+}
+
+QString
+{{prefix}}HttpFileElement::asJson() const{
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return QString(bArray);
+}
+
+QJsonValue
+{{prefix}}HttpFileElement::asJsonValue() const{
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return QJsonDocument::fromBinaryData(bArray.data()).object();
+}
+
+bool
+{{prefix}}HttpFileElement::fromStringValue(const QString &instr){
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()) {
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(instr.toUtf8());
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+bool
+{{prefix}}HttpFileElement::fromJsonValue(const QJsonValue &jval) {
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()) {
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(QJsonDocument(jval.toObject()).toBinaryData());
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+QByteArray
+{{prefix}}HttpFileElement::asByteArray() const {
+ QFile file(local_filename);
+ QByteArray bArray;
+ bool result = false;
+ if(file.exists()) {
+ result = file.open(QIODevice::ReadOnly);
+ bArray = file.readAll();
+ file.close();
+ }
+ if(!result) {
+ qDebug() << "Error opening file " << local_filename;
+ }
+ return bArray;
+}
+
+bool
+{{prefix}}HttpFileElement::fromByteArray(const QByteArray& bytes){
+ QFile file(local_filename);
+ bool result = false;
+ if(file.exists()){
+ file.remove();
+ }
+ result = file.open(QIODevice::WriteOnly);
+ file.write(bytes);
+ file.close();
+ if(!result) {
+ qDebug() << "Error creating file " << local_filename;
+ }
+ return result;
+}
+
+bool
+{{prefix}}HttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray& bytes){
+ setMimeType(mime);
+ setFileName(localFName);
+ setVariableName(varName);
+ setRequestFileName(reqFname);
+ return fromByteArray(bytes);
+}
+
+QByteArray
+{{prefix}}HttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime){
+ setMimeType(mime);
+ setFileName(localFName);
+ setVariableName(varName);
+ setRequestFileName(reqFname);
+ return asByteArray();
+}
+
+{{#cppNamespaceDeclarations}}
+}
+{{/cppNamespaceDeclarations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.h.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.h.mustache
new file mode 100644
index 00000000000..9ebfe362356
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/HttpFileElement.h.mustache
@@ -0,0 +1,42 @@
+{{>licenseInfo}}
+#ifndef {{prefix}}_HTTP_FILE_ELEMENT_H
+#define {{prefix}}_HTTP_FILE_ELEMENT_H
+
+#include
+#include
+#include
+
+
+{{#cppNamespaceDeclarations}}
+namespace {{this}} {
+{{/cppNamespaceDeclarations}}
+
+class {{prefix}}HttpFileElement {
+
+public:
+ QString variable_name;
+ QString local_filename;
+ QString request_filename;
+ QString mime_type;
+ void setMimeType(const QString &mime);
+ void setFileName(const QString &name);
+ void setVariableName(const QString &name);
+ void setRequestFileName(const QString &name);
+ bool isSet() const;
+ bool fromStringValue(const QString &instr);
+ bool fromJsonValue(const QJsonValue &jval);
+ bool fromByteArray(const QByteArray& bytes);
+ bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray& bytes);
+ QString asJson() const;
+ QJsonValue asJsonValue() const;
+ QByteArray asByteArray() const;
+ QByteArray loadFromFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime);
+};
+
+{{#cppNamespaceDeclarations}}
+}
+{{/cppNamespaceDeclarations}}
+
+Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}HttpFileElement)
+
+#endif // {{prefix}}_HTTP_FILE_ELEMENT_H
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache
index 2874ef8c712..bf34a3a150c 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/enum.mustache
@@ -15,7 +15,7 @@ class {{prefix}}Enum {
{{prefix}}Enum() {
}
-
+
{{prefix}}Enum(QString jsonString) {
fromJson(jsonString);
}
@@ -48,7 +48,7 @@ class {{prefix}}Enum {
return true;
}
private :
- QString jstr;
+ QString jstr;
};
{{#cppNamespaceDeclarations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-body.mustache
index 9aa16e1b52a..9b97b53e52c 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-body.mustache
@@ -55,11 +55,23 @@ toStringValue(const double &value){
return QString::number(value);
}
+QString
+toStringValue(const {{prefix}}Object &value){
+ return value.asJson();
+}
+
+
QString
toStringValue(const {{prefix}}Enum &value){
return value.asJson();
}
+QString
+toStringValue(const {{prefix}}HttpFileElement &value){
+ return value.asJson();
+}
+
+
QJsonValue
toJsonValue(const QString &value){
return QJsonValue(value);
@@ -115,6 +127,12 @@ toJsonValue(const {{prefix}}Enum &value){
return value.asJsonValue();
}
+QJsonValue
+toJsonValue(const {{prefix}}HttpFileElement &value){
+ return value.asJsonValue();
+}
+
+
bool
fromStringValue(const QString &inStr, QString &value){
value.clear();
@@ -209,6 +227,11 @@ fromStringValue(const QString &inStr, {{prefix}}Enum &value){
return true;
}
+bool
+fromStringValue(const QString &inStr, OAIHttpFileElement &value){
+ return value.fromStringValue(inStr);
+}
+
bool
fromJsonValue(QString &value, const QJsonValue &jval){
bool ok = true;
@@ -220,7 +243,7 @@ fromJsonValue(QString &value, const QJsonValue &jval){
} else if(jval.isDouble()){
value = QString::number(jval.toDouble());
} else {
- ok = false;
+ ok = false;
}
} else {
ok = false;
@@ -230,7 +253,7 @@ fromJsonValue(QString &value, const QJsonValue &jval){
bool
fromJsonValue(QDateTime &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
value = QDateTime::fromString(jval.toString(), Qt::ISODate);
ok = value.isValid();
@@ -254,7 +277,7 @@ fromJsonValue(QByteArray &value, const QJsonValue &jval){
bool
fromJsonValue(QDate &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
value = QDate::fromString(jval.toString(), Qt::ISODate);
ok = value.isValid();
@@ -266,7 +289,7 @@ fromJsonValue(QDate &value, const QJsonValue &jval){
bool
fromJsonValue(qint32 &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
value = jval.toInt();
} else {
@@ -277,7 +300,7 @@ fromJsonValue(qint32 &value, const QJsonValue &jval){
bool
fromJsonValue(qint64 &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
value = jval.toVariant().toLongLong();
} else {
@@ -288,7 +311,7 @@ fromJsonValue(qint64 &value, const QJsonValue &jval){
bool
fromJsonValue(bool &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(jval.isBool()){
value = jval.toBool();
} else {
@@ -299,7 +322,7 @@ fromJsonValue(bool &value, const QJsonValue &jval){
bool
fromJsonValue(float &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(jval.isDouble()){
value = static_cast(jval.toDouble());
} else {
@@ -310,7 +333,7 @@ fromJsonValue(float &value, const QJsonValue &jval){
bool
fromJsonValue(double &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(jval.isDouble()){
value = jval.toDouble();
} else {
@@ -321,7 +344,7 @@ fromJsonValue(double &value, const QJsonValue &jval){
bool
fromJsonValue({{prefix}}Object &value, const QJsonValue &jval){
- bool ok = true;
+ bool ok = true;
if(jval.isObject()){
value.fromJsonObject(jval.toObject());
ok = value.isValid();
@@ -337,6 +360,11 @@ fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval){
return true;
}
+bool
+fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval){
+ return value.fromJsonValue(jval);
+}
+
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-header.mustache
index 0948f4f662f..f5275022a71 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/helpers-header.mustache
@@ -11,8 +11,10 @@
#include
#include
#include
+
#include "{{prefix}}Object.h"
#include "{{prefix}}Enum.h"
+#include "{{prefix}}HttpFileElement.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
@@ -27,7 +29,9 @@ namespace {{this}} {
QString toStringValue(const bool &value);
QString toStringValue(const float &value);
QString toStringValue(const double &value);
- QString toStringValue(const {{prefix}}Enum &value);
+ QString toStringValue(const {{prefix}}Object &value);
+ QString toStringValue(const {{prefix}}Enum &value);
+ QString toStringValue(const {{prefix}}HttpFileElement &value);
template
QString toStringValue(const QList &val) {
@@ -52,6 +56,7 @@ namespace {{this}} {
QJsonValue toJsonValue(const double &value);
QJsonValue toJsonValue(const {{prefix}}Object &value);
QJsonValue toJsonValue(const {{prefix}}Enum &value);
+ QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
template
QJsonValue toJsonValue(const QList &val) {
@@ -80,7 +85,9 @@ namespace {{this}} {
bool fromStringValue(const QString &inStr, bool &value);
bool fromStringValue(const QString &inStr, float &value);
bool fromStringValue(const QString &inStr, double &value);
- bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}Object &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
+ bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value);
template
bool fromStringValue(const QList &inStr, QList &val) {
@@ -115,6 +122,7 @@ namespace {{this}} {
bool fromJsonValue(double &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
+ bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
template
bool fromJsonValue(QList &val, const QJsonValue &jval) {
@@ -129,7 +137,7 @@ namespace {{this}} {
ok = false;
}
return ok;
- }
+ }
template
bool fromJsonValue(QMap &val, const QJsonValue &jval) {
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-body.mustache
index 2a75a18c760..0f71c97ca6c 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-body.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-body.mustache
@@ -2,13 +2,13 @@
{{#models}}{{#model}}
#include "{{classname}}.h"
-#include "{{prefix}}Helpers.h"
-
#include
#include
#include
#include
+#include "{{prefix}}Helpers.h"
+
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
@@ -43,7 +43,7 @@ void
{{^isEnum}}QByteArray array (jsonString.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
- this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}
+ this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}
{{#-first}}if{{/-first}}{{^-first}}else if{{/-first}} ( jsonString.compare({{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}}, Qt::CaseInsensitive) == 0) {
m_value = e{{classname}}::{{name}};
m_value_isValid = true;
@@ -70,7 +70,7 @@ void
if(varmap.count() > 0){
for(auto val : varmap.keys()){
{{^items.isContainer}}{{items.baseType}}{{/items.isContainer}}{{#items.isListContainer}}QList<{{items.items.baseType}}>{{/items.isListContainer}}{{#items.isMapContainer}}QMap{{/items.isMapContainer}} item;
- auto jval = QJsonValue::fromVariant(varmap.value(val));
+ auto jval = QJsonValue::fromVariant(varmap.value(val));
m_{{name}}_isValid &= ::{{cppNamespace}}::fromJsonValue(item, jval);
{{name}}.insert({{name}}.end(), val, item);
}
@@ -92,7 +92,7 @@ QString
{{#enumVars}}
case e{{classname}}::{{name}}:
val = {{#isString}}"{{value}}"{{/isString}}{{^isString}}QString::number({{value}}){{/isString}};
- break;{{#-last}}
+ break;{{#-last}}
default:
break;{{/-last}}
{{/enumVars}}
@@ -103,7 +103,7 @@ QString
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}
{{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
{{^isEnum}}QJsonObject obj;{{#vars}}
- {{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
+ {{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
}{{/isContainer}}{{#isContainer}}
if({{name}}.size() > 0){
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-header.mustache
index 38b42f401a2..3c83c1f0d53 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/model-header.mustache
@@ -17,6 +17,7 @@
#include "{{prefix}}Object.h"
#include "{{prefix}}Enum.h"
+
{{#models}}
{{#model}}
{{#cppNamespaceDeclarations}}
@@ -53,7 +54,7 @@ public:
{{classname}}::e{{classname}} getValue() const;
void setValue(const {{classname}}::e{{classname}}& value);{{/isEnum}}
-
+
virtual bool isSet() const override;
virtual bool isValid() const override;
diff --git a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/object.mustache b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/object.mustache
index 100670d1fc5..e58b49adb92 100644
--- a/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/object.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-qt5-qhttpengine-server/object.mustache
@@ -15,7 +15,7 @@ class {{prefix}}Object {
{{prefix}}Object() {
}
-
+
{{prefix}}Object(QString jsonString) {
fromJson(jsonString);
}
diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache
index effb911aa82..c3691a55382 100644
--- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache
@@ -294,9 +294,9 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
})
.then([=](std::vector localVarResponse)
{
- HttpContent localVarResult;
+ {{{returnType}}} localVarResult;
std::shared_ptr stream = std::make_shared(std::string(localVarResponse.begin(), localVarResponse.end()));
- localVarResult.setData(stream);
+ localVarResult->setData(stream);
return localVarResult;
{{/vendorExtensions.x-codegen-response-ishttpcontent}}
{{^vendorExtensions.x-codegen-response-ishttpcontent}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/git_push.sh.mustache
index 4504311e405..8b3f689c912 100644
--- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-cpprest "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,5 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
+
diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache
index 91446e73a33..f4548d75605 100644
--- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache
@@ -118,8 +118,8 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t&
content->setName( name );
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
content->setContentType( contentType );
- std::stringstream* valueAsStringStream = new std::stringstream();
- (*valueAsStringStream) << value;
+ std::stringstream* valueAsStringStream = new std::stringstream();
+ (*valueAsStringStream) << value;
content->setData( std::shared_ptr( valueAsStringStream ) );
return content;
}
@@ -129,8 +129,8 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t&
content->setName( name );
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
content->setContentType( contentType );
- std::stringstream* valueAsStringStream = new std::stringstream();
- (*valueAsStringStream) << value;
+ std::stringstream* valueAsStringStream = new std::stringstream();
+ (*valueAsStringStream) << value;
content->setData( std::shared_ptr( valueAsStringStream) ) ;
return content;
}
@@ -140,8 +140,8 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t&
content->setName( name );
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
content->setContentType( contentType );
- std::stringstream* valueAsStringStream = new std::stringstream();
- (*valueAsStringStream) << value;
+ std::stringstream* valueAsStringStream = new std::stringstream();
+ (*valueAsStringStream) << value;
content->setData( std::shared_ptr( valueAsStringStream ) );
return content;
}
@@ -285,7 +285,7 @@ utility::string_t ModelBase::stringFromJson(const web::json::value& val)
utility::datetime ModelBase::dateFromJson(const web::json::value& val)
{
- return val.is_null() ? utility::datetime::from_string(L"NULL", utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
+ return val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
}
bool ModelBase::boolFromJson(const web::json::value& val)
{
diff --git a/modules/openapi-generator/src/main/resources/cpp-restbed-server/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/cpp-restbed-server/git_push.sh.mustache
index 4504311e405..8b3f689c912 100644
--- a/modules/openapi-generator/src/main/resources/cpp-restbed-server/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-restbed-server/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-cpprest "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,5 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
+
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
index 9d177d2c40e..e874041b3e7 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache
@@ -317,7 +317,7 @@ namespace {{packageName}}.Client
request.RequestFormat = DataFormat.Json;
}
- request.AddBody(options.Data);
+ request.AddJsonBody(options.Data);
}
if (options.FileParameters != null)
@@ -327,9 +327,9 @@ namespace {{packageName}}.Client
var bytes = ClientUtils.ReadAsBytes(fileParam.Value);
var fileStream = fileParam.Value as FileStream;
if (fileStream != null)
- FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name));
+ request.Files.Add(FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name)));
else
- FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided");
+ request.Files.Add(FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided"));
}
}
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache
index f9a29c90aa3..90d09845bd4 100644
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache
@@ -400,7 +400,7 @@ namespace {{packageName}}.Client
{
ApiKey = apiKey,
ApiKeyPrefix = apiKeyPrefix,
- DefaultHeader = defaultHeaders,
+ DefaultHeaders = defaultHeaders,
BasePath = second.BasePath ?? first.BasePath,
Timeout = second.Timeout,
UserAgent = second.UserAgent ?? first.UserAgent,
diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/git_push.sh.mustache
index e9c7bdb802b..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/csharp-netcore/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp-netcore/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/csharp/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/csharp/git_push.sh.mustache
index e9c7bdb802b..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/csharp/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache
index 93cdde77b2a..4b1c1420e03 100644
--- a/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache
@@ -39,7 +39,7 @@ version: {{pubVersion}}
description: {{pubDescription}}
dependencies:
{{pubName}}:
- git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
+ git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
version: 'any'
```
diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache
index 1fd657ea1df..b162a53ad4b 100644
--- a/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache
@@ -1,6 +1,6 @@
library {{pubName}}.api;
-import 'package:http/io_client.dart';
+import 'package:http/http.dart' as http;
import 'package:jaguar_serializer/jaguar_serializer.dart';
{{#protoFormat}}
import 'package:jaguar_serializer_protobuf/proto_repo.dart';
@@ -19,7 +19,7 @@ import 'package:jaguar_mimetype/jaguar_mimetype.dart';
{{#jsonFormat}}
final _jsonJaguarRepo = JsonRepo()
-{{#models}}{{#model}}..add({{classname}}Serializer())
+{{#models}}{{#model}}{{^isEnum}}..add({{classname}}Serializer()){{/isEnum}}
{{/model}}{{/models}};
final Map defaultConverters = {
MimeTypes.json: _jsonJaguarRepo,
@@ -52,7 +52,7 @@ class {{clientName}} {
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
*/
{{clientName}}({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
- _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
+ _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? http.Client());
if(interceptors == null) {
this.interceptors = _defaultInterceptors;
}
@@ -97,4 +97,4 @@ class {{clientName}} {
}
{{/apis}}{{/apiInfo}}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache
index de899850177..0ee26193bba 100644
--- a/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache
@@ -10,7 +10,12 @@ part '{{classFilename}}.jser.dart';
class {{classname}} {
{{#vars}}{{#description}} /* {{{description}}} */{{/description}}
- @Alias('{{{baseName}}}', isNullable:{{#isNullable}} true{{/isNullable}}{{^isNullable}} false{{/isNullable}})
+ @Alias('{{{baseName}}}', isNullable:{{#isNullable}} true{{/isNullable}}{{^isNullable}} false{{/isNullable}},{{#allowableValues}}
+ {{^enumVars.empty}}{{^isString}}{{! isString because inline enums are not handled for now }}
+ processor: const {{{datatype}}}FieldProcessor(),
+ {{/isString}}{{/enumVars.empty}}
+ {{/allowableValues}}
+ )
final {{{datatype}}} {{name}};
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}}{{/vars}}
diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/enum.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/enum.mustache
index 0698e149412..ef2c35e2c2a 100644
--- a/modules/openapi-generator/src/main/resources/dart-jaguar/enum.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-jaguar/enum.mustache
@@ -1,6 +1,5 @@
-part '{{classFilename}}.jser.dart';
-@Entity()
+{{#jsonFormat}}
class {{classname}} {
/// The underlying value of this enum member.
final {{dataType}} value;
@@ -12,27 +11,27 @@ class {{classname}} {
{{#description}}
/// {{description}}
{{/description}}
- static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
+ static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
}
-class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
+class {{classname}}FieldProcessor implements FieldProcessor<{{classname}}, {{dataType}}> {
+ const {{classname}}FieldProcessor();
- @override
- dynamic encode({{classname}} data) {
- return data.value;
- }
-
- @override
- {{classname}} decode(dynamic data) {
- switch (data) {
- {{#allowableValues}}
- {{#enumVars}}
- case {{{value}}}: return {{classname}}.{{{name}}}};
- {{/enumVars}}
- {{/allowableValues}}
- default: throw('Unknown enum value to decode: $data');
+ {{classname}} deserialize({{dataType}} data) {
+ switch (data) {
+ {{#allowableValues}}
+ {{#enumVars}}
+ case {{{value}}}: return {{classname}}.{{{name}}};
+ {{/enumVars}}
+ {{/allowableValues}}
+ default: throw('Unknown enum value to decode: $data');
+ }
+ }
+
+ {{dataType}} serialize({{classname}} item) {
+ return item.value;
}
- }
}
+{{/jsonFormat}}
diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/git_push.sh.mustache
index 92d71b84970..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/dart-jaguar/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/dart-jaguar/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/dart/README.mustache b/modules/openapi-generator/src/main/resources/dart/README.mustache
index 1766ea72105..02c6cd2116a 100644
--- a/modules/openapi-generator/src/main/resources/dart/README.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/README.mustache
@@ -31,7 +31,7 @@ version: {{pubVersion}}
description: {{pubDescription}}
dependencies:
{{pubName}}:
- git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
+ git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
version: 'any'
```
diff --git a/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/dart/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/dart2/README.mustache b/modules/openapi-generator/src/main/resources/dart2/README.mustache
index eab8ee0ea7a..76261fa0467 100644
--- a/modules/openapi-generator/src/main/resources/dart2/README.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/README.mustache
@@ -19,24 +19,20 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requirements
-Dart 1.20.0 or later OR Flutter 0.0.20 or later
+Dart 2.0 or later
## Installation & Usage
### Github
-If this Dart package is published to Github, please include the following in pubspec.yaml
+If this Dart package is published to Github, add the following dependency to your pubspec.yaml
```
-name: {{pubName}}
-version: {{pubVersion}}
-description: {{pubDescription}}
dependencies:
{{pubName}}:
- git: https://github.com/{{gitUserId}}/{{gitRepoId}}.git
- version: 'any'
+ git: https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git
```
### Local
-To use the package in your local drive, please include the following in pubspec.yaml
+To use the package in your local drive, add the following dependency to your pubspec.yaml
```
dependencies:
{{pubName}}:
diff --git a/modules/openapi-generator/src/main/resources/dart2/api.mustache b/modules/openapi-generator/src/main/resources/dart2/api.mustache
index 9ecac421b67..c5acc6314df 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api.mustache
@@ -9,10 +9,10 @@ class {{classname}} {
{{classname}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
{{#operation}}
- /// {{summary}}
+ /// {{summary}} with HTTP info returned
///
/// {{notes}}
- {{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
+ {{#returnType}}Future {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
Object postBody{{#bodyParam}} = {{paramName}}{{/bodyParam}};
// verify required params are set
@@ -87,7 +87,14 @@ class {{classname}} {
formParams,
contentType,
authNames);
+ return response;
+ }
+ /// {{summary}}
+ ///
+ /// {{notes}}
+ {{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
+ Response response = await {{nickname}}WithHttpInfo({{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) {
@@ -112,6 +119,7 @@ class {{classname}} {
return{{#returnType}} null{{/returnType}};
}
}
+
{{/operation}}
}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
index 6f6fb691ca8..7a668fc3147 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
@@ -44,11 +44,7 @@ class ApiClient {
{{#model}}
case '{{classname}}':
{{#isEnum}}
- // Enclose the value in a list so that Dartson can use a transformer
- // to decode it.
- final listValue = [value];
- final List listResult = dson.map(listValue, []);
- return listResult[0];
+ return new {{classname}}TypeTransformer().decode(value);
{{/isEnum}}
{{^isEnum}}
return {{classname}}.fromJson(value);
diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache
index a2275ec8792..d64dc80606a 100644
--- a/modules/openapi-generator/src/main/resources/dart2/class.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache
@@ -36,9 +36,16 @@ class {{classname}} {
{{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
+ {{#items.isListContainer}}
+ {{name}} = (json['{{baseName}}'] == null) ?
+ null :
+ {{items.complexType}}.mapListFromJson(json['{{baseName}}']);
+ {{/items.isListContainer}}
+ {{^items.isListContainer}}
{{name}} = (json['{{baseName}}'] == null) ?
null :
{{complexType}}.mapFromJson(json['{{baseName}}']);
+ {{/items.isListContainer}}
{{/isMapContainer}}
{{^isMapContainer}}
{{name}} = (json['{{baseName}}'] == null) ?
@@ -108,4 +115,15 @@ class {{classname}} {
}
return map;
}
+
+ // maps a json object with a list of {{classname}}-objects as value to a dart map
+ static Map> mapListFromJson(Map json) {
+ var map = Map>();
+ if (json != null && json.isNotEmpty) {
+ json.forEach((String key, dynamic value) {
+ map[key] = {{classname}}.listFromJson(value);
+ });
+ }
+ return map;
+ }
}
diff --git a/modules/openapi-generator/src/main/resources/dart2/enum.mustache b/modules/openapi-generator/src/main/resources/dart2/enum.mustache
index d4a4d2b8d11..df8d8ff9035 100644
--- a/modules/openapi-generator/src/main/resources/dart2/enum.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/enum.mustache
@@ -1,4 +1,3 @@
-@Entity()
class {{classname}} {
/// The underlying value of this enum member.
final {{dataType}} value;
@@ -13,16 +12,18 @@ class {{classname}} {
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
+
+ static {{classname}} fromJson(String value) {
+ return new {{classname}}TypeTransformer().decode(value);
+ }
}
-class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
+class {{classname}}TypeTransformer {
- @override
dynamic encode({{classname}} data) {
return data.value;
}
- @override
{{classname}} decode(dynamic data) {
switch (data) {
{{#allowableValues}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/dart2/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/dart2/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/dart2/model_test.mustache b/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
index 49f403ef695..6e9402d4473 100644
--- a/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/model_test.mustache
@@ -5,7 +5,9 @@ import 'package:test/test.dart';
// tests for {{classname}}
void main() {
- var instance = {{classname}}();
+ {{^isEnum}}
+ var instance = new {{classname}}();
+ {{/isEnum}}
group('test {{classname}}', () {
{{#vars}}
diff --git a/modules/openapi-generator/src/main/resources/flash/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/flash/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/flash/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/flash/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/README.mustache b/modules/openapi-generator/src/main/resources/go-experimental/README.mustache
index 869443a26ed..2f51e5cbccf 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/README.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/README.mustache
@@ -31,7 +31,7 @@ go get github.com/antihax/optional
Put the package under your project folder and add the following in import:
```golang
-import "./{{packageName}}"
+import sw "./{{packageName}}"
```
## Documentation for API Endpoints
@@ -54,19 +54,14 @@ Class | Method | HTTP request | Description
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
{{#authMethods}}
-## {{{name}}}
+### {{{name}}}
-{{#isApiKey}}- **Type**: API key
+{{#isApiKey}}
+- **Type**: API key
+- **API key parameter name**: {{{keyParamName}}}
+- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
-Example
-
-```golang
-auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
- Key: "APIKEY",
- Prefix: "Bearer", // Omit if not necessary.
-})
-r, err := client.Service.Operation(auth, args)
-```
+Note, each API key must be added to a map of `map[string]APIKey` where the key is: {{keyParamName}} and passed in as the auth context for each request.
{{/isApiKey}}
{{#isBasic}}- **Type**: HTTP basic authentication
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache
index 8bd402c5500..41a990f9e50 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/api.mustache
@@ -16,11 +16,33 @@ var (
_ _context.Context
)
+// {{classname}}Service {{classname}} service
type {{classname}}Service service
{{#operation}}
+{{#hasOptionalParams}}
+// {{{nickname}}}Opts Optional parameters for the method '{{{nickname}}}'
+type {{{nickname}}}Opts struct {
+{{#allParams}}
+{{^required}}
+{{#isPrimitiveType}}
+{{^isBinary}}
+ {{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
+{{/isBinary}}
+{{#isBinary}}
+ {{vendorExtensions.x-exportParamName}} optional.Interface
+{{/isBinary}}
+{{/isPrimitiveType}}
+{{^isPrimitiveType}}
+ {{vendorExtensions.x-exportParamName}} optional.Interface
+{{/isPrimitiveType}}
+{{/required}}
+{{/allParams}}
+}
+
+{{/hasOptionalParams}}
/*
-{{{classname}}}Service{{#summary}} {{{.}}}{{/summary}}
+{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
{{#notes}}
{{notes}}
{{/notes}}
@@ -42,30 +64,9 @@ type {{classname}}Service service
@return {{{returnType}}}
{{/returnType}}
*/
-{{#hasOptionalParams}}
-
-type {{{nickname}}}Opts struct {
-{{#allParams}}
-{{^required}}
-{{#isPrimitiveType}}
-{{^isBinary}}
- {{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
-{{/isBinary}}
-{{#isBinary}}
- {{vendorExtensions.x-exportParamName}} optional.Interface
-{{/isBinary}}
-{{/isPrimitiveType}}
-{{^isPrimitiveType}}
- {{vendorExtensions.x-exportParamName}} optional.Interface
-{{/isPrimitiveType}}
-{{/required}}
-{{/allParams}}
-}
-
-{{/hasOptionalParams}}
func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*_nethttp.Response, error) {
var (
- localVarHttpMethod = _nethttp.Method{{httpMethod}}
+ localVarHTTPMethod = _nethttp.Method{{httpMethod}}
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
@@ -169,24 +170,24 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
{{/hasQueryParams}}
// to determine the Content-Type header
{{=<% %>=}}
- localVarHttpContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
+ localVarHTTPContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
<%={{ }}=%>
// set Content-Type header
- localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
- if localVarHttpContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHttpContentType
+ localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
+ if localVarHTTPContentType != "" {
+ localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
{{=<% %>=}}
- localVarHttpHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
+ localVarHTTPHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
<%={{ }}=%>
// set Accept header
- localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
- if localVarHttpHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
+ localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
+ if localVarHTTPHeaderAccept != "" {
+ localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
{{#hasHeaderParams}}
{{#headerParams}}
@@ -275,74 +276,76 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
{{^isKeyInCookie}}
if ctx != nil {
// API Key Authentication
- if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
- var key string
- if auth.Prefix != "" {
- key = auth.Prefix + " " + auth.Key
- } else {
- key = auth.Key
+ if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
+ if auth, ok := auth["{{keyParamName}}"]; ok {
+ var key string
+ if auth.Prefix != "" {
+ key = auth.Prefix + " " + auth.Key
+ } else {
+ key = auth.Key
+ }
+ {{#isKeyInHeader}}
+ localVarHeaderParams["{{keyParamName}}"] = key
+ {{/isKeyInHeader}}
+ {{#isKeyInQuery}}
+ localVarQueryParams.Add("{{keyParamName}}", key)
+ {{/isKeyInQuery}}
}
- {{#isKeyInHeader}}
- localVarHeaderParams["{{keyParamName}}"] = key
- {{/isKeyInHeader}}
- {{#isKeyInQuery}}
- localVarQueryParams.Add("{{keyParamName}}", key)
- {{/isKeyInQuery}}
}
}
{{/isKeyInCookie}}
{{/isApiKey}}
{{/authMethods}}
- r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
+ r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
}
- localVarHttpResponse, err := a.client.callAPI(r)
- if err != nil || localVarHttpResponse == nil {
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
+ localVarHTTPResponse, err := a.client.callAPI(r)
+ if err != nil || localVarHTTPResponse == nil {
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
}
- localVarBody, err := _ioutil.ReadAll(localVarHttpResponse.Body)
- localVarHttpResponse.Body.Close()
+ localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
+ localVarHTTPResponse.Body.Close()
if err != nil {
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
}
- if localVarHttpResponse.StatusCode >= 300 {
+ if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
- error: localVarHttpResponse.Status,
+ error: localVarHTTPResponse.Status,
}
{{#responses}}
{{#dataType}}
- if localVarHttpResponse.StatusCode == {{{code}}} {
+ if localVarHTTPResponse.StatusCode == {{{code}}} {
var v {{{dataType}}}
- err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
+ err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
newErr.model = v
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{/dataType}}
{{/responses}}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{#returnType}}
- err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
+ err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{/returnType}}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, nil
}
{{/operation}}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/client.mustache b/modules/openapi-generator/src/main/resources/go-experimental/client.mustache
index 1c4241ff043..c3af4534120 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/client.mustache
@@ -164,7 +164,7 @@ func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request)
}
-// Change base path to allow switching to mocks
+// ChangeBasePath changes base path to allow switching to mocks
func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache b/modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache
index 81d3a41b7bd..0b74d83401f 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache
@@ -25,8 +25,8 @@ var (
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
ContextAccessToken = contextKey("accesstoken")
- // ContextAPIKey takes an APIKey as authentication for the request
- ContextAPIKey = contextKey("apikey")
+ // ContextAPIKeys takes a string apikey as authentication for the request
+ ContextAPIKeys = contextKey("apiKeys")
)
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
@@ -41,6 +41,7 @@ type APIKey struct {
Prefix string
}
+// Configuration stores the configuration of the API client
type Configuration struct {
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
@@ -50,6 +51,7 @@ type Configuration struct {
HTTPClient *http.Client
}
+// NewConfiguration returns a new Configuration object
func NewConfiguration() *Configuration {
cfg := &Configuration{
BasePath: "{{{basePath}}}",
@@ -59,6 +61,7 @@ func NewConfiguration() *Configuration {
return cfg
}
+// AddDefaultHeader adds a new HTTP header to the default header in the request
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache b/modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache
index ec4310dd593..e02a1be201b 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache
@@ -1,4 +1,4 @@
-module github.com/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
+module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
require (
github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/model.mustache b/modules/openapi-generator/src/main/resources/go-experimental/model.mustache
index f18a8260d14..2b97b31b3cf 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/model.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/model.mustache
@@ -12,9 +12,7 @@ import (
{{/imports}}
{{#model}}
{{#isEnum}}
-{{#description}}
-// {{{classname}}} : {{{description}}}
-{{/description}}
+// {{{classname}}} {{#description}}{{{.}}}{{/description}}{{^description}}the model '{{{classname}}}'{{/description}}
type {{{classname}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/format}}
// List of {{{name}}}
@@ -26,8 +24,10 @@ const (
{{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = "{{{value}}}"
{{/enumVars}}
{{/allowableValues}}
-){{/isEnum}}{{^isEnum}}{{#description}}
-// {{{description}}}{{/description}}
+)
+{{/isEnum}}
+{{^isEnum}}
+// {{classname}}{{#description}} {{{description}}}{{/description}}{{^description}} struct for {{{classname}}}{{/description}}
type {{classname}} struct {
{{#vars}}
{{^-first}}
@@ -87,6 +87,7 @@ func (o *{{classname}}) Set{{name}}ExplicitNull(b bool) {
{{/isNullable}}
{{/vars}}
+// MarshalJSON returns the JSON representation of the model.
func (o {{classname}}) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
{{#vars}}
diff --git a/modules/openapi-generator/src/main/resources/go-experimental/response.mustache b/modules/openapi-generator/src/main/resources/go-experimental/response.mustache
index e15d7e6a783..1a8765bae8f 100644
--- a/modules/openapi-generator/src/main/resources/go-experimental/response.mustache
+++ b/modules/openapi-generator/src/main/resources/go-experimental/response.mustache
@@ -5,6 +5,7 @@ import (
"net/http"
)
+// APIResponse stores the API response returned by the server.
type APIResponse struct {
*http.Response `json:"-"`
Message string `json:"message,omitempty"`
@@ -22,12 +23,14 @@ type APIResponse struct {
Payload []byte `json:"-"`
}
+// NewAPIResponse returns a new APIResonse object.
func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
return response
}
+// NewAPIResponseWithError returns a new APIResponse object with the provided error message.
func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index 8bd402c5500..dc0a2f4dc8b 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -16,11 +16,33 @@ var (
_ _context.Context
)
+// {{classname}}Service {{classname}} service
type {{classname}}Service service
{{#operation}}
+{{#hasOptionalParams}}
+// {{{nickname}}}Opts Optional parameters for the method '{{{nickname}}}'
+type {{{nickname}}}Opts struct {
+{{#allParams}}
+{{^required}}
+{{#isPrimitiveType}}
+{{^isBinary}}
+ {{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
+{{/isBinary}}
+{{#isBinary}}
+ {{vendorExtensions.x-exportParamName}} optional.Interface
+{{/isBinary}}
+{{/isPrimitiveType}}
+{{^isPrimitiveType}}
+ {{vendorExtensions.x-exportParamName}} optional.Interface
+{{/isPrimitiveType}}
+{{/required}}
+{{/allParams}}
+}
+
+{{/hasOptionalParams}}
/*
-{{{classname}}}Service{{#summary}} {{{.}}}{{/summary}}
+{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
{{#notes}}
{{notes}}
{{/notes}}
@@ -42,30 +64,9 @@ type {{classname}}Service service
@return {{{returnType}}}
{{/returnType}}
*/
-{{#hasOptionalParams}}
-
-type {{{nickname}}}Opts struct {
-{{#allParams}}
-{{^required}}
-{{#isPrimitiveType}}
-{{^isBinary}}
- {{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
-{{/isBinary}}
-{{#isBinary}}
- {{vendorExtensions.x-exportParamName}} optional.Interface
-{{/isBinary}}
-{{/isPrimitiveType}}
-{{^isPrimitiveType}}
- {{vendorExtensions.x-exportParamName}} optional.Interface
-{{/isPrimitiveType}}
-{{/required}}
-{{/allParams}}
-}
-
-{{/hasOptionalParams}}
func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*_nethttp.Response, error) {
var (
- localVarHttpMethod = _nethttp.Method{{httpMethod}}
+ localVarHTTPMethod = _nethttp.Method{{httpMethod}}
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
@@ -169,24 +170,24 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
{{/hasQueryParams}}
// to determine the Content-Type header
{{=<% %>=}}
- localVarHttpContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
+ localVarHTTPContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
<%={{ }}=%>
// set Content-Type header
- localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
- if localVarHttpContentType != "" {
- localVarHeaderParams["Content-Type"] = localVarHttpContentType
+ localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
+ if localVarHTTPContentType != "" {
+ localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
{{=<% %>=}}
- localVarHttpHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
+ localVarHTTPHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
<%={{ }}=%>
// set Accept header
- localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
- if localVarHttpHeaderAccept != "" {
- localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
+ localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
+ if localVarHTTPHeaderAccept != "" {
+ localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
{{#hasHeaderParams}}
{{#headerParams}}
@@ -293,56 +294,56 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
{{/isKeyInCookie}}
{{/isApiKey}}
{{/authMethods}}
- r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
+ r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
}
- localVarHttpResponse, err := a.client.callAPI(r)
- if err != nil || localVarHttpResponse == nil {
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
+ localVarHTTPResponse, err := a.client.callAPI(r)
+ if err != nil || localVarHTTPResponse == nil {
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
}
- localVarBody, err := _ioutil.ReadAll(localVarHttpResponse.Body)
- localVarHttpResponse.Body.Close()
+ localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
+ localVarHTTPResponse.Body.Close()
if err != nil {
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
}
- if localVarHttpResponse.StatusCode >= 300 {
+ if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
- error: localVarHttpResponse.Status,
+ error: localVarHTTPResponse.Status,
}
{{#responses}}
{{#dataType}}
- if localVarHttpResponse.StatusCode == {{{code}}} {
+ if localVarHTTPResponse.StatusCode == {{{code}}} {
var v {{{dataType}}}
- err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
+ err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
newErr.model = v
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{/dataType}}
{{/responses}}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{#returnType}}
- err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
+ err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, newErr
}
{{/returnType}}
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, nil
}
{{/operation}}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/go/client.mustache b/modules/openapi-generator/src/main/resources/go/client.mustache
index 1c4241ff043..c3af4534120 100644
--- a/modules/openapi-generator/src/main/resources/go/client.mustache
+++ b/modules/openapi-generator/src/main/resources/go/client.mustache
@@ -164,7 +164,7 @@ func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
return c.cfg.HTTPClient.Do(request)
}
-// Change base path to allow switching to mocks
+// ChangeBasePath changes base path to allow switching to mocks
func (c *APIClient) ChangeBasePath(path string) {
c.cfg.BasePath = path
}
diff --git a/modules/openapi-generator/src/main/resources/go/configuration.mustache b/modules/openapi-generator/src/main/resources/go/configuration.mustache
index 81d3a41b7bd..98f9d8fee26 100644
--- a/modules/openapi-generator/src/main/resources/go/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/go/configuration.mustache
@@ -41,6 +41,7 @@ type APIKey struct {
Prefix string
}
+// Configuration stores the configuration of the API client
type Configuration struct {
BasePath string `json:"basePath,omitempty"`
Host string `json:"host,omitempty"`
@@ -50,6 +51,7 @@ type Configuration struct {
HTTPClient *http.Client
}
+// NewConfiguration returns a new Configuration object
func NewConfiguration() *Configuration {
cfg := &Configuration{
BasePath: "{{{basePath}}}",
@@ -59,6 +61,7 @@ func NewConfiguration() *Configuration {
return cfg
}
+// AddDefaultHeader adds a new HTTP header to the default header in the request
func (c *Configuration) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}
diff --git a/modules/openapi-generator/src/main/resources/go/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/go/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/go/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/go/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/go/go.mod.mustache b/modules/openapi-generator/src/main/resources/go/go.mod.mustache
index ec4310dd593..e02a1be201b 100644
--- a/modules/openapi-generator/src/main/resources/go/go.mod.mustache
+++ b/modules/openapi-generator/src/main/resources/go/go.mod.mustache
@@ -1,4 +1,4 @@
-module github.com/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
+module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
require (
github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6
diff --git a/modules/openapi-generator/src/main/resources/go/model.mustache b/modules/openapi-generator/src/main/resources/go/model.mustache
index cff5e7a4d92..72359c5700c 100644
--- a/modules/openapi-generator/src/main/resources/go/model.mustache
+++ b/modules/openapi-generator/src/main/resources/go/model.mustache
@@ -12,9 +12,7 @@ import (
{{/imports}}
{{#model}}
{{#isEnum}}
-{{#description}}
-// {{{classname}}} : {{{description}}}
-{{/description}}
+// {{{classname}}} {{#description}}{{{.}}}{{/description}}{{^description}}the model '{{{classname}}}'{{/description}}
type {{{classname}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/format}}
// List of {{{name}}}
@@ -26,8 +24,10 @@ const (
{{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = "{{{value}}}"
{{/enumVars}}
{{/allowableValues}}
-){{/isEnum}}{{^isEnum}}{{#description}}
-// {{{description}}}{{/description}}
+)
+{{/isEnum}}
+{{^isEnum}}
+// {{classname}}{{#description}} {{{description}}}{{/description}}{{^description}} struct for {{{classname}}}{{/description}}
type {{classname}} struct {
{{#vars}}
{{^-first}}
diff --git a/modules/openapi-generator/src/main/resources/go/response.mustache b/modules/openapi-generator/src/main/resources/go/response.mustache
index e15d7e6a783..1a8765bae8f 100644
--- a/modules/openapi-generator/src/main/resources/go/response.mustache
+++ b/modules/openapi-generator/src/main/resources/go/response.mustache
@@ -5,6 +5,7 @@ import (
"net/http"
)
+// APIResponse stores the API response returned by the server.
type APIResponse struct {
*http.Response `json:"-"`
Message string `json:"message,omitempty"`
@@ -22,12 +23,14 @@ type APIResponse struct {
Payload []byte `json:"-"`
}
+// NewAPIResponse returns a new APIResonse object.
func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
return response
}
+// NewAPIResponseWithError returns a new APIResponse object with the provided error message.
func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
diff --git a/modules/openapi-generator/src/main/resources/graphql-schema/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/graphql-schema/git_push.sh.mustache
index c344020eab5..8b3f689c912 100755
--- a/modules/openapi-generator/src/main/resources/graphql-schema/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/graphql-schema/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/git_push.sh.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/git_push.sh.mustache
index 8a32e53995d..8b3f689c912 100644
--- a/modules/openapi-generator/src/main/resources/haskell-http-client/git_push.sh.mustache
+++ b/modules/openapi-generator/src/main/resources/haskell-http-client/git_push.sh.mustache
@@ -1,11 +1,17 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
-# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
+# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
+git_host=$4
+
+if [ "$git_host" = "" ]; then
+ git_host="{{{gitHost}}}"
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
+fi
if [ "$git_user_id" = "" ]; then
git_user_id="{{{gitUserId}}}"
@@ -28,7 +34,7 @@ git init
# Adds the files in the local repository and stages them for commit.
git add .
-# Commits the tracked changes and prepares them to be pushed to a remote repository.
+# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
@@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
@@ -47,6 +53,6 @@ fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
-echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
+echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
index b3d790c19ca..725ac257c09 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/README.mustache
@@ -2,11 +2,17 @@
## Requires
+{{#jvm}}
* Kotlin 1.3.41
* Gradle 4.9
+{{/jvm}}
+{{#multiplatform}}
+* Kotlin 1.3.50
+{{/multiplatform}}
## Build
+{{#jvm}}
First, create the gradle wrapper script:
```
@@ -15,6 +21,7 @@ gradle wrapper
Then, run:
+{{/jvm}}
```
./gradlew check assemble
```
@@ -26,7 +33,7 @@ This runs all tests and packages the library.
* Supports JSON inputs/outputs, File inputs, and Form inputs.
* Supports collection formats for query parameters: csv, tsv, ssv, pipes.
* Some Kotlin and Java types are fully qualified to avoid conflicts with types defined in OpenAPI definitions.
-* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.
+{{#jvm}}* Implementation of ApiClient is intended to reduce method counts, specifically to benefit Android targets.{{/jvm}}
{{#generateApiDocs}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
index 05954bb78a6..e735dc05a20 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache
@@ -32,6 +32,9 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.squareup.moshi:moshi-kotlin:1.8.0"
compile "com.squareup.moshi:moshi-adapters:1.8.0"
+ {{#gson}}
+ implementation "com.google.code.gson:gson:2.8.5"
+ {{/gson}}
compile "com.squareup.okhttp3:okhttp:4.0.1"
{{#threetenbp}}
compile "org.threeten:threetenbp:1.3.8"
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
index 35b32bc12aa..0cece22bb0b 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class.mustache
@@ -1,35 +1,64 @@
+{{#jvm}}
+{{#gson}}
+import com.google.gson.annotations.SerializedName
+{{/gson}}
+{{#moshi}}
import com.squareup.moshi.Json
+{{/moshi}}
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
{{/parcelizeModels}}
+{{/jvm}}
+{{#multiplatform}}
+import kotlinx.serialization.*
+import kotlinx.serialization.internal.CommonEnumSerializer
+{{/multiplatform}}
/**
* {{{description}}}
{{#vars}}
- * @param {{name}} {{{description}}}
+ * @param {{{vendorExtensions.x-escapedName}}} {{{description}}}
{{/vars}}
*/
{{#parcelizeModels}}
@Parcelize
{{/parcelizeModels}}
+{{#multiplatform}}@Serializable{{/multiplatform}}
data class {{classname}} (
{{#requiredVars}}
{{>data_class_req_var}}{{^-last}},
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}},
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>data_class_opt_var}}{{^-last}},
{{/-last}}{{/optionalVars}}
-){{#parcelizeModels}} : Parcelable{{/parcelizeModels}} {
-{{#hasEnums}}{{#vars}}{{#isEnum}}
+){{#parcelizeModels}} : Parcelable{{/parcelizeModels}}
+{{#hasEnums}}
+{
+{{#vars}}{{#isEnum}}
/**
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
+ {{#multiplatform}}@Serializable(with = {{nameInCamelCase}}.Serializer::class){{/multiplatform}}
enum class {{{nameInCamelCase}}}(val value: {{#isListContainer}}{{{ nestedType }}}{{/isListContainer}}{{^isListContainer}}{{{dataType}}}{{/isListContainer}}){
{{#allowableValues}}{{#enumVars}}
- @Json(name = {{{value}}})
+ {{#jvm}}
+ {{#moshi}}
+ @Json(name = {{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName(value={{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
+ {{/gson}}
+ {{/jvm}}
+ {{#multiplatform}}
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
+ {{/multiplatform}}
{{/enumVars}}{{/allowableValues}}
+
+ {{#multiplatform}}
+ object Serializer : CommonEnumSerializer<{{nameInCamelCase}}>("{{nameInCamelCase}}", values(), values().map { it.value }.toTypedArray())
+ {{/multiplatform}}
}
-{{/isEnum}}{{/vars}}{{/hasEnums}}
+{{/isEnum}}{{/vars}}
}
+{{/hasEnums}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
index 03cbd718c34..e77b8b2b2ba 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_opt_var.mustache
@@ -1,5 +1,12 @@
{{#description}}
/* {{{description}}} */
{{/description}}
+ {{#jvm}}
+ {{#moshi}}
@Json(name = "{{{baseName}}}")
- val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName("{{name}}")
+ {{/gson}}
+ {{/jvm}}
+ {{#multiplatform}}@SerialName(value = "{{name}}") {{/multiplatform}}val {{{vendorExtensions.x-escapedName}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
index 6682bc8170c..0097d0702a9 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
@@ -1,5 +1,12 @@
{{#description}}
/* {{{description}}} */
{{/description}}
+ {{#jvm}}
+ {{#moshi}}
@Json(name = "{{{baseName}}}")
- val {{{name}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
\ No newline at end of file
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName("{{name}}")
+ {{/gson}}
+ {{/jvm}}
+ {{#multiplatform}}@SerialName(value = "{{name}}") @Required {{/multiplatform}}val {{{vendorExtensions.x-escapedName}}}: {{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
index 80b040f6b7c..ccf8eb0c89f 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/enum_class.mustache
@@ -1,13 +1,32 @@
+{{#jvm}}
+{{#gson}}
+import com.google.gson.annotations.SerializedName
+{{/gson}}
+{{#moshi}}
import com.squareup.moshi.Json
+{{/moshi}}
+{{/jvm}}
+{{#multiplatform}}
+import kotlinx.serialization.*
+import kotlinx.serialization.internal.CommonEnumSerializer
+{{/multiplatform}}
/**
* {{{description}}}
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
*/
+{{#multiplatform}}@Serializable(with = {{classname}}.Serializer::class){{/multiplatform}}
enum class {{classname}}(val value: {{{dataType}}}){
{{#allowableValues}}{{#enumVars}}
+ {{#jvm}}
+ {{#moshi}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
+ {{/moshi}}
+ {{#gson}}
+ @SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
+ {{/gson}}
+ {{/jvm}}
{{#isListContainer}}
{{#isList}}
{{&name}}(listOf({{{value}}})){{^-last}},{{/-last}}{{#-last}};{{/-last}}
@@ -21,4 +40,8 @@ enum class {{classname}}(val value: {{{dataType}}}){
{{/isListContainer}}
{{/enumVars}}{{/allowableValues}}
+
+{{#multiplatform}}
+ object Serializer : CommonEnumSerializer<{{classname}}>("{{classname}}", values(), values().map { it.value }.toTypedArray())
+{{/multiplatform}}
}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache
index 0a42ce534d3..6123c8b01b1 100644
--- a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiAbstractions.kt.mustache
@@ -12,9 +12,12 @@ fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
-fun toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List {
+fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
+ = toMultiValue(items.asIterable(), collectionFormat, map)
+
+fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List {
return when(collectionFormat) {
"multi" -> items.map(map)
- else -> listOf(items.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
+ else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiClient.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiInfrastructureResponse.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiInfrastructureResponse.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiInfrastructureResponse.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApiInfrastructureResponse.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApplicationDelegates.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApplicationDelegates.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApplicationDelegates.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ApplicationDelegates.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ByteArrayAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ByteArrayAdapter.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ByteArrayAdapter.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Errors.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Errors.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Errors.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Errors.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateAdapter.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateAdapter.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateTimeAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/LocalDateTimeAdapter.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/LocalDateTimeAdapter.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ResponseExtensions.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ResponseExtensions.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ResponseExtensions.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/ResponseExtensions.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Serializer.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/Serializer.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/Serializer.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/UUIDAdapter.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/UUIDAdapter.kt.mustache
rename to modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm/infrastructure/UUIDAdapter.kt.mustache
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache
new file mode 100644
index 00000000000..bab78f865b0
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/api.mustache
@@ -0,0 +1,122 @@
+{{>licenseInfo}}
+package {{apiPackage}}
+
+{{#imports}}import {{import}}
+{{/imports}}
+
+import {{packageName}}.infrastructure.*
+import io.ktor.client.request.forms.formData
+import kotlinx.serialization.UnstableDefault
+import io.ktor.client.engine.HttpClientEngine
+import io.ktor.client.features.json.serializer.KotlinxSerializer
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.JsonConfiguration
+import io.ktor.http.ParametersBuilder
+import kotlinx.serialization.*
+import kotlinx.serialization.internal.StringDescriptor
+
+{{#operations}}
+class {{classname}} @UseExperimental(UnstableDefault::class) constructor(
+ baseUrl: kotlin.String = "{{{basePath}}}",
+ httpClientEngine: HttpClientEngine? = null,
+ serializer: KotlinxSerializer)
+ : ApiClient(baseUrl, httpClientEngine, serializer) {
+
+ @UseExperimental(UnstableDefault::class)
+ constructor(
+ baseUrl: kotlin.String = "{{{basePath}}}",
+ httpClientEngine: HttpClientEngine? = null,
+ jsonConfiguration: JsonConfiguration = JsonConfiguration.Default)
+ : this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
+
+ {{#operation}}
+ /**
+ * {{summary}}
+ * {{notes}}
+ {{#allParams}}* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
+ {{/allParams}}* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
+ */
+ {{#returnType}}
+ @Suppress("UNCHECKED_CAST")
+ {{/returnType}}
+ suspend fun {{operationId}}({{#allParams}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : HttpResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}> {
+
+ val localVariableBody = {{#hasBodyParam}}{{#bodyParam}}{{#isListContainer}}{{operationIdCamelCase}}Request({{paramName}}.asList()){{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}{{operationIdCamelCase}}Request({{paramName}}){{/isMapContainer}}{{^isMapContainer}}{{paramName}}{{/isMapContainer}}{{/isListContainer}}{{/bodyParam}}{{/hasBodyParam}}
+ {{^hasBodyParam}}
+ {{#hasFormParams}}
+ {{#isMultipart}}
+ formData {
+ {{#formParams}}
+ {{paramName}}?.apply { append("{{{baseName}}}", {{paramName}}) }
+ {{/formParams}}
+ }
+ {{/isMultipart}}
+ {{^isMultipart}}
+ ParametersBuilder().also {
+ {{#formParams}}
+ {{paramName}}?.apply { it.append("{{{baseName}}}", {{paramName}}.toString()) }
+ {{/formParams}}
+ }.build()
+ {{/isMultipart}}
+ {{/hasFormParams}}
+ {{^hasFormParams}}
+ io.ktor.client.utils.EmptyContent
+ {{/hasFormParams}}
+ {{/hasBodyParam}}
+
+ val localVariableQuery = mutableMapOf>()
+ {{#queryParams}}
+ {{paramName}}?.apply { localVariableQuery["{{baseName}}"] = {{#isContainer}}toMultiValue(this, "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}} }
+ {{/queryParams}}
+
+ val localVariableHeaders = mutableMapOf()
+ {{#headerParams}}
+ {{paramName}}?.apply { localVariableHeaders["{{baseName}}"] = {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}} }
+ {{/headerParams}}
+
+ val localVariableConfig = RequestConfig(
+ RequestMethod.{{httpMethod}},
+ "{{path}}"{{#pathParams}}.replace("{"+"{{baseName}}"+"}", "${{paramName}}"){{/pathParams}},
+ query = localVariableQuery,
+ headers = localVariableHeaders
+ )
+
+ return {{#hasBodyParam}}jsonRequest{{/hasBodyParam}}{{^hasBodyParam}}{{#hasFormParams}}{{#isMultipart}}multipartFormRequest{{/isMultipart}}{{^isMultipart}}urlEncodedFormRequest{{/isMultipart}}{{/hasFormParams}}{{^hasFormParams}}request{{/hasFormParams}}{{/hasBodyParam}}(
+ localVariableConfig,
+ localVariableBody
+ ).{{#isListContainer}}wrap<{{operationIdCamelCase}}Response>().map { value.toTypedArray() }{{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}wrap<{{operationIdCamelCase}}Response>().map { value }{{/isMapContainer}}{{^isMapContainer}}wrap(){{/isMapContainer}}{{/isListContainer}}
+ }
+
+ {{#hasBodyParam}}
+ {{#bodyParam}}
+ {{#isListContainer}}{{>serial_wrapper_request_list}}{{/isListContainer}}{{#isMapContainer}}{{>serial_wrapper_request_map}}{{/isMapContainer}}
+ {{/bodyParam}}
+ {{/hasBodyParam}}
+ {{#isListContainer}}
+ {{>serial_wrapper_response_list}}
+ {{/isListContainer}}
+ {{#isMapContainer}}
+ {{>serial_wrapper_response_map}}
+ {{/isMapContainer}}
+
+ {{/operation}}
+
+ companion object {
+ internal fun setMappers(serializer: KotlinxSerializer) {
+ {{#operation}}
+ {{#hasBodyParam}}
+ {{#bodyParam}}
+ {{#isListContainer}}serializer.setMapper({{operationIdCamelCase}}Request::class, {{operationIdCamelCase}}Request.serializer()){{/isListContainer}}{{#isMapContainer}}serializer.setMapper({{operationIdCamelCase}}Request::class, {{operationIdCamelCase}}Request.serializer()){{/isMapContainer}}
+ {{/bodyParam}}
+ {{/hasBodyParam}}
+ {{#isListContainer}}
+ serializer.setMapper({{operationIdCamelCase}}Response::class, {{operationIdCamelCase}}Response.serializer())
+ {{/isListContainer}}
+ {{#isMapContainer}}
+ serializer.setMapper({{operationIdCamelCase}}Response::class, {{operationIdCamelCase}}Response.serializer())
+ {{/isMapContainer}}
+ {{/operation}}
+ }
+ }
+}
+{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache
new file mode 100644
index 00000000000..1e309cc464a
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.mustache
@@ -0,0 +1,138 @@
+apply plugin: 'kotlin-multiplatform'
+apply plugin: 'kotlinx-serialization'
+
+group '{{groupId}}'
+version '{{artifactVersion}}'
+
+ext {
+ kotlin_version = '1.3.50'
+ kotlinx_version = '1.1.0'
+ coroutines_version = '1.3.1'
+ serialization_version = '0.12.0'
+ ktor_version = '1.2.4'
+}
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50" // $kotlin_version
+ classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.50" // $kotlin_version
+ }
+}
+
+repositories {
+ jcenter()
+}
+
+kotlin {
+ jvm()
+ iosArm64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
+ iosX64() { binaries { framework { freeCompilerArgs.add("-Xobjc-generics") } } }
+
+ sourceSets {
+ commonMain {
+ dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
+ implementation "io.ktor:ktor-client-core:$ktor_version"
+ implementation "io.ktor:ktor-client-json:$ktor_version"
+ implementation "io.ktor:ktor-client-serialization:$ktor_version"
+ }
+ }
+
+ commonTest {
+ dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-test-common"
+ implementation "org.jetbrains.kotlin:kotlin-test-annotations-common"
+ implementation "io.ktor:ktor-client-mock:$ktor_version"
+ }
+ }
+
+ jvmMain {
+ dependsOn commonMain
+ dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
+ implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
+ implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
+ implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
+ }
+ }
+
+ jvmTest {
+ dependsOn commonTest
+ dependencies {
+ implementation "org.jetbrains.kotlin:kotlin-test"
+ implementation "org.jetbrains.kotlin:kotlin-test-junit"
+ implementation "io.ktor:ktor-client-mock-jvm:$ktor_version"
+ }
+ }
+
+ iosMain {
+ dependsOn commonMain
+ dependencies {
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
+ implementation "io.ktor:ktor-client-ios:$ktor_version"
+ }
+ }
+
+ iosTest {
+ dependsOn commonTest
+ dependencies {
+ implementation "io.ktor:ktor-client-mock-native:$ktor_version"
+ }
+ }
+
+ iosArm64().compilations.main.defaultSourceSet {
+ dependsOn iosMain
+ dependencies {
+ implementation "io.ktor:ktor-client-ios-iosarm64:$ktor_version"
+ implementation "io.ktor:ktor-client-json-iosarm64:$ktor_version"
+ implementation "io.ktor:ktor-client-serialization-iosarm64:$ktor_version"
+ }
+ }
+
+ iosArm64().compilations.test.defaultSourceSet {
+ dependsOn iosTest
+ }
+
+ iosX64().compilations.main.defaultSourceSet {
+ dependsOn iosMain
+ dependencies {
+ implementation "io.ktor:ktor-client-ios-iosx64:$ktor_version"
+ implementation "io.ktor:ktor-client-json-iosx64:$ktor_version"
+ implementation "io.ktor:ktor-client-serialization-iosx64:$ktor_version"
+ }
+ }
+
+ iosX64().compilations.test.defaultSourceSet {
+ dependsOn iosTest
+ }
+
+ all {
+ languageSettings {
+ useExperimentalAnnotation('kotlin.Experimental')
+ }
+ }
+ }
+}
+
+task iosTest {
+ def device = project.findProperty("device")?.toString() ?: "iPhone 8"
+ dependsOn 'linkDebugTestIosX64'
+ group = JavaBasePlugin.VERIFICATION_GROUP
+ description = "Execute unit tests on ${device} simulator"
+ doLast {
+ def binary = kotlin.targets.iosX64.binaries.getTest('DEBUG')
+ exec { commandLine 'xcrun', 'simctl', 'spawn', device, binary.outputFile }
+ }
+}
+
+configurations { // workaround for https://youtrack.jetbrains.com/issue/KT-27170
+ compileClasspath
+}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache
new file mode 100644
index 00000000000..c3bd8b18461
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/commonTest/coroutine.mustache
@@ -0,0 +1,13 @@
+{{>licenseInfo}}
+
+package util
+
+import kotlinx.coroutines.CoroutineScope
+
+/**
+* Block the current thread until execution of the given coroutine is complete.
+*
+* @param block The coroutine code.
+* @return The result of the coroutine.
+*/
+internal expect fun runTest(block: suspend CoroutineScope.() -> T): T
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar
new file mode 100644
index 00000000000..2c6137b8789
Binary files /dev/null and b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.jar differ
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache
new file mode 100644
index 00000000000..ce3ca77db54
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradle-wrapper.properties.mustache
@@ -0,0 +1,6 @@
+#Tue May 17 23:08:05 CST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache
new file mode 100644
index 00000000000..5f192121eb4
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.bat.mustache
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache
new file mode 100755
index 00000000000..9d82f789151
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/gradlew.mustache
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache
new file mode 100644
index 00000000000..fdb83114b7b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/ApiClient.kt.mustache
@@ -0,0 +1,122 @@
+package {{packageName}}.infrastructure
+
+import io.ktor.client.HttpClient
+import io.ktor.client.HttpClientConfig
+import io.ktor.client.call.call
+import io.ktor.client.engine.HttpClientEngine
+import io.ktor.client.features.json.JsonFeature
+import io.ktor.client.features.json.JsonSerializer
+import io.ktor.client.features.json.serializer.KotlinxSerializer
+import io.ktor.client.request.accept
+import io.ktor.client.request.forms.FormDataContent
+import io.ktor.client.request.forms.MultiPartFormDataContent
+import io.ktor.client.request.header
+import io.ktor.client.request.parameter
+import io.ktor.client.response.HttpResponse
+import io.ktor.client.utils.EmptyContent
+import io.ktor.http.*
+import io.ktor.http.content.OutgoingContent
+import io.ktor.http.content.PartData
+import kotlinx.serialization.UnstableDefault
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.JsonConfiguration
+
+import {{apiPackage}}.*
+import {{modelPackage}}.*
+
+open class ApiClient(
+ private val baseUrl: String,
+ httpClientEngine: HttpClientEngine?,
+ serializer: KotlinxSerializer) {
+
+ @UseExperimental(UnstableDefault::class)
+ constructor(
+ baseUrl: String,
+ httpClientEngine: HttpClientEngine?,
+ jsonConfiguration: JsonConfiguration) :
+ this(baseUrl, httpClientEngine, KotlinxSerializer(Json(jsonConfiguration)))
+
+ private val serializer: JsonSerializer by lazy {
+ serializer.apply { setMappers(this) }.ignoreOutgoingContent()
+ }
+
+ private val client: HttpClient by lazy {
+ val jsonConfig: JsonFeature.Config.() -> Unit = { this.serializer = this@ApiClient.serializer }
+ val clientConfig: (HttpClientConfig<*>) -> Unit = { it.install(JsonFeature, jsonConfig) }
+ httpClientEngine?.let { HttpClient(it, clientConfig) } ?: HttpClient(clientConfig)
+ }
+
+ companion object {
+ protected val UNSAFE_HEADERS = listOf(HttpHeaders.ContentType)
+
+ private fun setMappers(serializer: KotlinxSerializer) {
+ {{#apiInfo}}{{#apis}}
+ {{classname}}.setMappers(serializer)
+ {{/apis}}{{/apiInfo}}
+ {{#models}}
+ {{#model}}{{^isAlias}}serializer.setMapper({{classname}}::class, {{classname}}.serializer()){{/isAlias}}{{/model}}
+ {{/models}}
+ }
+ }
+
+ protected suspend fun multipartFormRequest(requestConfig: RequestConfig, body: List?): HttpResponse {
+ return request(requestConfig, MultiPartFormDataContent(body ?: listOf()))
+ }
+
+ protected suspend fun urlEncodedFormRequest(requestConfig: RequestConfig, body: Parameters?): HttpResponse {
+ return request(requestConfig, FormDataContent(body ?: Parameters.Empty))
+ }
+
+ protected suspend fun jsonRequest(requestConfig: RequestConfig, body: Any? = null): HttpResponse {
+ val contentType = (requestConfig.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it) }
+ ?: ContentType.Application.Json)
+ return if (body != null) request(requestConfig, serializer.write(body, contentType))
+ else request(requestConfig)
+ }
+
+ protected suspend fun request(requestConfig: RequestConfig, body: OutgoingContent = EmptyContent): HttpResponse {
+ val headers = requestConfig.headers
+
+ return client.call {
+ this.url {
+ this.takeFrom(URLBuilder(baseUrl))
+ appendPath(requestConfig.path.trimStart('/').split('/'))
+ requestConfig.query.forEach { query ->
+ query.value.forEach { value ->
+ parameter(query.key, value)
+ }
+ }
+ }
+ this.method = requestConfig.method.httpMethod
+ headers.filter { header -> !UNSAFE_HEADERS.contains(header.key) }.forEach { header -> this.header(header.key, header.value) }
+ if (requestConfig.method in listOf(RequestMethod.PUT, RequestMethod.POST, RequestMethod.PATCH))
+ this.body = body
+
+ }.response
+ }
+
+ private fun URLBuilder.appendPath(components: List): URLBuilder = apply {
+ encodedPath = encodedPath.trimEnd('/') + components.joinToString("/", prefix = "/") { it.encodeURLQueryComponent() }
+ }
+
+ private val RequestMethod.httpMethod: HttpMethod
+ get() = when (this) {
+ RequestMethod.DELETE -> HttpMethod.Delete
+ RequestMethod.GET -> HttpMethod.Get
+ RequestMethod.HEAD -> HttpMethod.Head
+ RequestMethod.PATCH -> HttpMethod.Patch
+ RequestMethod.PUT -> HttpMethod.Put
+ RequestMethod.POST -> HttpMethod.Post
+ RequestMethod.OPTIONS -> HttpMethod.Options
+ }
+}
+
+// https://github.com/ktorio/ktor/issues/851
+private fun JsonSerializer.ignoreOutgoingContent() = IgnoreOutgoingContentJsonSerializer(this)
+
+private class IgnoreOutgoingContentJsonSerializer(private val delegate: JsonSerializer) : JsonSerializer by delegate {
+ override fun write(data: Any): OutgoingContent {
+ if (data is OutgoingContent) return data
+ return delegate.write(data)
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache
new file mode 100644
index 00000000000..6bf43085b73
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/HttpResponse.kt.mustache
@@ -0,0 +1,51 @@
+package {{packageName}}.infrastructure
+
+import io.ktor.client.call.TypeInfo
+import io.ktor.client.call.typeInfo
+import io.ktor.http.Headers
+import io.ktor.http.isSuccess
+
+open class HttpResponse(val response: io.ktor.client.response.HttpResponse, val provider: BodyProvider) {
+ val status: Int = response.status.value
+ val success: Boolean = response.status.isSuccess()
+ val headers: Map> = response.headers.mapEntries()
+ suspend fun body(): T = provider.body(response)
+ suspend fun typedBody(type: TypeInfo): V = provider.typedBody(response, type)
+
+ companion object {
+ private fun Headers.mapEntries(): Map> {
+ val result = mutableMapOf>()
+ entries().forEach { result[it.key] = it.value }
+ return result
+ }
+ }
+}
+
+interface BodyProvider {
+ suspend fun body(response: io.ktor.client.response.HttpResponse): T
+ suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V
+}
+
+class TypedBodyProvider(private val type: TypeInfo) : BodyProvider {
+ @Suppress("UNCHECKED_CAST")
+ override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
+ response.call.receive(type) as T
+
+ @Suppress("UNCHECKED_CAST")
+ override suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V =
+ response.call.receive(type) as V
+}
+
+class MappedBodyProvider(private val provider: BodyProvider, private val block: S.() -> T) : BodyProvider {
+ override suspend fun body(response: io.ktor.client.response.HttpResponse): T =
+ block(provider.body(response))
+
+ override suspend fun typedBody(response: io.ktor.client.response.HttpResponse, type: TypeInfo): V =
+ provider.typedBody(response, type)
+}
+
+inline fun io.ktor.client.response.HttpResponse.wrap(): HttpResponse =
+ HttpResponse(this, TypedBodyProvider(typeInfo()))
+
+fun HttpResponse.map(block: T.() -> V): HttpResponse =
+ HttpResponse(response, MappedBodyProvider(provider, block))
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache
new file mode 100644
index 00000000000..351c0120b7b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/iosTest/coroutine.mustache
@@ -0,0 +1,8 @@
+{{>licenseInfo}}
+
+package util
+
+import kotlinx.coroutines.CoroutineScope
+import kotlin.coroutines.EmptyCoroutineContext
+
+internal actual fun runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block)
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache
new file mode 100644
index 00000000000..351c0120b7b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/jvmTest/coroutine.mustache
@@ -0,0 +1,8 @@
+{{>licenseInfo}}
+
+package util
+
+import kotlinx.coroutines.CoroutineScope
+import kotlin.coroutines.EmptyCoroutineContext
+
+internal actual fun runTest(block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(EmptyCoroutineContext, block)
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache
new file mode 100644
index 00000000000..1e240683b80
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_list.mustache
@@ -0,0 +1,10 @@
+@Serializable
+private class {{operationIdCamelCase}}Request(val value: List<{{#bodyParam}}{{baseType}}{{/bodyParam}}>) {
+ @Serializer({{operationIdCamelCase}}Request::class)
+ companion object : KSerializer<{{operationIdCamelCase}}Request> {
+ private val serializer: KSerializer> = {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer().list
+ override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
+ override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
+ override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Request(serializer.deserialize(decoder))
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache
new file mode 100644
index 00000000000..7da90c9974b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_request_map.mustache
@@ -0,0 +1,10 @@
+@Serializable
+private class {{operationIdCamelCase}}Request(val value: Map) {
+ @Serializer({{operationIdCamelCase}}Request::class)
+ companion object : KSerializer<{{operationIdCamelCase}}Request> {
+ private val serializer: KSerializer> = (kotlin.String.serializer() to {{#bodyParam}}{{baseType}}{{/bodyParam}}.serializer()).map
+ override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Request")
+ override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Request) = serializer.serialize(encoder, obj.value)
+ override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Request(serializer.deserialize(decoder))
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache
new file mode 100644
index 00000000000..91403ee50b4
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_list.mustache
@@ -0,0 +1,10 @@
+@Serializable
+private class {{operationIdCamelCase}}Response(val value: List<{{returnBaseType}}>) {
+ @Serializer({{operationIdCamelCase}}Response::class)
+ companion object : KSerializer<{{operationIdCamelCase}}Response> {
+ private val serializer: KSerializer> = {{returnBaseType}}.serializer().list
+ override val descriptor = StringDescriptor.withName("{{operationIdCamelCase}}Response")
+ override fun serialize(encoder: Encoder, obj: {{operationIdCamelCase}}Response) = serializer.serialize(encoder, obj.value)
+ override fun deserialize(decoder: Decoder) = {{operationIdCamelCase}}Response(serializer.deserialize(decoder))
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache
new file mode 100644
index 00000000000..730e0b672c5
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/serial_wrapper_response_map.mustache
@@ -0,0 +1,10 @@
+@Serializable
+private class {{operationIdCamelCase}}Response(val value: Map