RicoSuter/NSwag
View on GitHubOpenApi-C# generation with npm-cli does not handle invalid names correctly
Open
#2811 opened on Apr 19, 2020
help wanted
Description
Environment:
NSwag NPM CLI
NSwag command line tool for .NET Core NetCore21, toolchain v13.4.2.0 (NJsonSchema v10.1.11.0 (Newtonsoft.Json v11.0.0.0))
Scenario:
If you take a look at this Specification of the Microsoft vsts-rest-api-specs you will recognize a parameter named $scope in line 63.
Calling the following on this element
nswag openapi2csclient /input: dashboard.json
/classname:Dashboard
/namespace:MyNamespace
/output:Dashboard.cs
Will generate the following enum-code:
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.11.0 (Newtonsoft.Json v11.0.0.0)")]
public enum $scope
{
[System.Runtime.Serialization.EnumMember(Value = @"collection_User")]
Collection_User = 0,
[System.Runtime.Serialization.EnumMember(Value = @"project_Team")]
Project_Team = 1,
}
The name $scope is invalid obviously in C#.
Expected:
The name of the member should be scope. nswag should take care of special characters.