简体   繁体   中英

How to generate inner java classes with json schema?

Is it possible to generate inner java classes using json schema? The plugin I am using for generating my pojos is jsonschema2pojo( http://www.jsonschema2pojo.org/ )

If yes, how?

Currently I couldn't find any information/examples regarding this on web, neither on http://json-schema.org/ or on http://www.jsonschema2pojo.org/

No. I have experimented with this trying to achieve the same and have concluded that jsonschema2Pojo doesn't support it.

Neither

{
...
   "foo": {
      "$ref" : "#/definitions/Bar.Foo"
   }
...
"definitions" : {
   "Bar.Foo": {
      "type": object,
      ...
   }
}

or

{
...
   "foo": {
      "$ref" : "#/definitions/Foo"
   }
...
"definitions" : {
   "Foo": {
      "type": object,
      "javaType": "org.example.Bar.Foo"
      ...
   }
}

works.

I'd recommend posting this issue to their jira, last time I checked they were quite responsive.

You might also want to consider other limitations of jsonschema2Pojo and think about whether the tool makes sense at all.

On the project I have been working on it is becoming more more clear that we might have been better off not using the tool at all, because people have been inventing all kinds of exotic workarounds to compensate for shortcomings of the tool (like being able to specify a base class for a generated class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM