swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[CSHARP] swagger-codegen-cli produces invalid constructors with AllOf

Open asthomas opened this issue 1 year ago • 0 comments

Description

The C# client API code generator produces constructors that are wrong in a few ways:

  • Members in the derived class that shadow members in the AllOf class appear twice in the constructor parameters
  • Some constructor parameters in the derived class are missing
  • The base class constructor is missing parameters
  • The call to the base class constructor uses parameters that are not in the parameter list of the derived class constructor e.g., public DerivedClass (string a, string b) : BaseClass (a, c)
Swagger-codegen version

swagger-codegen-3.0.52

Swagger declaration file content or url

Attached file is the OpenAPI definition file for YouTrack (https://www.jetbrains.com/youtrack/) config.json YouTrack.json

Command line used for generation

export JAVA_HOME="c:\Program Files\Java\jdk-18.0.1.1" java="c:/Program Files/Java/jdk-18.0.1.1/bin/java" jar="swagger-codegen-3.0.52\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar" "$java" -jar $jar generate -i YouTrack.json -o api -l csharp -c config.json

Steps to reproduce
  • Build the API using the above command
  • Open the resulting api/Cogent YouTrack.sln file in Visual Studio 2022
  • Change the target framework in the Cogent.YouTrack project to version 4.6.2
  • Build the solution
  • Look at the constructor for Article in Mode/Article.cs
    • Some arguments are duplicated
    • The "id" argument to the base() constructor is undefined
Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/11905 https://github.com/swagger-api/swagger-codegen/issues/11900

Suggest a fix/enhancement

I have no suggestions. It just appears to be broken.

asthomas avatar Mar 15 '24 12:03 asthomas