Skip to content

[BUG][csharp-netcore] Cannot deserialized to dateonly #14564

@kYann

Description

@kYann

Description
When a model contains a DateOnly and serialize to date (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#data-types) the generated model contains a datetime and the DateTimeJsonConverter does not handle a date format. The deserialization throw a NotSupportedException.

I would suggest to serialize also as date. But it's up to the server converter to handle datetime as date.

openapi-generator version
6.3.0-20230125.125049-89

csharp-netcore

OpenAPI declaration file content or url
https://gist.github.com/kYann/23eab426be79fd2cb93c2ddb902a8ecd

"date": {
            "type": "string",
            "format": "date",
            "example": "2017-07-21"
          }

Generation Details
`java -jar ..\openapi-generator-cli-6.3.0-20230125.125049-89.jar generate -i ..\swagger.json -c ..\config.yaml``

config

generatorName: csharp-netcore
library: generichost
additionalProperties:
artifactId: PublicClient
packageName: PublicClient
targetFramework: net6.0
useDateTimeOffset: true
nullableReferenceTypes: true
packageDescription: Public client to access rest api
packageTitle: "Api Public Client"
Steps to reproduce
Run generate command on the provided swagger file.

Suggest a fix
Handle deserialization of date to datetime or directly handle generation of dateonly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions