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

Added setting UsePolymorphicSerialization #462

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

ryanheath
Copy link
Contributor

Fixes #459 and Unknown subtype causes Stackoverflow exception at deserialization

Loosely based on Add support for STJ-native C# code gen

When UseSystemTextJsonPolymorphicSerialization is set to true
a CustomTemplateFactory is used that overrides the NSwag DefaultTemplateFactory behavior.
The STJ polymorphic attributes are rendered instead of NSwag own polymorphic attributes.

when true a CustomTemplateFactory is used that overrides the NSwag DefaultTemplateFactory behavior
@christianhelle christianhelle self-assigned this Sep 10, 2024
@christianhelle christianhelle added the enhancement New feature, bug fix, or request label Sep 10, 2024
@christianhelle
Copy link
Owner

@ryanheath Thanks for taking the time to investigate and implement this. I'll start reviewing this immediately

@christianhelle
Copy link
Owner

@all-contributors please add @ryanheath for code

Copy link
Contributor

@christianhelle

I've put up a pull request to add @ryanheath! 🎉

Copy link
Owner

@christianhelle christianhelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanheath I just have a few minor suggestions, but all-in-all this looks great!

src/Refitter.Core/Settings/RefitGeneratorSettings.cs Outdated Show resolved Hide resolved
src/Refitter/Settings.cs Outdated Show resolved Hide resolved
src/Refitter.Core/Refitter.Core.csproj Show resolved Hide resolved
@ryanheath
Copy link
Contributor Author

The tests are still failing because of a static template dictionary deep down in the nwag or nschema sources.
I'll see want can be done.

…ion into custom template models to be used in the liquid template files ...
Copy link

sonarcloud bot commented Sep 10, 2024

@ryanheath
Copy link
Contributor Author

I have added a lot more override and custom implementation of NSwag/NSchema generators and models.
NSwag/NSchema is not extensible friendly regarding this point, or I must have overlooked an easy way to access settings in the template files ... 😅

@ryanheath ryanheath changed the title Added setting UseSystemTextJsonPolymorphicSerialization Added setting UsePolymorphicSerialization Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 40 lines in your changes missing coverage. Please review.

Project coverage is 85.95%. Comparing base (f7c6865) to head (d9f050e).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
src/Refitter.Core/CustomCSharpClientGenerator.cs 59.15% 26 Missing and 3 partials ⚠️
src/Refitter.Core/CSharpClientGeneratorFactory.cs 79.24% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #462       +/-   ##
===========================================
- Coverage   96.04%   85.95%   -10.09%     
===========================================
  Files          73       50       -23     
  Lines        3991     2769     -1222     
===========================================
- Hits         3833     2380     -1453     
- Misses        116      357      +241     
+ Partials       42       32       -10     
Flag Coverage Δ
unittests 85.95% <75.00%> (-10.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@christianhelle christianhelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @ryanheath

@christianhelle
Copy link
Owner

I have added a lot more override and custom implementation of NSwag/NSchema generators and models. NSwag/NSchema is not extensible friendly regarding this point, or I must have overlooked an easy way to access settings in the template files ... 😅

Yeah, I agree. It looks needlessly complicated and harder than it should be.

Let's merge this in

@christianhelle christianhelle merged commit 646b180 into christianhelle:main Sep 11, 2024
4 of 6 checks passed
@ryanheath
Copy link
Contributor Author

Thank you @christianhelle!

@ryanheath
Copy link
Contributor Author

@christianhelle what else should we do to get a new (pre) release nuget?

@christianhelle
Copy link
Owner

@christianhelle what else should we do to get a new (pre) release nuget?

I can create a pre-release now as it is so that you can use it

@christianhelle
Copy link
Owner

@ryanheath I was planning to update the docs tonight but then I can just do another pre-release with the new docs

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

Successfully merging this pull request may close these issues.

Is it possible to replace the liquid files of NSwag?
2 participants