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
types
definition of yourraml
file.For instance, assuming that:
EmployeeGroupsContainer
,Employee
schema is calledemployee.schema
and is in the same directory as theraml
file.The
types
section 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
Employee
object, and once you have it you can generate the rest because theEmployee
class 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.schema
to generate theEmployee
class, and the second one with the rest).May be you are tempted to generate
Employee
once 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
raml
file. But if you do have it, I would definitely go for the first approach.