You have 2 options here.
The first one is to just include the external file with the schema in the types
definition of your raml
file.
For instance, assuming that:
- The object represented in your example is called
EmployeeGroupsContainer
,
- And the file with the
Employee
schema is called employee.schema
and is in the same directory as the raml
file.
The types
section would look like this:
types:
EmployeeGroupsContainer:
schema: |
{
"$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
}
Employee:
schema:
!include employee.schema
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 the Employee
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 with employee.schema
to generate the Employee
class, and the second one with the rest).
May be you are tempted to generate Employee
once and move it to src/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.