I’m trying to use both CUBA rest API and swagger-codegen. however, there is a limitation that in CUBA “com.haulmont.restapi.service.ServicesControllerManager#_invokeServiceMethod” check fixed order of input parameter which is deserialized from JSON string as below:
for (int i = 0; i < types.length; i++) {
try {
paramValues.add(restParseUtils.toObject(types[ i ], paramValuesStr.get(i), modelVersion));
} catch (Exception e) {
log.error("Error on parsing service param value", e);
throw new RestAPIException("Invalid parameter value",
"Invalid parameter value for " + paramNames.get(i),
HttpStatus.BAD_REQUEST);
}
}
Object methodResult;
try {
methodResult = serviceMethod.invoke(service, paramValues.toArray());
} catch (InvocationTargetException | IllegalAccessException ex) {
if (ex.getCause() instanceof ValidationException) {
throw (ValidationException) ex.getCause();
} else {
log.error("Error on service method invoke", ex.getCause());
throw new RestAPIException("Error on service method invoke", "", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
but according to json spec, you can not expect order of json fields. Additionaly in GSON which is used by swagger-codegen spread entity fields randomly. So code generated by swagger-codegen can not work properly (most of time can not find method exception raising).
I’d like to know the purpose of your design to know if I need to customize swagger-codegen to use Jackson for instance.
Thanks for your time.