Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kYann opened this issue Jan 30, 2023 · 1 comment · Fixed by #14616 or #14679
Closed

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

kYann opened this issue Jan 30, 2023 · 1 comment · Fixed by #14616 or #14679

Comments

@kYann
Copy link

kYann commented Jan 30, 2023

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.

@kYann
Copy link
Author

kYann commented Feb 6, 2023

Hello @devhl-labs ,

Thanks for looking into this. I saw your pull request and tested the openapi-generator-cli-6.4.0-20230206.024543-10.jar where I think your fix should be.
It is not working as there is still an issue with deserialization. The server send the format expected by the API : yyyy-MM-dd but the DateTimeJsonConverter does not handle this format.

See list of supported format by the DateTimeJsonConverter
image

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant