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

Use DateOnly in C# generator for date type #189

Closed
gkocak-scottlogic opened this issue Mar 28, 2023 · 1 comment
Closed

Use DateOnly in C# generator for date type #189

gkocak-scottlogic opened this issue Mar 28, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@gkocak-scottlogic
Copy link
Contributor

gkocak-scottlogic commented Mar 28, 2023

In #185, it is established that swagger distinguishes date and date-time types. The necessary changes to address this has been made in the main repo (see #187).

To reflect these changes, C# tests are also altered in ScottLogic/openapi-forge-csharp#50. However, these changes are applied on a surface level where both date and date-time strings are still represented by DateTime type in C#. In the mentioned PR, the tests conditionally convert the testing property into DateOnly on runtime in an ad-hoc way.

For context, C# introduced DateOnly type [1] in dotnet6. However, they haven't introduced the serialisation/deserialisation for this type until dotnet7 [2]. Since the test project is on dotnet6 (which is a LTS release), it is not possible to use the DateOnly type on generated code.

To address the mentioned problem, one option is to write custom ser/deser methods which can be undesirable for generated code structures. A more viable second option to bring the project to dotnet >=7 at a later stage to eliminate this limitation. The testing of date/datetime can be streamlined from that point onwards.

@ColinEberhardt ColinEberhardt added enhancement New feature or request CSharp labels Mar 29, 2023
@ColinEberhardt
Copy link
Collaborator

Migrated to ScottLogic/openapi-forge-csharp#51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants