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

Generate IDisposable Refit Interfaces #543

Merged
merged 6 commits into from
Nov 26, 2024
Merged

Generate IDisposable Refit Interfaces #543

merged 6 commits into from
Nov 26, 2024

Conversation

christianhelle
Copy link
Owner

The changes here fixes the issue introduced in #541 where the generated code using IDisposable doesn't build due to the System namespace being imported multiple times.

This pull request includes several updates to documentation, configuration files, and code to support new features and improve existing functionality. The most important changes include the addition of polymorphic serialization and disposable client generation, along with corresponding updates to documentation and tests.

New Features:

  • Added support for System.Text.Json polymorphic serialization, replacing NSwag JsonInheritanceConverter attributes with System.Text.Json JsonPolymorphicAttributes. This allows for native support of inheritance (de)serialization and fallback to base types when payloads with unknown types are offered by newer API versions. (README.md, cli-tool.md, json-schema.json, GenerateCommand.cs) [1] [2] [3] [4]
  • Introduced the option to generate Refit clients that implement IDisposable, enabling better resource management. (README.md, cli-tool.md, json-schema.json, GenerateCommand.cs) [1] [2] [3] [4]

Documentation Updates:

  • Updated the README.md files and other documentation to reflect the new options for polymorphic serialization and disposable client generation. (README.md, cli-tool.md, refitter-file-format.md) [1] [2] [3]
  • Added examples and explanations for the new features in the .refitter file format and CLI tool documentation. (refitter-file-format.md, cli-tool.md) [1] [2]

Codebase Enhancements:

  • Modified the RefitInterfaceImports.cs to conditionally include the System namespace only if disposable clients are generated. (RefitInterfaceImports.cs)
  • Updated the GenerateCommand.cs to include the new GenerateDisposableClients setting. (GenerateCommand.cs)

Testing Improvements:

  • Added new test cases to verify the generation of disposable clients and ensure the generated code builds correctly. (SwaggerPetstoreMultipleFileTests.cs, SwaggerPetstoreTests.cs) [1] [2]

@christianhelle christianhelle added documentation Improvements or additions to documentation enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code labels Nov 26, 2024
@christianhelle christianhelle self-assigned this Nov 26, 2024
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.76%. Comparing base (0cb3f2e) to head (515f15e).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #543      +/-   ##
==========================================
+ Coverage   91.72%   94.76%   +3.03%     
==========================================
  Files          51       51              
  Lines        2659     2541     -118     
==========================================
- Hits         2439     2408      -31     
+ Misses        182       98      -84     
+ Partials       38       35       -3     
Flag Coverage Δ
unittests 94.76% <100.00%> (+3.03%) ⬆️

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.

@christianhelle christianhelle merged commit 555d08c into main Nov 26, 2024
8 checks passed
@christianhelle christianhelle deleted the disposable branch November 26, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant