-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Switch to System.Text.Json for (de)serialization #767
Comments
@kipusoep Thanks for taking the time to report this Which code generator are you thinking of? I have 100% control over Refitter since I wrote the tool and NSwag features the option to configure which JSON serialization library to use. I have very little control over the other code generators since I just piggyback over them |
The Open API generator. |
@kipusoep There's a similar issue on the OpenAPI Generator repo and one of the comments is about a fork that implements this. Hopefully, this becomes a pull request and ends up in the OpenAPI Generator itself. Otherwise, someone should implement this, that could be me, you, or someone else |
Here is the fork. It has worked well on several of my projects so far: https://github.com/rasmusrim/openapi-generator-csharp-system-text-json |
Is there a relatively easy way to use your fork with the VS tool? |
@kipusoep The mentioned fork looks like Mustache templates to me, and my extension supports using custom mustache templates. You can try to clone that repo to a local folder like |
@kipusoep @rasmusrim The mustache templates can be used to generate code, but the generated code doesn't build. At least not out-out-of-the-box. I guess some tweaking of the templates would help Here's the output: The immediate problems that I noticed are the following:
Mustache templates are hard to work with when starting from scratch but they are not that hard to modify, so maybe a few tweaks would make this work. Eventually this fork, once it works, should be merged into OpenAPI Generator itself |
We're using the new System.Text.Json namespace for WebApi JSON serialization (I think it's OOTB like this nowadays).
TimeSpan
objects are serialized in the format23:59:59
and Newtonsoft.Json is unable to deserialize this.It would be nice if the generated Open API code would use System.Text.Json instead.
The text was updated successfully, but these errors were encountered: