Reputation: 718
I have some json schema that I try to convert to pojo classes using jsonschema2pojo.
Unfortunately, I get some duplicated classes generated with an additional __1
postfix on the classname.
You can test this at https://www.jsonschema2pojo.org/.
Add this example and hit Preview
:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"something": {
"type": "object",
"properties": {}
},
"other": {
"type": "object",
"properties": {
"physical": {
"$ref": "#/properties/something"
}
}
}
}
}
I get the classes Something
and Something__1
. They have the same code (except the class name).
I found other questions, where someone commented that one can change some ObjectRule
and RuleFactory
, but I don't want to patch the library.
Is there something with my schema or is this a bug?
Upvotes: 1
Views: 1687
Reputation: 55
jung,
The below code might be working for you, I am facing the same issue for a week and walked through the lots of docs and references available.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"other": {
"type": "object",
"properties": {
"physical": {
"existingJavaType":"com.example.Something" // package name with class name
}
}
},
"something": {
"type": "object"
}
}
}
Upvotes: 0