swagger-api / swagger-api/swagger-codegen

Enum support for csharp-dotnet2

Open
#9,031 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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

#2429

Suggest a fix/enhancement

Could probably re-use same mustache template (e.g. modelEnum) as for csharp

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing enum support for csharp with the csharp-dotnet2 generator and the modelEnum Mustache template mentioned in the issue. Run the provided swagger-codegen command with the sample declaration; done means csharp-dotnet2 generates Portion as a valid C# enum rather than an empty class.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.