Skip to content
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] [Go] [Java] [Python] Duplicate models generated when there are circular references between specs #6926

Open
5 tasks done
shylasrinivas opened this issue Jul 14, 2020 · 2 comments

Comments

@shylasrinivas
Copy link
Contributor

shylasrinivas commented Jul 14, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
    Yes
  • Have you validated the input using an OpenAPI validator (example)?
    Yes. Spec is valid.
  • What's the version of OpenAPI Generator used?
    5.0.0 SNAPSHOT and 4.3.1
  • Have you search for related issues/PRs?
    Duplicate classes / Models are generated if ( $ref) referenced externally. #2701
  • What's the actual output vs expected output?
    Duplicate models with _2 suffix generated in go, 2 suffix in java. I have tested this in java and python and found the same issue.
Description

Models generated twice with same content when there are circular references between 2 specs
Issue occurs in Go, Java and Python languages.
Eg: model_complex_node_slice.go and model_complex_node_slice_2.go
ComplexNodeSlice.java and ComplexNodeSlice2.java

openapi-generator version

4.3.1 and 5.0.0 SNAPSHOT

OpenAPI declaration file content or url

https://gist.github.com/shylasrinivas/af9312c27f6c2a2d99d91c4c2c0323a1

Command line used for generation

openapi-generator generate -g go -i ~/testyamls/linked_list.yaml -o ~/testyamls/test

Related issues/PRs

#2701

Suggest a fix

Based on #2701 it seems the latest swagger parser should have fixed the issue. However, even with 5.0.0 SNAPSHOT version of openapi-generator which is using a newer swagger parser version (2.0.20) I am still seeing this issue. Any help is appreciated.

@auto-labeler
Copy link

auto-labeler bot commented Jul 14, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@shylasrinivas shylasrinivas changed the title [BUG] [Go] [Java] [Python] Duplicate models generated with $ref in yamls [BUG] [Go] [Java] [Python] Duplicate models generated when there are circular references between specs Jul 29, 2020
@yangguangxiadeyun
Copy link
Contributor

This may be the work-around for this case.
https://openapi-generator.tech/docs/usage/#type-mappings-and-import-mappings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants