Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refs swagger-api/swagger-codegen#9909 - fix javascript generator templateDir and missing template file #562

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public JavaScriptClientCodegen() {
modelTestTemplateFiles.put("model_test.mustache", ".js");
apiTemplateFiles.put("api.mustache", ".js");
apiTestTemplateFiles.put("api_test.mustache", ".js");
embeddedTemplateDir = templateDir = "javascript";
if (StringUtils.isBlank(templateDir)) {
embeddedTemplateDir = templateDir = getTemplateDir();
}
apiPackage = "api";
modelPackage = "model";
modelDocTemplateFiles.put("model_doc.mustache", ".md");
Expand Down Expand Up @@ -765,7 +767,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
@Override
public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> allSchemas) {
CodegenModel codegenModel = super.fromModel(name, schema, allSchemas);

boolean hasEnums = getBooleanValue(codegenModel, HAS_ENUMS_EXT_NAME);
if (allSchemas != null && codegenModel != null && codegenModel.parent != null && hasEnums) {
final Schema parentModel = allSchemas.get(codegenModel.parentSchema);
Expand All @@ -789,7 +791,7 @@ public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> al
codegenModel.vendorExtensions.put("x-isPrimitive", true);
}
}
}
}
return codegenModel;
}

Expand All @@ -816,7 +818,7 @@ private String getModelledType(String dataType) {

@Override
public String getDefaultTemplateDir() {
return "JavaScript";
return "javascript";
}

private String getJSDocType(CodegenModel cm, CodegenProperty cp) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/handlebars/javascript/.babelrc.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
["babel-plugin-transform-builtin-extend", {
globals: ["Error", "Array"]
}]
],
"presets": ["env", "stage-0"]
}