openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ][C#] use System.text.json as serializer (csharp-netcore)

Open StephenOTT opened this issue 4 years ago • 19 comments

Is your feature request related to a problem? Please describe.

Possible to replace the json.net newtonsoft dependency with System.text.json

StephenOTT avatar May 16 '21 16:05 StephenOTT

Is there already anyone working on this topic?

muellnes avatar Aug 31 '21 12:08 muellnes

+1

marc-wilson avatar Apr 21 '22 19:04 marc-wilson

+1

ghost avatar Jul 25 '22 09:07 ghost

+1 - is this repo dying? I see no responses from anyone. We need this too

digitaldias avatar Jan 10 '23 06:01 digitaldias

Also hoping to see this soon

apkrieg avatar Jul 20 '23 20:07 apkrieg

I am out of C# code base and now in Kotlin using KMM (https://kotlinlang.org) with some Swift So sorry I can not assist anymore

muellnes avatar Jul 21 '23 07:07 muellnes

I have made a fork of the csharp generator with System.Text.Json. It can be found here:

https://github.com/rasmusrim/openapi-generator-csharp-system-text-json

Clone it, and then run your openapi-generator-cli command as normal, but add a -t with the path to the cloned directory. I would do something like this:

npx @openapitools/openapi-generator-cli generate -i http://localhost:5166/swagger/v1/swagger.json -g csharp -o Api.ClientSdk --library httpclient --additional-properties=packageName=Flyttavle.Plugins.PortFlowPlugin,nullableReferenceTypes=true,useDateTimeOffset=true -t ~/source/repos/openapi-generator-csharp-system-text-json

It is only tested on one of my codebases. Please raise an issue and submit a swagger file if you find some problems.

rasmusrim avatar Nov 09 '23 13:11 rasmusrim

+1

Waiting for this as well

marcselman avatar Dec 08 '23 13:12 marcselman

@marcselman

Check out this repo: https://github.com/rasmusrim/openapi-generator-csharp-system-text-json

rasmusrim avatar Dec 08 '23 14:12 rasmusrim

This should be imported.

nariya avatar Sep 04 '24 06:09 nariya

+1 NewtonSoft is really out-dated for years and has undocumented trouble with properties named "status" or "value" of type object !!

monstalein avatar Jan 17 '25 19:01 monstalein

+1 for making it a included generator 👍

angelaki avatar Feb 18 '25 08:02 angelaki

+1

owebb98 avatar Feb 21 '25 14:02 owebb98

+1 for supporting it in the official generator, instead of using https://github.com/rasmusrim/openapi-generator-csharp-system-text-json

thangchung avatar Feb 26 '25 08:02 thangchung

fwiw i've done a ton of mods to rasmusrim's version here: https://github.com/bc3tech/openapi-generator-csharp-system-text-json/tree/mods

bc3tech avatar Feb 26 '25 20:02 bc3tech

please file a PR to start with and then we will try to incorporate that into openapi generator

wing328 avatar Feb 27 '25 08:02 wing328

It looks like v7.12.0 could fix this? Newtonsoft.Json has been replaced by System.Text.Json internally.

owebb98 avatar Mar 03 '25 11:03 owebb98

+1

for using System.Text.Json!

stor661 avatar Sep 01 '25 12:09 stor661

+1

binn avatar Nov 22 '25 15:11 binn