swagger-api / swagger-api/swagger-codegen

[csharp] Generate a List<Guid> Model property instead of List<Guid?>

Open
#9,677 0 comments 0 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 following model generates a class with a UUIDs property, but the type of the property is List<Guid?>. How can I generate a List<Guid>?

Swagger-codegen version

2.2.3

Swagger declaration file content or url
  SearchModel:
    type: object
    description: A request model.
    required: [uuids]
    properties:
      uuids:
        type: array
        items:
          type: string
          format: uuid
          description: The unique identifier.
Command line used for generation
  java -Dapis -Dmodels -DsupportingFiles -DapiTests=false -DmodelDocs=true -DmodelTests=false 2>>%4 -jar %5\swagger-codegen-cli-2.2.3.jar generate -i "%%f" -l csharp -o %2 --config %3 -t %5\templates
Output

The above yaml generates a Model with the following UUIDs property.

/// <summary>
/// Gets or Sets Uuids
/// </summary>
[DataMember(Name="uuids", EmitDefaultValue=false)]
public List<Guid?> Uuids { get; set; }

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

Reproduce the generated C# model from the supplied Swagger YAML and command, then trace the C# model generation entry point and its type-mapping or template handling for required UUID arrays. Done means the generated Uuids property is List rather than List<Guid?> while preserving the declared required-array behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.