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

Add support for STJ-native C# code gen #1675

Merged
merged 2 commits into from
Nov 19, 2024

Conversation

schnerring
Copy link
Contributor

@schnerring schnerring commented Feb 13, 2024

I took another crack at adding the missing System.Text.Json polymorphic serialization features to NSwag's C# client generator (previous PR: #1595).

As per your suggestion I added a C# client generator setting named JsonPolymorphicSerializationStyle that defaults to NSwag (old behavior). Setting it to SystemTextJson will opt into the new behavior:

  • Generate JsonPolymorphic and JsonDerivedType attributes
  • Don't generate JsonInheritanceConverter and JsonInheritanceAttribute classes

I also added a corresponding (WIP) PR in the NSwag repo that might be missing a couple of things: https://github.com/RicoSuter/NSwag/pull/4782/files

@brrusino
Copy link

@schnerring @RicoSuter What's the latest status of this PR?

@schnerring
Copy link
Contributor Author

@RicoSuter Anything else? It's good to go from my side.

@ryanheath
Copy link
Contributor

@schnerring Would you mind adding a setting to support JsonUnknownDerivedTypeHandling ?

I could do the work if you want me to.

// Ryan

@NikolayTzonev
Copy link

NikolayTzonev commented Oct 10, 2024

@schnerring @RicoSuter What's the latest status of this PR? It is related to issue RicoSuter/NSwag#4375 which is critical because can lead to denial of service on public APIs

@ryanheath
Copy link
Contributor

@schnerring @RicoSuter What's the latest status of this PR? It is related to issue #4375 which is critical because can lead to denial of service on public APIs

Which issue #4375 ?

@NikolayTzonev
Copy link

Sorry about that. This issue - RicoSuter/NSwag#4375

@ryanheath
Copy link
Contributor

Yep in christianhelle/refitter/#462 we worked around it using the STJ-native.

@Jozzle
Copy link

Jozzle commented Oct 30, 2024

@schnerring @RicoSuter What's the latest status of this PR? It is related to issue RicoSuter/NSwag#4375 which is critical because can lead to denial of service on public APIs

We're experiencing the same, stackoverflow exceptions on incorrect/missing type discriminator. Any reason why this PR is open for so long?

@RicoSuter RicoSuter merged commit 284e993 into RicoSuter:master Nov 19, 2024
@RicoSuter
Copy link
Owner

Thanks for the PR.

Regarding the stackoverflow, I could not really repro this:
22d33c9#diff-181052195a641873f0edadea91a8d21aa00fbd92982bc42bd24431593e9cd04b

@RicoSuter
Copy link
Owner

Should we make this the new default or is something missing?

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

Successfully merging this pull request may close these issues.

6 participants