-
Notifications
You must be signed in to change notification settings - Fork 105
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
OpenAPI Generator - entities are generating duplicated mapping keys #2172
Comments
I'll look into it. |
Not sure if still required, but maybe it helps to find the actual problem: @bboersig and I came also across this bug. The problem is that "entity.properties"... When digging deeper, we saw that org.eclipse.vorto.plugin.utils.Utils.getReferencedEntities... https://github.com/eclipse/vorto/blob/2657685397bcf9a0f361843d8508fffcead3eef2/generators/generator-openapi/src/main/java/org/eclipse/vorto/codegen/openapi/Utils.xtend#L45 As far as I remember, the only difference between these duplicates is that the presence field is set only for one duplicate and the constraint rule field only for the other one. As we were doing only some prototyping, we applied a hotfix by simply filtering the properties collection (generator code level) --> "entities.properties.filter[presence !== null]". |
Thanks for the hint and thanks @philbuettner for providing the models. I need to ask a beginner question since I'm new to the topic: I tried to reproduce this but the only way I was able to was by creating an entity with two properties having the same ID. Is this the problem which is described here? In the example information models I cannot see this. |
I don't know why, but I can't reproduce this behaviour anymore with the official current Vorto release. |
This error occured with a unique property id. |
Hello @mschoeffler , |
Hi, the bug occurs with any model configuration, including unique properties. I just tried it out with a very basic infomodel --> vorto.private.mschoeffler.temp_Test_1.0.0.zip In order to reproduce the bug, I go to information model and start the Open API Generator from there. The generated file has a duplicate of 'temperature':
I did my test on the current code basis --> 19.01.20, commit 86de67a My guess is that the bug occurs while parsing/importing the Vorto model. I did only a very brief debugging: getFlatStatusProperties seems to add a duplicate to the entity (line 212). Not something that I would have expected from a "get method". |
Hello @mschoeffler , |
Hello @mschoeffler , |
PR here |
Added another commit. The contraint rules were omitted previously. |
…-vorto#2172 Signed-off-by: Tobias Gauss <[email protected]>
…pingKeys Prevent properties from being added multiple times. Fixes #2172
…to#2172 Signed-off-by: Tobias Gauss <[email protected]>
…-vorto#2172 Signed-off-by: Tobias Gauss <[email protected]>
When generating OpenAPI documents, in some documents the following error appears:
Parser error - duplicated mapping key
This error only appears in connection with an entity object inside of a .type model. Because the OpenAPI Generator Template function, which parses entities did not changed from current release (0.12.4) to development branch, the cause of that error must be somewhere else (in 0.12.4 this error does not appear).
This function:
https://github.com/eclipse/vorto/blob/2657685397bcf9a0f361843d8508fffcead3eef2/generators/generator-openapi/src/main/java/org/eclipse/vorto/codegen/openapi/templates/OpenAPITemplate.xtend#L615
generates this error in the development branch:
The following OpenAPI documents are containing the duplicated keys. If you compare them with each other, there are also slightly different in the block order. Documents which are generated correctly, always have the same order. But I am not sure if this was by coincident.
OpenAPIgeneratedWithDuplicatedKeys.zip
The text was updated successfully, but these errors were encountered: