JSON schema using javaType from a separate module in the project

2.4k views Asked by At

How do you use a type that is declared in a separate module of the same project?

I have the following JSON schema:

"firstname" : {
  "type" : "object",
  "javaType" : "location.of.class.Name"
}

Where the type is declared in a class in my rs module:

package location.of.class;

import...

public class Name {
   //some logic
}

I want the jsonschema2pojo to generate a class that use the type Name, however I get a separate class generated called Name with exactly the same package name as my existing class.

1

There are 1 answers

0
Casper On BEST ANSWER

It was as simple as adding the relevant dependency to the module in my pom file. For example the below dependency points to an external library javax.ws.rs in the same way.

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0-m10</version>
    </dependency>

For some reason the jsonschema2pojo plugin doesn't look at the entire project but only refers to the module where you have the plugin.