-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] AsyncAPI generator for Java doesn't generate class correctly when there's reference to itself #1885
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. |
Hey @xespirit, which version are you using? I am pretty sure this is an old bug from Modelina v2 |
In v3 I get the following (https://modelina.org/playground?language=java):
|
I use 4.0.0-next.16 version of modelina:
|
Ehh. Let me take a look with |
@xespirit even with next when I use the following AsyncAPI document it works fine (https://65f02a20166dac9eadcc846e--modelina.netlify.app/playground?language=java):
Might have something to do with your |
Yes, it has something to do with $ref pointing to itself. There's no any complex setup. I have tried Modelina generator with different json schemas, with different complexity. Everything works well except for case I mentioned above. Is there any default behaviour of generator so It gneerates Map<String, Object> witjhout even including Java import for Map. My guess it happens when the generator gets confused so it somehow generates the map instead of correct object type. |
Damn, yea thats a bug!
We need to add the dependency import like we do for Python here:
Do you mind helping to fix this? |
I'm sorry but I'm Java/Kotlin Back-end developer, I don't think I have capacity right now to fix Typescript codebase |
No worries, created a good first issue for it: #1892
Regarding this problem, I simply cant reproduce your problem, unfortunately... Cause the example you gave generates the correct models. Can you reproduce it yourself on the playground and post the example? https://65f02a20166dac9eadcc846e--modelina.netlify.app/playground?language=java |
Hey @jonaslagoni I would love to work on it. However, Same stands for me as well; I am also unable to generate this problem in playground, I am still wondering why that If the Change is this only, then why only this specific case isn't importing map. It's weird. {
"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": "#/components/schemas/CaseSchema"
}
}
}
}
}
}
} |
It's for every case, where there is a dictionary model 🙂 |
I'm providing full sets of files to reproduce the issue: Case.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
|
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. |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Describe the bug.
Modelina Async generator fails to generate Java class correctly in certain scenario: there's self-refence. Example:
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?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
No, someone else can work on it
The text was updated successfully, but these errors were encountered: