jsonschema2pojo
jsonschema2pojo copied to clipboard
Unable to use an existing json file using "ref"
Sample-
request.json
{
"title":"Request",
"description":"Request Object",
"type":"object",
"properties": {
"TestRequest": {
"description":"The response object corresponding to the token suspend request.",
"$ref": "spec.json"
}
},
"required": [
"TestRequest"
]
}
spec.json
{
"title":"Data in Request",
"description":"Contains the details of the Data elements",
"type":"object",
"properties": {
"Attribute1": {
"description":"The attribute object.",
"$ref": "another_file.json"
}
},
"required": [
"Attribute1"
]
}
The above code works and generates the pojos fine as expected.
But when I start referencing the "spec.json" from another new request2.json object, the pojo generation gets screwed up. Need help.
I kind of found a problem, the order in which the files are sequenced in the folder seems to matter. As there are multiple files referencing the spec.json, unless that object gets created first, the first one in the folder ends up winning the baton.
Hi. How does the generation get screwed up?
To explain in exact problem - in details - common_request.json common_response.json
The above common jsons are referenced in the subsequent files - deactivate_request.json deactivate_response.json
reactivate_request.json reactivate_response.json
Due to the above nomenclature the files remain in the same sequential order in the folder.The generation of pojos has "CommonRequest.java" and "CommonResponse.java" for the first and then they are used in the other classes - as a child object.
Now this is where the problem starts - The content being exactly the same - I add a new files with names as - activate_request.json activate_response.json
The name make the file as the first item on the folder. Now when we generate the pojos - the "CommonRequest.java" and "CommonResponse.java" are NO more created and instead, we see "ActivateRequest.java" and "ActivateResponse.java" which has all the content of the referenced file "common_request.json" and "common_response.json" All the other files, start referencing these new classes as child object henceforth.
This is the problem.