swagger-api / swagger-api/swagger-codegen

[CSHARP] 3.x array schema doesnt work - always is Object

Open
#11,988 2 comments 1 reaction 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

Array types always translated to "Object", even if nested inside an actual object schema.

DefaultApi.cs, supposed to return an array of strings.

        Object GetArray ();

Test2.cs, arr is an array of strings.

        /// <summary>
        /// Gets or Sets Arr
        /// </summary>
        [DataMember(Name="arr", EmitDefaultValue=false)]
        public Object Arr { get; set; }
Swagger-codegen version

3.0.36

Swagger declaration file content or url

https://gist.github.com/ShoryuKyzan/02bfa48e1b82ca937150467644da56c3

Command line used for generation
java -jar swagger-codegen-cli-3.0.36.jar generate \
        -i swagger.json \
        -l csharp \
        -o api-gen
openjdk 19.0.1 2022-10-18                                           
OpenJDK Runtime Environment (build 19.0.1+10-21)                    
OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)  

Windows 10

Steps to reproduce

Run the above commands

Related issues/PRs

N/A

Suggest a fix/enhancement

?

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

Run the supplied swagger-codegen 3.0.36 command against the linked Swagger declaration and inspect the generated DefaultApi.cs and Test2.cs. Trace how the array schemas become Object; done means the generated method and property use an appropriate string-array type, with a regression test covering both cases.

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.