OpenAPITools / OpenAPITools/openapi-generator

CSharpNetCoreClientCodegen generate nullable TimeSpan

Open
#4,951 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Hi guys. Is there possibility generate nullable TimeSpan from scheme. I have --type-mappings arg in command line. It it map type correctly but nullable description is not involved.

Thank you for your help!

openapi-generator version

4.22

OpenAPI declaration file content or url
 "startTime": {
            "type": "string",
            "format": "date-span"
          },
          "endTime": {
            "type": "string",
            "format": "date-span",
            "nullable": true
          }, ....
Command line used for generation

openapi-generator generate -g csharp-netcore -i http://localhost:22525/swagger/v1/swagger.json -o RestApiClients -c v1-config.json -DapiTests=false -DapiDocs=false -DmodelTests=false -DmodelDocs=false --type-mappings date-span=TimeSpan --package-name Rest.V1

Steps to reproduce
Related issues/PRs
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

Reproduce the issue with the csharp-netcore generator, the supplied OpenAPI schema, and the shown --type-mappings command. Start by tracing how the generator handles the date-span format and nullable property, then verify that the generated model represents the nullable field as TimeSpan and that the non-nullable field remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
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.