From e924cec595ba76bbf6443bc285160f0c8b7ced8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20M=C3=A6tzke=20Tandrup?= Date: Sat, 25 Jul 2015 07:45:08 +0200 Subject: [PATCH] Conditional copy properties from parent. Pull request #946 broke the TypeScript generation with inheritance where a superclass defined an enum. This makes it up to each language to decide the behavior appropriate for the language. --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 3 ++- .../swagger/codegen/languages/TypeScriptNodeClientCodegen.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index bc4f08d7f55..fe260cd56c0 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -80,6 +80,7 @@ public class DefaultCodegen { protected List supportingFiles = new ArrayList(); protected List cliOptions = new ArrayList(); protected boolean skipOverwrite; + protected boolean copyPropertiesFromParents = true; public List cliOptions() { return cliOptions; @@ -533,7 +534,7 @@ public class DefaultCodegen { final String parentRef = toModelName(parent.getSimpleRef()); m.parent = parentRef; addImport(m, parentRef); - if (allDefinitions != null) { + if (copyPropertiesFromParents && allDefinitions != null) { final Model parentModel = allDefinitions.get(parentRef); if (parentModel instanceof ModelImpl) { final ModelImpl _parent = (ModelImpl) parentModel; diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java index 0ea33f21709..ee559878330 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptNodeClientCodegen.java @@ -30,6 +30,7 @@ public class TypeScriptNodeClientCodegen extends DefaultCodegen implements Codeg public TypeScriptNodeClientCodegen() { super(); + copyPropertiesFromParents = false; outputFolder = "generated-code/typescript-node"; modelTemplateFiles.put("model.mustache", ".ts"); apiTemplateFiles.put("api.mustache", ".ts");