forked from loafle/openapi-generator-original
* [JaxRS] Fix response annotation generation (fixes #2588) * [JaxRS] Fix jaxrs jersey1 usetags sample provider * Revert "[JaxRS] Fix jaxrs jersey1 usetags sample provider" This reverts commit 73fef2e451e376b23f6c1d43d8781f0b4a0bd1f5. * [JaxRS] Fix jaxrs jersey1 sample generator * [JaxRS] Fix samples for jersey1 and jersey2 * [Server: Java] Fix diamond operator defaultValue for Java < 1.7
This commit is contained in:
@@ -639,16 +639,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return null;
|
||||
}
|
||||
|
||||
String typeDeclaration = getTypeDeclaration(ap.getItems());
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
if (java8 != null && java8) {
|
||||
typeDeclaration = "";
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(pattern, typeDeclaration);
|
||||
return String.format(pattern, getTypeDeclaration(ap.getItems()));
|
||||
} else if (p instanceof MapProperty) {
|
||||
final MapProperty ap = (MapProperty) p;
|
||||
final String pattern;
|
||||
@@ -661,16 +652,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return null;
|
||||
}
|
||||
|
||||
String typeDeclaration = String.format("String, %s", getTypeDeclaration(ap.getAdditionalProperties()));
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
if (java8 != null && java8) {
|
||||
typeDeclaration = "";
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(pattern, typeDeclaration);
|
||||
return String.format(pattern, String.format("String, %s", getTypeDeclaration(ap.getAdditionalProperties())));
|
||||
} else if (p instanceof IntegerProperty) {
|
||||
IntegerProperty dp = (IntegerProperty) p;
|
||||
if (dp.getDefault() != null) {
|
||||
|
||||
@@ -140,6 +140,15 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for ( CodegenOperation operation : ops ) {
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
Map<String, String> firstType = operation.consumes.get(0);
|
||||
if (firstType != null) {
|
||||
if ("multipart/form-data".equals(firstType.get("mediaType"))) {
|
||||
operation.isMultipart = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isMultipartPost = false;
|
||||
List<Map<String, String>> consumes = operation.consumes;
|
||||
if(consumes != null) {
|
||||
@@ -166,39 +175,32 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
resp.code = "200";
|
||||
}
|
||||
|
||||
// set vendorExtensions.x-java-is-response-void to true as dataType is set to "void"
|
||||
if (resp.dataType == null) {
|
||||
if (resp.baseType == null) {
|
||||
resp.dataType = "void";
|
||||
resp.baseType = "Void";
|
||||
// set vendorExtensions.x-java-is-response-void to true as baseType is set to "Void"
|
||||
resp.vendorExtensions.put("x-java-is-response-void", true);
|
||||
}
|
||||
|
||||
if ("array".equals(resp.containerType)) {
|
||||
resp.containerType = "List";
|
||||
} else if ("map".equals(resp.containerType)) {
|
||||
resp.containerType = "Map";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( operation.returnType == null ) {
|
||||
if ( operation.returnBaseType == null ) {
|
||||
operation.returnType = "void";
|
||||
// set vendorExtensions.x-java-is-response-void to true as returnType is set to "void"
|
||||
operation.returnBaseType = "Void";
|
||||
// set vendorExtensions.x-java-is-response-void to true as returnBaseType is set to "Void"
|
||||
operation.vendorExtensions.put("x-java-is-response-void", true);
|
||||
} else if ( operation.returnType.startsWith("List") ) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if ( end > 0 ) {
|
||||
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
} else if ( operation.returnType.startsWith("Map") ) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if ( end > 0 ) {
|
||||
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
} else if ( operation.returnType.startsWith("Set") ) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if ( end > 0 ) {
|
||||
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
|
||||
if ("array".equals(operation.returnContainer)) {
|
||||
operation.returnContainer = "List";
|
||||
} else if ("map".equals(operation.returnContainer)) {
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,54 +133,7 @@ public class JavaResteasyEapServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
Map<String, String> firstType = operation.consumes.get(0);
|
||||
if (firstType != null) {
|
||||
if ("multipart/form-data".equals(firstType.get("mediaType"))) {
|
||||
operation.isMultipart = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
for (CodegenResponse resp : responses) {
|
||||
if ("0".equals(resp.code)) {
|
||||
resp.code = "200";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
} else if (operation.returnType.startsWith("List")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Map")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Set")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
return super.postProcessOperations(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -132,54 +132,7 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.hasConsumes == Boolean.TRUE) {
|
||||
Map<String, String> firstType = operation.consumes.get(0);
|
||||
if (firstType != null) {
|
||||
if ("multipart/form-data".equals(firstType.get("mediaType"))) {
|
||||
operation.isMultipart = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<CodegenResponse> responses = operation.responses;
|
||||
if (responses != null) {
|
||||
for (CodegenResponse resp : responses) {
|
||||
if ("0".equals(resp.code)) {
|
||||
resp.code = "200";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation.returnType == null) {
|
||||
operation.returnType = "Void";
|
||||
} else if (operation.returnType.startsWith("List")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("List<".length(), end).trim();
|
||||
operation.returnContainer = "List";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Map")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Map<".length(), end).split(",")[1].trim();
|
||||
operation.returnContainer = "Map";
|
||||
}
|
||||
} else if (operation.returnType.startsWith("Set")) {
|
||||
String rt = operation.returnType;
|
||||
int end = rt.lastIndexOf(">");
|
||||
if (end > 0) {
|
||||
operation.returnType = rt.substring("Set<".length(), end).trim();
|
||||
operation.returnContainer = "Set";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
return super.postProcessOperations(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user