Description
Using the EVE Online ESI Swagger definition, the generated csharp client code is generated without error by the code gen however it cannot be compiled. Observing the output, the generator correctly created an enum but then proceeded to try assigning strings to it which is invalid.
The problem can be seen here where Color is defined as ColorEnum
/// <summary>
/// Hexadecimal string representing label color, in RGB format
/// </summary>
/// <value>Hexadecimal string representing label color, in RGB format </value>
[DataMember(Name="color", EmitDefaultValue=false)]
public ColorEnum? Color { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="PostCharactersCharacterIdMailLabelsLabel" /> class.
/// </summary>
/// <param name="Color">Hexadecimal string representing label color, in RGB format (default to "#ffffff").</param>
/// <param name="Name">name string (required).</param>
public PostCharactersCharacterIdMailLabelsLabel(ColorEnum? Color = null, string Name = null)
{
// to ensure "Name" is required (not null)
if (Name == null)
{
throw new InvalidDataException("Name is a required property for PostCharactersCharacterIdMailLabelsLabel and cannot be null");
}
else
{
this.Name = Name;
}
// use default value if no "Color" provided
if (Color == null)
{
this.Color = "#ffffff";
}
else
{
this.Color = Color;
}
}
but at the end, it attempts to set the class level Color definition to a string "default"
The generated ColorEnum appears like this:
/// <summary>
/// Hexadecimal string representing label color, in RGB format
/// </summary>
/// <value>Hexadecimal string representing label color, in RGB format </value>
[JsonConverter(typeof(StringEnumConverter))]
public enum ColorEnum
{
/// <summary>
/// Enum Ffffff for "#ffffff"
/// </summary>
[EnumMember(Value = "#ffffff")]
Ffffff,
/// <summary>
/// Enum Ffff01 for "#ffff01"
/// </summary>
[EnumMember(Value = "#ffff01")]
Ffff01,
/// <summary>
/// Enum Ff6600 for "#ff6600"
/// </summary>
[EnumMember(Value = "#ff6600")]
Ff6600,
}
(Enum shortened for sanity)
Swagger-codegen version
2.2.1
Swagger declaration file content or url
The link to the swagger file is here
https://esi.tech.ccp.is/latest/#
Command line used for generation
java -jar swagger-codegen-cli-2.2.1.jar generate ^
-i esi.json ^
-c esi-codegen.json ^
-l csharp ^
-o ./esi-lib
esi-codegen.json
{
"packageName": "ESI",
"packageGuid": "1b95dd80-dd8a-4e94-80db-2db990e00824"
}
Steps to reproduce
Generate code using above command line, attempt compile in visual studio
Description
Using the EVE Online ESI Swagger definition, the generated csharp client code is generated without error by the code gen however it cannot be compiled. Observing the output, the generator correctly created an enum but then proceeded to try assigning strings to it which is invalid.
The problem can be seen here where Color is defined as ColorEnum
but at the end, it attempts to set the class level Color definition to a string "default"
The generated ColorEnum appears like this:
(Enum shortened for sanity)
Swagger-codegen version
2.2.1
Swagger declaration file content or url
The link to the swagger file is here
https://esi.tech.ccp.is/latest/#
Command line used for generation
java -jar swagger-codegen-cli-2.2.1.jar generate ^
-i esi.json ^
-c esi-codegen.json ^
-l csharp ^
-o ./esi-lib
esi-codegen.json
{
"packageName": "ESI",
"packageGuid": "1b95dd80-dd8a-4e94-80db-2db990e00824"
}
Steps to reproduce
Generate code using above command line, attempt compile in visual studio