swagger-api/swagger-codegen
在 GitHub 查看invalid enum generation on javascript-closure-angular-client and typescript-angular-client
Open
#2,739 建立於 2016年4月29日
Client: JavaScript/Node.jsClient: TypeScriptFeature: EnumIssue: Bughelp wanted
描述
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'
}