swagger-api / swagger-api/swagger-codegen

[CSharp] Codegen method return type nullable

Open
#10,159 0 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

Hi,

it is pretty annoying to make every member [required] but ok.
How to define that return type is not nullable?
Im using Swashbuckle 5.6.0

bool HasUser(string Username) //server side
bool? HasUser(string Username) // client side

What i need is something like
[required]bool HasUser(string Username) // server

I try to inject some required and x-nullable just if it work but it not.

"responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "boolean",
              "x-type-dotnet": "System.Boolean",
              "x-nullable": false,
              "required": true
            },
            "x-null": false,
            "required": true,
            "x-type-dotnet": "System.Boolean",
            "x-nullable": false
          }
        }

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 by reproducing the generated C# client from the Swashbuckle 5.6.0 schema shown in the issue and inspect how the response schema's nullable metadata is interpreted. Done means the generated HasUser method returns bool rather than bool? without requiring unsupported schema changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.