swagger-api / swagger-api/swagger-codegen
[Typescript-Angular2] Array items exported as extending "models.Array"
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If I define a model definition as just an array, then the created model ts file says "extends models.Array" instead of just "extends Array"
Swagger-codegen version 2.2.1
Swagger declaration file content or url
swagger: "2.0"
host: localhost
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/test:
get:
tags:
- test
operationId: test
description: test
responses:
"200":
description: Success
schema:
$ref: "#/definitions/TestArray"
definitions:
TestArray:
type: array
items:
$ref: "#/definitions/TestItem"
TestItem:
properties:
val:
type: string
The invalid generated model for TestArray is then:
export interface TestArray extends models.Array<models.TestItem> {
}
whereas it should just be as follows (without "models."):
export interface TestArray extends Array<models.TestItem> {
}
Command line used for generation
java -jar swagger-codegen-cli-2.2.1.jar generate -i ./swagger.yaml -l typescript-angular2 --additional-properties modelPropertyNaming=original
Suggest a Fix
For the time-being, I have my codegen run within a script that uses sed to replace the values after generation:
sed -i '' 's/extends models\.Array/extends Array/g' *
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
Start with the provided swagger.yaml definition and run the listed swagger-codegen-cli command using the typescript-angular2 generator. Inspect the generated TestArray model and the generator templates or entry points that produce its extends clause; done means array models extend Array without the models. prefix while item models remain correctly qualified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100