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 #51

Open
ColinEberhardt opened this issue Mar 29, 2023 · 0 comments
Open

Use DateOnly in C# generator for date type #51

ColinEberhardt opened this issue Mar 29, 2023 · 0 comments

Comments

@ColinEberhardt
Copy link
Collaborator

In ScottLogic/openapi-forge#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 ScottLogic/openapi-forge#187).

To reflect these changes, C# tests are also altered in #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.

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

No branches or pull requests

1 participant