From e021a99e787784982389052ff116a372b4294d7d Mon Sep 17 00:00:00 2001 From: Yael Aharon Date: Wed, 30 Mar 2016 09:09:37 -0400 Subject: [PATCH] Revert "Fix issue #2449: SubClass annotations are missing from the base class." This reverts commit ff0cefe676ef7895476d0ed54ffcde7d1b7a50c0. --- .../main/java/io/swagger/codegen/CodegenModel.java | 3 +-- .../java/io/swagger/codegen/DefaultCodegen.java | 13 ------------- .../codegen/languages/JavaClientCodegen.java | 7 ------- .../src/main/resources/Java/pojo.mustache | 1 - .../main/resources/Java/typeInfoAnnotation.mustache | 6 ------ 5 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 modules/swagger-codegen/src/main/resources/Java/typeInfoAnnotation.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java index 1994255a5a7f..a7866e5675a5 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenModel.java @@ -11,7 +11,6 @@ public class CodegenModel { // References to parent and interface CodegenModels. Only set when code generator supports inheritance. public CodegenModel parentModel; public List interfaceModels; - public List children; public String name, classname, description, classVarName, modelJson, dataType; public String classFilename; // store the class file name, mainly used for import @@ -27,7 +26,7 @@ public class CodegenModel { public Set allMandatory; public Set imports = new TreeSet(); - public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasChildren, hasMoreChildren; + public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum; public ExternalDocs externalDocs; public Map vendorExtensions; 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 c73d8f984e20..ea16e75f1c94 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 @@ -156,19 +156,6 @@ public Map postProcessAllModels(Map objs) { } } } - // Let parent know about all its children - for (String name : allModels.keySet()) { - CodegenModel cm = allModels.get(name); - if (cm.parent == null) continue; - CodegenModel parent = allModels.get(cm.parent); - if (parent.children == null) { - parent.children = new ArrayList(); - } else { - parent.children.get(parent.children.size() - 1).hasMoreChildren = Boolean.TRUE; - } - parent.children.add(cm); - parent.hasChildren = true; - } } return objs; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 273729a5d5a3..fae47c70729d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -45,7 +45,6 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { public JavaClientCodegen() { super(); - supportsInheritance = true; outputFolder = "generated-code" + File.separator + "java"; modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); @@ -236,8 +235,6 @@ public void processOpts() { importMapping.put("ApiModelProperty", "io.swagger.annotations.ApiModelProperty"); importMapping.put("ApiModel", "io.swagger.annotations.ApiModel"); importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty"); - importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes"); - importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo"); importMapping.put("JsonValue", "com.fasterxml.jackson.annotation.JsonValue"); importMapping.put("Objects", "java.util.Objects"); importMapping.put("StringUtil", invokerPackage + ".StringUtil"); @@ -542,10 +539,6 @@ public CodegenModel fromModel(String name, Model model, Map allDe if(codegenModel.description != null) { codegenModel.imports.add("ApiModel"); } - if (codegenModel.discriminator != null) { - codegenModel.imports.add("JsonSubTypes"); - codegenModel.imports.add("JsonTypeInfo"); - } if (allDefinitions != null && codegenModel != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { final Model parentModel = allDefinitions.get(codegenModel.parentSchema); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel); diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache index aeb0614601a0..1a1f455ed31a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache @@ -1,6 +1,5 @@ {{#description}}@ApiModel(description = "{{{description}}}"){{/description}} {{>generatedAnnotation}} -{{#hasChildren}}{{>typeInfoAnnotation}}{{/hasChildren}} public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#vars}}{{#isEnum}} diff --git a/modules/swagger-codegen/src/main/resources/Java/typeInfoAnnotation.mustache b/modules/swagger-codegen/src/main/resources/Java/typeInfoAnnotation.mustache deleted file mode 100644 index dda0a10b9357..000000000000 --- a/modules/swagger-codegen/src/main/resources/Java/typeInfoAnnotation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator}}" ) -@JsonSubTypes({ - {{#children}}@JsonSubTypes.Type(value = {{name}}.class, name = "{{name}}"){{#hasMoreChildren}}, - {{/hasMoreChildren}}{{/children}} -}) -