You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Schema $ref with same name is not producing models properly #1089
My schema definition are spread across multiple files and they are cross reference(using $ref). In these files there is one schema with same name. I have 5 such instances
When i run code generator, Only 2 models are produced. Rest are ignored. Some of the $ref are pointing to wrong model.
//We add a number at the end of the definition name
int i = 2;
for (String name : schemas.keySet()) {
if (name.equals(possiblyConflictingDefinitionName)) {
tryName = possiblyConflictingDefinitionName + "_" + i;
existingModel = schemas.get(tryName);
i++;
}
In above code, possiblyConflictingDefinitionName remains same through out the loop. If possiblyConflictingDefinitionName = "model" then the outcome of the loop is always tryName = "model_2".
I am hitting same issue.
So above code should be
//We add a number at the end of the definition name
int i = 2;
tryName = possiblyConflictingDefinitionName;
for (String name : schemas.keySet()) {
if (name.equals(tryName)) {
tryName = tryName + "_" + i;
existingModel = schemas.get(tryName);
i++;
}
Can some one help me to validate this code
Reacted by Grace Karina Gonzalez Diaz and Akihito Nakano
Activity
gracekarina commentedon May 5, 2019
@vinodchitrali In other to check the code, can you please send us a failing PR so we can add a test to parser and try this out? Thanks!
vinodchitrali commentedon May 6, 2019
@gracekarina , I dont have failing PR.
@ackintosh added test case in openapi-generator ackintosh@102c704
gracekarina commentedon May 6, 2019
Hi @vinodchitrali please bring the test case here please, so I can review.
ackintosh commentedon May 13, 2019
@vinodchitrali Thank your for your mention about the test case I added.
I'll file a PR which add the test case so that it could be reviewed.
ackintosh commentedon May 13, 2019
@gracekarina I've added the test case #1097 .
tomasz-zablocki commentedon Aug 27, 2019
Any progress on this one ?
Facing the same problem as well which basically forces a single-file-spec approach, which is quite problematic for large specs.