modelina: [BUG] AsyncAPI generator for Java doesn't generate class correctly when there's reference to itself
Describe the bug.
Modelina Async generator fails to generate Java class correctly in certain scenario: there’s self-refence. Example:
{
"asyncapi": "2.6.0",
"info": {
"title": "Case",
"version": "1.0.0",
"description": "AsyncAPI schema definition for Case"
},
"channels": {},
"components": {
"schemas": {
"CaseSchema": {
"$id": "CaseSchema",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"label": {
"type": "string"
},
"exceptForCase": {
"type": "array",
"items": {
"type": "object",
"$ref": "./Case.json#/components/schemas/CaseSchema"
}
}
}
}
}
}
}
Expected behavior
Generated Java class should have
private List<CaseSchema> exceptForCase;
instead it generates array of Map<String, Object>:
private List<Map<String, Object>> exceptForCase;
Screenshots
Example:
Generated class:
How to Reproduce
See screeshots above
🥦 Browser
None
👀 Have you checked for similar open issues?
- I checked and didn’t find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
No, someone else can work on it
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (10 by maintainers)
Just pinging that I have not forgotten about this, but have to work on some other fixes that I think will fix this along side it.
I’m providing full sets of files to reproduce the issue:
Case.json DirectPolicy.json Insurance.json Policy.json Schemas.json
The generator is being called from Maven plug-in:
I’ve attached pictures of generated files, representing the issue below:
@jonaslagoni could you try to reproduce the bug?
As you can see Modelina generator thinks all files are generated successfuly (without exiting with error). But in fact we have:
and exceptForCase shouldn’t be a list of Map<String, Object>. Expected result is a
private List<CaseSchema> exceptForCase;