Closed TonyValenti closed 3 years ago
Known issue. Thanks for reporting.
The challenge is: C# enums are actually integers instead of strings. This article is helpful: https://www.bytefish.de/blog/enums_json_net.html
The idea is pretty good, but impractical. Example:
public class MethodInfo
{
/// <summary>
/// Method identifier. The default value is 1 (Ground)
/// </summary>
public Id id { get; set; }
public enum Id
{
1,
2,
3
}
/// <summary>
/// Method name, corresponding to the identifier
/// </summary>
public Name name { get; set; }
public enum Name
{
Ground,
2 Day,
Overnight
}
}
There are enum values which cannot be used as C# variable names: 1
, 2
, 3
& 2 Day
.
We need to manually rename them and do mapping to the original json string.
Since all of the definitions classes are auto generated based on swagger spec, we prefer an automatic way to resolve the naming issue(otherwise, the code will break if spec changes). Unfortunately, there is no such a way.
I will close this issue for now since we won't implement it.
Hi @tylerlong - Can you please update the SDK so that enum values are listed as actual enums instead of strings?
For example:
This will allow us to code more efficiently and in a less brittle way.