swagger-api / swagger-api/swagger-codegen

Constructor without parameters in generated C# api classes

Open
#8,622 0 comments 2 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

I'm using swagger generated C# api classes to access some api and I discovered that all of it has not constructor without params, but there is constructor with single optional Configuration parameter. Is there some reason for it? May be it makes sense to add it to template? So that feature will make generated api classes corresponding new() generic type constraint (that exactly my case).

Swagger-codegen version

2.3.1

Suggest a fix/enhancement

Add constructor without parameters in api.mustache C# template, behavior will be same with constructor with single optional Configuration parameter where it equals to null.

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 C# api.mustache template and inspect the existing constructor that accepts an optional Configuration parameter. Update the template so generated API classes also support construction without parameters, with behavior equivalent to a null Configuration; verify the generated classes satisfy the new() constraint.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.