I have RAML schema which contains "javaType": "java.util.Map<String, java.util.List<Employee>>"
I have separate schema (employee.schema) available which represent class Employee.
But as I have not used employee.schema in RAML so it is not generating class Employee and throws an Error while converting RAML to Java.
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"description": "Desc",
"properties": {
"employeeGroups": {
"type": "object",
"javaType": "java.util.Map<String, java.util.List<Employee>>"
}
},
"additionalProperties": false
}
Can anybody share comments how to represent "javaType": "java.util.Map<String, java.util.List<Employee>>" in RAML ?
RAML Version: 1.0
You have 2 options here.
The first one is to just include the external file with the schema in the
typesdefinition of yourramlfile.For instance, assuming that:
EmployeeGroupsContainer,Employeeschema is calledemployee.schemaand is in the same directory as theramlfile.The
typessection would look like this:This would be the recomended approach and the one I would use.
A second option would be to previously generate the
Employeeobject, and once you have it you can generate the rest because theEmployeeclass would now be in your classpath. The best way to do this is by two separate executions of the tool you use to generate the code (the first one withemployee.schemato generate theEmployeeclass, and the second one with the rest).May be you are tempted to generate
Employeeonce and move it tosrc/main/java, but I would recommend against this, as keeping generated code versioned (in git or any other VCS) is always a bad practice. Code generation should always be a part of the overall build process (tipically with a maven plugin, if you use maven).The only scenario I can think of to choose the second approach instead of the first one is that you don't have access to the main
ramlfile. But if you do have it, I would definitely go for the first approach.