swagger-api / swagger-api/swagger-codegen
[JavaScript] Invalid definition classes
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Entities specified as swagger definitions are imported with Definitions prefix,
Swagger-codegen version
Docker image with swagger-codegen-cli 2.4.2
Swagger declaration file content or url
For example, given the next declaration:
{
...
"definitions": {
"Company": {
"type": "object",
"properties": {
"uid": {
"type": "string"
},
"name": {
"type": "string"
},
"companySize": {
"$ref": "#definitions/CompanySize"
}
},
"CompanySize": {
"type": "string",
"enum": [
"small",
"medium",
"large"
]
},
next files are generated: model/Company.js and model/CompanySize.js but the problem is the model/Company.js has de code:
import DefinitionsCompanySize from './DefinitionsCompanySize';
which should be
import CompanySize from './CompanySize';
Command line used for generation
docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/swagger.json -l javascript -o /local/api-sdk --additional-properties usePromises=true,useES6=true
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generated model files with the reported Docker command and declaration, then inspect the JavaScript generator templates that produce imports for model/Company.js and model/CompanySize.js. The work is done when Company.js imports CompanySize from './CompanySize' rather than DefinitionsCompanySize from './DefinitionsCompanySize'.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100