Description
Description
When generating with the typescript-angular2 language, an enum is generated with an integer name. The typescript compiler error is:
error TS2452: An enum member cannot have a numeric name.
I am generating this from a C# Web API that on a bad request returns a ModelStateDictionary which has a validationState
of type ModelValidationState.
The generated Typescript enum is:
export namespace ModelStateEntry {
export enum ValidationStateEnum {
0 = <any> '0',
1 = <any> '1',
2 = <any> '2',
3 = <any> '3',
}
}
Swagger-codegen version
2.2.0
Swagger declaration file content or url
The swagger definition for this from the JSON content is:
"ModelStateEntry": {
"type": "object",
"properties": {
"rawValue": {
"type": "object"
},
"attemptedValue": {
"type": "string"
},
"errors": {
"type": "array",
"items": {
"$ref": "#/definitions/ModelError"
},
"readOnly": true
},
"validationState": {
"format": "int32",
"enum": [
0,
1,
2,
3
],
"type": "integer"
},
"isContainerNode": {
"type": "boolean",
"readOnly": true
},
"children": {
"type": "array",
"items": {
"$ref": "#/definitions/ModelStateEntry"
},
"readOnly": true
}
}
}
Steps to reproduce
Run swagger-codegen generate
against a web api that returns a model result of ModelStateDictionary
(C# type)
Related issues
Using Swashbuckle configuration of DescribeAllEnumsAsStrings()
solves the issue, but we may be able to do something here also to prevent the case where this occurs.
Suggest a Fix
The typescript-angular2/model.mustache contains the declaration for the enum, but I'm not sure of the proper change to make here.