swagger-api / swagger-api/swagger-codegen

[Javascript] Circular dependency import error

Open
#9,563 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The model generated from a class with circular dependency comes with an
import from self, generating the error "has already declared".

Swagger-codegen version

swagger-codegen-cli-2.4.0

Command line used for generation

`java -Dapis -Dmodels -DmodelDocs=false -DmodelTests=false -DapiTests=false -DapiDocs=false -jar {jarPath} generate -l javascript -c ${config} -o {folderPath} -i {url}

config : {
"sourceFolder": ".",
"useES6": true,
"usePromises": true,
"emitModelMethods": true
}

Steps to reproduce

1 - Run the command line
2 - Import any class with circular dependency model

Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/7543
https://github.com/swagger-api/swagger-codegen/pull/6069
https://github.com/swagger-api/swagger-codegen/pull/6069

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied swagger-codegen command with a model containing a circular dependency and inspect the generated JavaScript imports. Read related issue 7543 and pull request 6069 for prior context; done means generation no longer produces a self-import or the reported “has already declared” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.