mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-17 08:59:05 +00:00
[JavaScript] fix index.js, ApiClient.js and test files generated to incorrect location (#2511)
remove outdated samples files update test dependencies
This commit is contained in:
committed by
William Cheng
parent
c4d982f775
commit
8977d7b366
@@ -51,8 +51,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
final String[][] JAVASCRIPT_SUPPORTING_FILES = new String[][]{
|
||||
new String[]{"package.mustache", "package.json"},
|
||||
new String[]{"index.mustache", "src/index.js"},
|
||||
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||
// new String[]{"index.mustache", "src/index.js", },
|
||||
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
||||
new String[]{"README.mustache", "README.md"},
|
||||
new String[]{"mocha.opts", "mocha.opts"},
|
||||
@@ -61,8 +61,8 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
final String[][] JAVASCRIPT_ES6_SUPPORTING_FILES = new String[][]{
|
||||
new String[]{"package.mustache", "package.json"},
|
||||
new String[]{"index.mustache", "src/index.js"},
|
||||
new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||
// new String[]{"index.mustache", "src/index.js"},
|
||||
// new String[]{"ApiClient.mustache", "src/ApiClient.js"},
|
||||
new String[]{"git_push.sh.mustache", "git_push.sh"},
|
||||
new String[]{"README.mustache", "README.md"},
|
||||
new String[]{"mocha.opts", "mocha.opts"},
|
||||
@@ -85,7 +85,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
protected String modelDocPath = "docs/";
|
||||
protected String apiTestPath = "api/";
|
||||
protected String modelTestPath = "model/";
|
||||
protected boolean useES6 = true; // default is ES5
|
||||
protected boolean useES6 = true; // default is ES6
|
||||
private String modelPropertyNaming = "camelCase";
|
||||
|
||||
public JavascriptClientCodegen() {
|
||||
@@ -337,6 +337,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
for (String[] supportingTemplateFile : supportingTemplateFiles) {
|
||||
supportingFiles.add(new SupportingFile(supportingTemplateFile[0], "", supportingTemplateFile[1]));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("index.mustache", createPath(sourceFolder, invokerPackage), "index.js"));
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", createPath(sourceFolder, invokerPackage), "ApiClient.js"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -373,12 +376,12 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return (outputFolder + "/test/" + apiTestPath).replace('/', File.separatorChar);
|
||||
return createPath(outputFolder, "test", invokerPackage, apiTestPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return (outputFolder + "/test/" + modelTestPath).replace('/', File.separatorChar);
|
||||
return createPath(outputFolder, "test", invokerPackage, modelTestPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -788,7 +791,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
* @param type Primitive type
|
||||
* @return Normalized type
|
||||
*/
|
||||
public String normalizeType(String type) {
|
||||
private String normalizeType(String type) {
|
||||
return type.replaceAll("\\b(Boolean|Integer|Number|String|Date|Blob)\\b", "'$1'");
|
||||
}
|
||||
|
||||
@@ -867,10 +870,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
/*
|
||||
private String sanitizePath(String p) {
|
||||
//prefer replace a ', instead of a fuLL URL encode for readability
|
||||
return p.replaceAll("'", "%27");
|
||||
}
|
||||
}*/
|
||||
|
||||
private String trimBrackets(String s) {
|
||||
if (s != null) {
|
||||
@@ -959,7 +963,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
List<String> argList = new ArrayList<String>();
|
||||
List<String> argList = new ArrayList<>();
|
||||
boolean hasOptionalParams = false;
|
||||
for (CodegenParameter p : operation.allParams) {
|
||||
if (p.required) {
|
||||
@@ -1014,7 +1018,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
// NOTE: can't use 'mandatory' as it is built from ModelImpl.getRequired(), which sorts names
|
||||
// alphabetically and in any case the document order of 'required' and 'properties' can differ.
|
||||
List<CodegenProperty> required = new ArrayList<>();
|
||||
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<CodegenProperty>() : required;
|
||||
List<CodegenProperty> allRequired = supportsInheritance || supportsMixins ? new ArrayList<>() : required;
|
||||
cm.vendorExtensions.put("x-required", required);
|
||||
cm.vendorExtensions.put("x-all-required", allRequired);
|
||||
|
||||
@@ -1120,6 +1124,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
/*
|
||||
private static String sanitizePackageName(String packageName) { // FIXME parameter should not be assigned. Also declare it as "final"
|
||||
packageName = packageName.trim();
|
||||
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
|
||||
@@ -1128,6 +1133,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
return packageName;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
|
||||
Reference in New Issue
Block a user