swagger-api / swagger-api/swagger-codegen
invalid enum generation on javascript-closure-angular-client and typescript-angular-client
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Using swagger editor 2.9.9 when I generate a closure angular or typescript angular enums are not properly defined when spaces appear in the string. They are normalized in the javascript client.
schema:
{
"swagger" : "2.0",
"info" : {
"description" : "Enum",
"version" : "1.0.0",
"title" : "Enum"
},
"host" : "localhost",
"basePath" : "/api",
"schemes" : [ "http" ],
"consumes" : [ "application/json" ],
"produces" : [ "application/json" ],
"paths" : {
"/example" : {
"post" : {
"summary" : "Example",
"parameters" : [ {
"in" : "body",
"name" : "body",
"required" : true,
"schema" : {
"$ref" : "#/definitions/body"
}
} ],
"responses" : {
"200" : {
"description" : "success"
}
}
}
}
},
"definitions" : {
"body" : {
"type" : "object",
"properties" : {
"someProperty" : {
"type" : "string",
"enum" : [ "1", "Good", "With Spaces" ]
}
}
}
}
}
JAVASCRIPT CLIENT
exports.SomePropertyEnum = {
/**
* value: 1
* @const
*/
_1: "1",
/**
* value: Good
* @const
*/
GOOD: "Good",
/**
* value: With Spaces
* @const
*/
WITH_SPACES: "With Spaces"
};
JAVASCRIPT CLOSURE ANGULAR CLIENT
API.Client.Body.SomePropertyEnum = {
1: '1',
Good: 'Good',
With Spaces: 'With Spaces',
}
TYPESCRIPT ANGULAR CLIENT
export enum SomePropertyEnum {
1 = <any> '1',
Good = <any> 'Good',
With Spaces = <any> 'With Spaces'
}
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 supplied Swagger schema and compare the generated JavaScript Closure Angular and TypeScript Angular enum outputs with the normalized JavaScript client output. Inspect the templates or generator entry points responsible for these two clients, then verify that values containing spaces and values beginning with digits produce valid enum identifiers while preserving their original string values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 40/100