swagger-api / swagger-api/swagger-codegen

[CSHARP] Duplicate constructor parameters in generated models from Swagger JSON

Open
#12,538 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:
When generating C# models from the following Swagger JSON:
🔗 https://www.zsrnext.ch/ApiGateway/swagger/1/swagger.json
some generated classes contain constructors with duplicate parameters, resulting in invalid and non-compilable code.

Example:
The following constructor was generated for the class SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractBank:

public SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractBank( SasisRegisterCareProviderCommonModelsApiGatewayV1BankGroup bankGroup = default(SasisRegisterCareProviderCommonModelsApiGatewayV1BankGroup), SasisRegisterCareProviderCommonModelsApiGatewayV1Translation bankGroupTranslations = default(SasisRegisterCareProviderCommonModelsApiGatewayV1Translation), SasisRegisterCareProviderCommonModelsApiGatewayV1BankIidType bankIidType = default(SasisRegisterCareProviderCommonModelsApiGatewayV1BankIidType), SasisRegisterCareProviderCommonModelsApiGatewayV1Translation bankIidTypeTranslations = default(SasisRegisterCareProviderCommonModelsApiGatewayV1Translation), int? iid = default(int?), int? newIid = default(int?), string branchId = default(string), string sicIid = default(string), int? headquarterIid = default(int?), string shortName = default(string), string name = default(string), string postalAccountNumber = default(string), string bic = default(string), SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractContact contact = default(SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractContact), SasisRegisterCareProviderCommonModelsApiGatewayV1BankGroup bankGroup = default(SasisRegisterCareProviderCommonModelsApiGatewayV1BankGroup), // duplicate SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractContact contact = default(SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractContact), // duplicate long? id = default(long?) )
As you can see, both bankGroup and contact are included twice!

Code generated with https://app.swaggerhub.com/
Codgen -> ClientSDK -> 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 with the linked Swagger JSON and the generated SasisRegisterCareProviderCommonModelsApiGatewayV1ResponsesContractBank constructor. Trace how the schema produces its constructor parameters, then verify the generated C# compiles with bankGroup and contact included only once; the issue provides no repository file or test entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
tooling
Issue type
Bug
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.