diff --git a/.travis.yml b/.travis.yml
index 8c3abe8a927..01f388d10b2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -62,7 +62,6 @@ before_install:
- gem install bundler
- npm install -g typescript
- npm install -g npm
- #- npm install -g elm@0.18.0-exp5
- npm config set registry http://registry.npmjs.org/
# set python 3.6.3 as default
- source ~/virtualenv/python3.6/bin/activate
diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh
index b7142b28a9d..a1462d57c36 100755
--- a/CI/circle_parallel.sh
+++ b/CI/circle_parallel.sh
@@ -21,9 +21,6 @@ elif [ "$NODE_INDEX" = "2" ]; then
echo "Running node $NODE_INDEX to test ensure-up-to-date"
java -version
- # install elm-format
- npm install -g elm-format
-
# clear any changes to the samples
git checkout -- .
diff --git a/bin/elm-0.18-petstore.sh b/bin/elm-0.18-petstore.sh
deleted file mode 100755
index 4ec99604def..00000000000
--- a/bin/elm-0.18-petstore.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-SCRIPT="$0"
-echo "# START SCRIPT: $SCRIPT"
-
-while [ -h "$SCRIPT" ] ; do
- ls=`ls -ld "$SCRIPT"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- SCRIPT="$link"
- else
- SCRIPT=`dirname "$SCRIPT"`/"$link"
- fi
-done
-
-if [ ! -d "${APP_DIR}" ]; then
- APP_DIR=`dirname "$SCRIPT"`/..
- APP_DIR=`cd "${APP_DIR}"; pwd`
-fi
-
-executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
-
-if [ ! -f "$executable" ]
-then
- mvn -B clean package
-fi
-
-# auto format elm code using elm-format
-export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.18 --yes"
-
-# if you've executed sbt assembly previously it will use that instead.
-export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/client/petstore/elm-0.18 --additional-properties elmVersion=0.18 --enable-post-process-file $@"
-
-java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/elm-petstore-all.sh b/bin/elm-petstore-all.sh
deleted file mode 100755
index 0d64cf613cf..00000000000
--- a/bin/elm-petstore-all.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-./bin/elm-0.18-petstore.sh
-./bin/elm-petstore.sh
-
diff --git a/bin/elm-petstore.sh b/bin/elm-petstore.sh
deleted file mode 100755
index dd4c67f4945..00000000000
--- a/bin/elm-petstore.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-SCRIPT="$0"
-echo "# START SCRIPT: $SCRIPT"
-
-while [ -h "$SCRIPT" ] ; do
- ls=`ls -ld "$SCRIPT"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- SCRIPT="$link"
- else
- SCRIPT=`dirname "$SCRIPT"`/"$link"
- fi
-done
-
-if [ ! -d "${APP_DIR}" ]; then
- APP_DIR=`dirname "$SCRIPT"`/..
- APP_DIR=`cd "${APP_DIR}"; pwd`
-fi
-
-executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
-
-if [ ! -f "$executable" ]
-then
- mvn -B clean package
-fi
-
-# auto format elm code using elm-format
-export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.19 --yes"
-
-# if you've executed sbt assembly previously it will use that instead.
-export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/client/petstore/elm --enable-post-process-file $@"
-
-java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/openapi3/elm-all.sh b/bin/openapi3/elm-all.sh
deleted file mode 100755
index 199d1182de2..00000000000
--- a/bin/openapi3/elm-all.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-./bin/openapi3/elm-petstore.sh
-./bin/openapi3/elm-composition.sh
-
diff --git a/bin/openapi3/elm-composition.sh b/bin/openapi3/elm-composition.sh
deleted file mode 100755
index 97ad1649502..00000000000
--- a/bin/openapi3/elm-composition.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-SCRIPT="$0"
-echo "# START SCRIPT: $SCRIPT"
-
-while [ -h "$SCRIPT" ] ; do
- ls=`ls -ld "$SCRIPT"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- SCRIPT="$link"
- else
- SCRIPT=`dirname "$SCRIPT"`/"$link"
- fi
-done
-
-if [ ! -d "${APP_DIR}" ]; then
- APP_DIR=`dirname "$SCRIPT"`/..
- APP_DIR=`cd "${APP_DIR}"; pwd`
-fi
-
-executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
-
-if [ ! -f "$executable" ]
-then
- mvn -B clean package
-fi
-
-# auto format elm code using elm-format
-export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.19 --yes"
-
-# if you've executed sbt assembly previously it will use that instead.
-export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -i modules/openapi-generator/src/test/resources/3_0/composition.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/composition/elm --enable-post-process-file $@"
-
-java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/openapi3/elm-petstore.sh b/bin/openapi3/elm.sh
similarity index 78%
rename from bin/openapi3/elm-petstore.sh
rename to bin/openapi3/elm.sh
index 082678c7bff..9f7eba8ce33 100755
--- a/bin/openapi3/elm-petstore.sh
+++ b/bin/openapi3/elm.sh
@@ -22,11 +22,11 @@ executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
- mvn clean package
+ mvn -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/petstore/elm --additional-properties elmPrefixCustomTypeVariants=true $@"
+ags="generate -i modules/openapi-generator/src/test/resources/3_0/elm.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/elm $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date
index 561988aa07e..f7d7172d479 100755
--- a/bin/utils/ensure-up-to-date
+++ b/bin/utils/ensure-up-to-date
@@ -77,7 +77,7 @@ declare -a samples=(
"${root}/bin/dart-petstore.sh"
"${root}/bin/dart2-petstore.sh"
"${root}/bin/java-play-framework-petstore-server-all.sh"
-#"${root}/bin/elm-petstore-all.sh"
+"${root}/bin/openapi3/elm.sh"
"${root}/bin/typescript-redux-query-petstore-with-npm-version.sh"
)
diff --git a/docs/generators/elm.md b/docs/generators/elm.md
index 922560cd6d3..b9df3d2422e 100644
--- a/docs/generators/elm.md
+++ b/docs/generators/elm.md
@@ -5,7 +5,3 @@ sidebar_label: elm
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
-|elmVersion|Elm version: 0.18, 0.19|
- **0.19**
- Elm 0.19
- **0.18**
- Elm 0.18
|0.19|
-|elmPrefixCustomTypeVariants|Prefix custom type variants| |false|
-|elmEnableCustomBasePaths|Enable setting the base path for each request| |false|
-|elmEnableHttpRequestTrackers|Enable adding a tracker to each http request| |false|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
index 15bfcb01036..29efd452af2 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java
@@ -38,18 +38,6 @@ import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(ElmClientCodegen.class);
- private Set customPrimitives = new HashSet();
- private ElmVersion elmVersion = ElmVersion.ELM_019;
- private Boolean elmPrefixCustomTypeVariants = false;
-
- private static final String ELM_VERSION = "elmVersion";
- private static final String ELM_PREFIX_CUSTOM_TYPE_VARIANTS = "elmPrefixCustomTypeVariants";
- private static final String ELM_ENABLE_CUSTOM_BASE_PATHS = "elmEnableCustomBasePaths";
- private static final String ELM_ENABLE_HTTP_REQUEST_TRACKERS = "elmEnableHttpRequestTrackers";
- private static final String ENCODER = "elmEncoder";
- private static final String DECODER = "elmDecoder";
- private static final String DISCRIMINATOR_NAME = "discriminatorName";
- private static final String CUSTOM_TYPE = "elmCustomType";
protected String packageName = "openapi";
protected String packageVersion = "1.0.0";
@@ -64,14 +52,14 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
public String getHelp() {
- return "Generates a Elm client library (beta).";
+ return "Generates an Elm client library.";
}
public ElmClientCodegen() {
super();
- outputFolder = "generated-code/elm";
- modelTemplateFiles.put("model.mustache", ".elm");
templateDir = "elm";
+ apiPackage = "Api.Request";
+ modelPackage = "Api";
supportsInheritance = true;
@@ -109,14 +97,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
"String")
);
- customPrimitives = new HashSet<>(
- Arrays.asList(
- "Byte",
- "DateOnly",
- "DateTime",
- "Uuid")
- );
-
instantiationTypes.clear();
instantiationTypes.put("array", "List");
instantiationTypes.put("map", "Dict");
@@ -131,10 +111,10 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("string", "String");
typeMapping.put("array", "List");
typeMapping.put("map", "Dict");
- typeMapping.put("date", "DateOnly");
- typeMapping.put("DateTime", "DateTime");
+ typeMapping.put("date", "Posix");
+ typeMapping.put("DateTime", "Posix");
typeMapping.put("password", "String");
- typeMapping.put("ByteArray", "Byte");
+ typeMapping.put("ByteArray", "String");
typeMapping.put("file", "String");
typeMapping.put("binary", "String");
typeMapping.put("UUID", "Uuid");
@@ -144,80 +124,11 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.clear();
- final CliOption elmVersion = new CliOption(ELM_VERSION, "Elm version: 0.18, 0.19").defaultValue("0.19");
- final Map supportedVersions = new HashMap<>();
- supportedVersions.put("0.18", "Elm 0.18");
- supportedVersions.put("0.19", "Elm 0.19");
- elmVersion.setEnum(supportedVersions);
- cliOptions.add(elmVersion);
- final CliOption elmPrefixCustomTypeVariants = CliOption.newBoolean(ELM_PREFIX_CUSTOM_TYPE_VARIANTS, "Prefix custom type variants");
- cliOptions.add(elmPrefixCustomTypeVariants);
- final CliOption elmEnableCustomBasePaths = CliOption.newBoolean(ELM_ENABLE_CUSTOM_BASE_PATHS, "Enable setting the base path for each request");
- cliOptions.add(elmEnableCustomBasePaths);
- final CliOption elmEnableHttpRequestTrackers = CliOption.newBoolean(ELM_ENABLE_HTTP_REQUEST_TRACKERS, "Enable adding a tracker to each http request");
- cliOptions.add(elmEnableHttpRequestTrackers);
- }
-
- @Override
- public void processOpts() {
- super.processOpts();
-
- if (additionalProperties.containsKey(ELM_VERSION)) {
- final String version = (String) additionalProperties.get(ELM_VERSION);
- if ("0.18".equals(version)) {
- elmVersion = ElmVersion.ELM_018;
- } else {
- elmVersion = ElmVersion.ELM_019;
- }
- }
-
- if (additionalProperties.containsKey(ELM_PREFIX_CUSTOM_TYPE_VARIANTS)) {
- elmPrefixCustomTypeVariants = Boolean.TRUE.equals(Boolean.valueOf(additionalProperties.get(ELM_PREFIX_CUSTOM_TYPE_VARIANTS).toString()));
- }
-
- if (additionalProperties.containsKey(ELM_ENABLE_CUSTOM_BASE_PATHS)) {
- final boolean enable = Boolean.TRUE.equals(Boolean.valueOf(additionalProperties.get(ELM_ENABLE_CUSTOM_BASE_PATHS).toString()));
- additionalProperties.put("enableCustomBasePaths", enable);
- }
-
- if (additionalProperties.containsKey(ELM_ENABLE_HTTP_REQUEST_TRACKERS)) {
- final boolean enable = Boolean.TRUE.equals(Boolean.valueOf(additionalProperties.get(ELM_ENABLE_HTTP_REQUEST_TRACKERS).toString()));
- additionalProperties.put("enableHttpRequestTrackers", enable);
- }
-
- if (StringUtils.isEmpty(System.getenv("ELM_POST_PROCESS_FILE"))) {
- if (elmVersion.equals(ElmVersion.ELM_018)) { // 0.18
- LOGGER.info("Environment variable ELM_POST_PROCESS_FILE not defined so the Elm code may not be properly formatted. To define it, try `export ELM_POST_PROCESS_FILE=\"/usr/local/bin/elm-format --elm-version={} --yes\"` (Linux/Mac)", "0.18");
- } else { // 0.19
- LOGGER.info("Environment variable ELM_POST_PROCESS_FILE not defined so the Elm code may not be properly formatted. To define it, try `export ELM_POST_PROCESS_FILE=\"/usr/local/bin/elm-format --elm-version={} --yes\"` (Linux/Mac)", "0.19");
- }
- LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
- }
-
- switch (elmVersion) {
- case ELM_018:
- LOGGER.info("Elm version: 0.18");
- additionalProperties.put("isElm018", true);
- apiTemplateFiles.put("api018.mustache", ".elm");
- supportingFiles.add(new SupportingFile("DateOnly018.mustache", "src", "DateOnly.elm"));
- supportingFiles.add(new SupportingFile("DateTime018.mustache", "src", "DateTime.elm"));
- supportingFiles.add(new SupportingFile("elm-package018.mustache", "", "elm-package.json"));
- supportingFiles.add(new SupportingFile("Main018.mustache", "src", "Main.elm"));
- break;
- case ELM_019:
- LOGGER.info("Elm version: 0.19");
- additionalProperties.put("isElm019", true);
- apiTemplateFiles.put("api.mustache", ".elm");
- supportingFiles.add(new SupportingFile("DateOnly.mustache", "src", "DateOnly.elm"));
- supportingFiles.add(new SupportingFile("DateTime.mustache", "src", "DateTime.elm"));
- supportingFiles.add(new SupportingFile("elm.mustache", "", "elm.json"));
- supportingFiles.add(new SupportingFile("Main.mustache", "src", "Main.elm"));
- break;
- default:
- throw new RuntimeException("Undefined Elm version");
- }
-
- supportingFiles.add(new SupportingFile("Byte.mustache", "src", "Byte.elm"));
+ apiTemplateFiles.put("operation.mustache", ".elm");
+ modelTemplateFiles.put("model.mustache", ".elm");
+ supportingFiles.add(new SupportingFile("Api.mustache", "", "src" + File.separator + "Api.elm"));
+ supportingFiles.add(new SupportingFile("Time.mustache", "", "src" + File.separator + "Api" + File.separator + "Time.elm"));
+ supportingFiles.add(new SupportingFile("elm.mustache", "", "elm.json"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
@@ -246,11 +157,6 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
return defaultIncludes.contains(modelName) ? modelName + "_" : modelName;
}
- @Override
- public String toModelFilename(String name) {
- return toModelName(name);
- }
-
@Override
public String toEnumName(CodegenProperty property) {
return toModelName(property.name);
@@ -258,22 +164,17 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toVarName(String name) {
- final String varName = camelize(name, true);
+ final String varName = camelize(name.replaceAll("[^a-zA-Z0-9_]", ""), true);
return isReservedWord(varName) ? escapeReservedWord(name) : varName;
}
@Override
public String toEnumVarName(String value, String datatype) {
String camelized = camelize(value.replace(" ", "_").replace("(", "_").replace(")", "")); // TODO FIXME escape properly
-
if (camelized.length() == 0) {
LOGGER.error("Unable to determine enum variable name (name: {}, datatype: {}) from empty string. Default to UnknownEnumVariableName", value, datatype);
camelized = "UnknownEnumVariableName";
}
-
- if (!Character.isUpperCase(camelized.charAt(0))) {
- return "N" + camelized;
- }
return camelized;
}
@@ -288,132 +189,100 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
}
}
+ @Override
+ public String apiFileFolder() {
+ return outputFolder + File.separator + "src" + File.separator + apiPackage().replace('.', File.separatorChar);
+ }
+
+ @Override
+ public String modelFileFolder() {
+ return outputFolder + File.separator + "src" + File.separator + modelPackage().replace('.', File.separatorChar);
+ }
+
@Override
public String escapeReservedWord(String name) {
return name + "_";
}
@Override
- public String apiFileFolder() {
- return outputFolder + ("/src/Request/" + apiPackage().replace('.', File.separatorChar)).replace("/", File.separator);
- }
-
- @Override
- public String modelFileFolder() {
- return outputFolder + ("/src/Data/" + modelPackage().replace('.', File.separatorChar)).replace("/", File.separator);
- }
-
- @Override
- public CodegenModel fromModel(String name, Schema schema) {
- CodegenModel m = super.fromModel(name, schema);
-
- if (ModelUtils.isArraySchema(schema)) {
- ArraySchema am = (ArraySchema) schema;
- CodegenProperty codegenProperty = fromProperty(name, (Schema) am.getItems());
- m.vendorExtensions.putAll(codegenProperty.vendorExtensions);
+ public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
+ if (property.getAllowableValues() != null && !property.getAllowableValues().isEmpty()) {
+ property.isModel = true;
}
-
- return m;
}
@SuppressWarnings({"static-method", "unchecked"})
- public Map postProcessAllModels(Map objs) {
- // Index all CodegenModels by model name.
- Map allModels = new HashMap<>();
- for (Map.Entry entry : objs.entrySet()) {
- String modelName = toModelName(entry.getKey());
- Map inner = (Map) entry.getValue();
- List