[Java][Spring][Inflector][Jax-RS] To fix various enum issues (#3615)

* fix spring enum deserialization issue

* fix enum class for spring

* update java inflector to fix enum tostring

* fix jaxrs jersey1 enum toString

* fix jaxrs jersey patch issue
This commit is contained in:
wing328
2016-08-20 17:54:45 +08:00
committed by GitHub
parent 64e03422c0
commit 4e20bd9bab
187 changed files with 3960 additions and 229 deletions

View File

@@ -33,6 +33,8 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
modelPackage = "io.swagger.model";
additionalProperties.put("title", title);
// java inflector uses the jackson lib
additionalProperties.put("jackson", "true");
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
cliOptions.add(new CliOption("title", "a title describing the application"));

View File

@@ -39,6 +39,8 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "io.swagger.model");
additionalProperties.put("title", title);
// java inflector uses the jackson lib
additionalProperties.put("jackson", "true");
}
@Override

View File

@@ -4,7 +4,6 @@ import io.swagger.codegen.*;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import org.apache.commons.lang3.BooleanUtils;
import java.io.File;
import java.util.*;
@@ -42,6 +41,9 @@ public class SpringCodegen extends AbstractJavaCodegen {
additionalProperties.put(CONFIG_PACKAGE, configPackage);
additionalProperties.put(BASE_PACKAGE, basePackage);
// spring uses the jackson lib
additionalProperties.put("jackson", "true");
cliOptions.add(new CliOption(TITLE, "server title name or client service name"));
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
cliOptions.add(new CliOption(BASE_PACKAGE, "base package for generated code"));
@@ -352,17 +354,22 @@ public class SpringCodegen extends AbstractJavaCodegen {
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
if("null".equals(property.example)) {
if ("null".equals(property.example)) {
property.example = null;
}
//Add imports for Jackson
if(!BooleanUtils.toBoolean(model.isEnum)) {
if (!Boolean.TRUE.equals(model.isEnum)) {
model.imports.add("JsonProperty");
if(BooleanUtils.toBoolean(model.hasEnums)) {
if (Boolean.TRUE.equals(model.hasEnums)) {
model.imports.add("JsonValue");
}
} else { // enum class
//Needed imports for Jackson's JsonCreator
if (additionalProperties.containsKey("jackson")) {
model.imports.add("JsonCreator");
}
}
}