swagger-codegen
swagger-codegen copied to clipboard
Enum support for csharp-dotnet2
Description
The language csharp-dotnet2
does not generate valid enum definitions. Enum support was implemented for csharp
, but still doesn't exist for csharp-dotnet2
.
Swagger-codegen version
2.4.0
Swagger declaration file content or url
"Portion": {
"enum": [
"T",
"F",
"R",
"M"
],
"type": "string"
}
And the resulting type is
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Model {
/// <summary>
///
/// </summary>
[DataContract]
public class Portion {
/// <summary>
/// Get the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString() {
var sb = new StringBuilder();
sb.Append("class Portion {\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson() {
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
}
}
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i swagger.json -o gen -l csharp-dotnet2
Related issues/PRs
Suggest a fix/enhancement
Could probably re-use same mustache template (e.g. modelEnum
) as for csharp
Hey, I've just got hit by this issue using generator.swagger.io. Are there any plans to fix that? Most of real world APIs include enums in their definitions so it's a real problem.
I am finding this issue this week, my clients are not generating enums. If I take the same YAML file and use csharp generator it generates the valid enum.