Skip to content

Split RefitGeneratorSettings into focused config records#1148

Merged
christianhelle merged 4 commits into
mainfrom
feat/deepen-refit-generator-settings
Jun 15, 2026
Merged

Split RefitGeneratorSettings into focused config records#1148
christianhelle merged 4 commits into
mainfrom
feat/deepen-refit-generator-settings

Conversation

@christianhelle

@christianhelle christianhelle commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Deepens \RefitGeneratorSettings\ by splitting its 50+ properties into 8 focused configuration records that compose. The public API surface is identical — properties delegate to their owning record internally.

Changes

New files (8 config records)

  • \OpenApiSourceConfig\ — OpenAPI source paths (\OpenApiPath, \OpenApiPaths)
  • \CodeGenerationConfig\ — generation toggles (contracts, clients, headers, etc.)
  • \ParameterConfig\ — cancellation tokens, date format, collection format, optional params
  • \OutputConfig\ — output paths, namespace, filename, multiple files
  • \TypeConfig\ — accessibility, property naming, contract suffix, immutable records
  • \FilterConfig\ — tags, path matches, ignored headers, namespace filtering
  • \SchemaConfig\ — schema trimming, keep patterns, inheritance hierarchy
  • \FeatureConfig\ — Apizr, polymorphic serialization, auth headers, security scheme

Modified files

  • \RefitGeneratorSettings.cs\ — rewritten as a composition root holding 8 private config instances. Each property delegates get/set to its owning record.

Preserved as direct properties (existing separate classes)

  • \NamingSettings\
  • \CodeGeneratorSettings\
  • \DependencyInjectionSettings\

Design Decisions

  • Backward compatible — zero changes to the .refitter\ JSON schema. All [JsonPropertyName], [JsonConverter], and [JsonIgnore]\ attributes remain on \RefitGeneratorSettings\ properties.
  • No consumer changes — every property still exists on \RefitGeneratorSettings. All existing code compiles without modification.
  • Deletion test — each record concentrates its domain. Delete \SchemaConfig\ → schema trimming vanishes. Delete \NamingConfig\ → naming behavior vanishes.
  • Existing records preserved — \ApizrSettings, \CodeGeneratorSettings, \NamingSettings, \DependencyInjectionSettings\ are not split further.

Verification

  • Build: 0 errors
  • Tests: 2284 passed, 0 failed

Summary by CodeRabbit

  • New Features
    • Added new end-user configuration classes to fine-tune code generation (OpenAPI source selection, output folder/namespace/filenames, parameter behavior, schema trimming and inheritance retention, type accessibility and naming, and code generation controls such as contracts/clients, headers, docs, templates, and overrides).
    • Added settings for endpoint/type filtering and additional feature toggles (including polymorphic serialization and security/auth header generation).
  • Chores
    • Reorganized generator settings to route public options through dedicated configuration objects for cleaner structure.

Create 8 domain-focused configuration records that partition the
50+ properties of RefitGeneratorSettings into small, stable interfaces:

- OpenApiSourceConfig: OpenAPI source paths
- CodeGenerationConfig: what to generate (contracts, clients, etc.)
- ParameterConfig: cancellation tokens, date format, collection format
- OutputConfig: output paths, namespace, filename
- TypeConfig: type accessibility, naming policy, contract suffix
- FilterConfig: tags, path matches, namespace filtering
- SchemaConfig: schema trimming settings
- FeatureConfig: Apizr, polymorphism, auth headers, security scheme

Each config class has its own defaults and owns one domain.
JSON attributes are duplicated on RefitGeneratorSettings properties
for backward-compatible serialization.
RefitGeneratorSettings now composes 8 focused config records instead of
holding 50+ properties directly. Each property delegates to its owning
record:

- OpenApi properties -> OpenApiSourceConfig
- Code generation toggles -> CodeGenerationConfig
- Parameter options -> ParameterConfig
- Output paths/namespace -> OutputConfig
- Type accessibility/naming -> TypeConfig
- Filtering -> FilterConfig
- Schema trimming -> SchemaConfig
- Feature flags -> FeatureConfig

Preserved as direct properties (existing separate classes):
NamingSettings, CodeGeneratorSettings, DependencyInjectionSettings.

JSON serialization contract is unchanged — all [JsonPropertyName]
attributes remain on RefitGeneratorSettings properties. The public
API surface is identical; all consumers compile without changes.
@christianhelle christianhelle added enhancement New feature, bug fix, or request .NET Pull requests that contain changes to .NET code labels Jun 15, 2026
@christianhelle christianhelle self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8babd7f7-bf9b-466c-af44-95813fdaa03c

📥 Commits

Reviewing files that changed from the base of the PR and between bdbcea0 and 209d115.

📒 Files selected for processing (2)
  • src/Refitter.Core/Settings/CodeGenerationConfig.cs
  • src/Refitter.Core/Settings/OutputConfig.cs

📝 Walkthrough

Walkthrough

Eight new focused configuration POCOs are introduced: OpenApiSourceConfig, OutputConfig, CodeGenerationConfig, ParameterConfig, TypeConfig, FilterConfig, SchemaConfig, and FeatureConfig. RefitGeneratorSettings is refactored from a flat DTO into a façade that holds private instances of these config objects and proxies all public property access to them.

Changes

Settings Decomposition and RefitGeneratorSettings Delegation

Layer / File(s) Summary
New config POCOs
src/Refitter.Core/Settings/OpenApiSourceConfig.cs, src/Refitter.Core/Settings/OutputConfig.cs, src/Refitter.Core/Settings/CodeGenerationConfig.cs, src/Refitter.Core/Settings/ParameterConfig.cs, src/Refitter.Core/Settings/TypeConfig.cs, src/Refitter.Core/Settings/FilterConfig.cs, src/Refitter.Core/Settings/SchemaConfig.cs, src/Refitter.Core/Settings/FeatureConfig.cs
Eight new public settings classes partition configuration concerns: OpenApiSourceConfig holds OpenAPI document input paths; OutputConfig manages output folder/namespace defaults and multi-file behavior; CodeGenerationConfig controls contract/client generation, header behavior, response overrides, and naming strategies; ParameterConfig configures cancellation tokens, date format, parameter ordering, and collection formats; TypeConfig sets type accessibility, property naming policy, contract suffix, and record immutability; FilterConfig defines tag/path/namespace filtering patterns; SchemaConfig controls schema trimming and inheritance handling; FeatureConfig provides Apizr, polymorphic serialization, AOT, and authentication header configuration. All classes use ExcludeFromCodeCoverage, Description attributes, and JSON converters for enum properties.
RefitGeneratorSettings delegation refactor
src/Refitter.Core/Settings/RefitGeneratorSettings.cs
RefitGeneratorSettings is transformed from a flat auto-property DTO to a façade pattern: eight private config object fields (_openApiSource, _outputConfig, _codeGeneration, _parameterConfig, _typeConfig, _filterConfig, _schemaConfig, _featureConfig) replace inline storage. Every public property getter/setter is rewritten to forward to the corresponding sub-config object. DefaultOutputFolder and DefaultNamespace constants are updated to reference OutputConfig.DefaultOutputFolder and OutputConfig.DefaultNamespace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • christianhelle/refitter#709: Adds GenerateXmlDocCodeComments usage in interface/method generation, which is now a property on the new CodeGenerationConfig class introduced here.
  • christianhelle/refitter#936: Adds AuthenticationHeaderStyle enum handling and header generation logic, which is now housed in the FeatureConfig class introduced here.
  • christianhelle/refitter#1146: Introduces RefitPipeline, RefitCodeGenerator, and RefitSchemaCleaner modules that directly consume the RefitGeneratorSettings properties being refactored here.

Poem

🐇 Eight little configs, each in their place,
No longer a monolith cluttered with space.
I hopped through the settings, assigned them with care—
A façade to proxy each field with a flair!
From schemas to features, from types to the source,
The settings are tidy—what a wonderful course! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring: decomposing RefitGeneratorSettings into 8 focused configuration records while maintaining backward compatibility.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/deepen-refit-generator-settings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@christianhelle christianhelle changed the title feat: deepen RefitGeneratorSettings into focused config records Split RefitGeneratorSettings into focused config records Jun 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Refitter.Core/Settings/RefitGeneratorSettings.cs (1)

11-447: 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift

Add XML documentation comments for the public API surface.

This refactor keeps a large public API, but the public class/members still lack XML doc comments (/// <summary>...). Please add XML docs for the class and public members so API consumers get proper IntelliSense/docs output.

Example pattern
+/// <summary>
+/// Defines settings for Refit code generation.
+/// </summary>
 public class RefitGeneratorSettings
 {
+    /// <summary>
+    /// Default output folder for generated files.
+    /// </summary>
     public const string DefaultOutputFolder = OutputConfig.DefaultOutputFolder;

As per coding guidelines, **/*.cs: Include XML documentation for public APIs in C# code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Refitter.Core/Settings/RefitGeneratorSettings.cs` around lines 11 - 447,
The RefitGeneratorSettings class and its public properties lack XML
documentation comments. Add XML doc comments (`/// <summary>...</summary>`)
above the RefitGeneratorSettings class declaration itself and above each public
property definition to provide proper IntelliSense documentation for API
consumers. Ensure each comment clearly describes the purpose and behavior of the
class and respective properties, matching the descriptions already provided in
the [Description] attributes where applicable.

Source: Coding guidelines

🧹 Nitpick comments (1)
src/Refitter.Core/Settings/OpenApiSourceConfig.cs (1)

8-17: ⚡ Quick win

Add XML documentation to the public API surface in this config class.

OpenApiSourceConfig and its public properties are exposed APIs, but they currently rely only on [Description]. Please add /// <summary> XML docs for the class and each public property to meet repository standards.

As per coding guidelines, "Include XML documentation for public APIs in C# code."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Refitter.Core/Settings/OpenApiSourceConfig.cs` around lines 8 - 17, The
OpenApiSourceConfig class and its public properties OpenApiPath and OpenApiPaths
are missing XML documentation comments required for public API surface. Add ///
<summary> XML documentation blocks above the class definition and above each
property to document their purpose, complementing the existing [Description]
attributes. Ensure the XML docs clearly describe what each property represents
and its usage.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Refitter.Core/Settings/CodeGenerationConfig.cs`:
- Around line 45-50: The Description attribute for the ResponseTypeOverride
property contains text that references AddAcceptHeaders, which is incorrect
copy-paste content. Update the Description text in the ResponseTypeOverride
property definition to accurately describe what this property does (mapping
operation ids to specific response types that should be used, with the type
wrapped in a task). Ensure the corrected description clearly explains the
property's purpose rather than describing a different feature.

In `@src/Refitter.Core/Settings/OutputConfig.cs`:
- Around line 24-30: Fix the Description text for the OutputFilename property in
the OutputConfig class by correcting the typo "The the Source Generator" to "The
Source Generator" and fixing the malformed sentence structure. The description
should have proper punctuation and syntax — remove the stray closing parenthesis
and ensure the sentence about the default value for the Source Generator is
complete and grammatically correct.

---

Outside diff comments:
In `@src/Refitter.Core/Settings/RefitGeneratorSettings.cs`:
- Around line 11-447: The RefitGeneratorSettings class and its public properties
lack XML documentation comments. Add XML doc comments (`///
<summary>...</summary>`) above the RefitGeneratorSettings class declaration
itself and above each public property definition to provide proper IntelliSense
documentation for API consumers. Ensure each comment clearly describes the
purpose and behavior of the class and respective properties, matching the
descriptions already provided in the [Description] attributes where applicable.

---

Nitpick comments:
In `@src/Refitter.Core/Settings/OpenApiSourceConfig.cs`:
- Around line 8-17: The OpenApiSourceConfig class and its public properties
OpenApiPath and OpenApiPaths are missing XML documentation comments required for
public API surface. Add /// <summary> XML documentation blocks above the class
definition and above each property to document their purpose, complementing the
existing [Description] attributes. Ensure the XML docs clearly describe what
each property represents and its usage.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 80ae83c9-88d8-415d-ae6d-611dbb6c1d01

📥 Commits

Reviewing files that changed from the base of the PR and between 4c703d5 and c518886.

📒 Files selected for processing (9)
  • src/Refitter.Core/Settings/CodeGenerationConfig.cs
  • src/Refitter.Core/Settings/FeatureConfig.cs
  • src/Refitter.Core/Settings/FilterConfig.cs
  • src/Refitter.Core/Settings/OpenApiSourceConfig.cs
  • src/Refitter.Core/Settings/OutputConfig.cs
  • src/Refitter.Core/Settings/ParameterConfig.cs
  • src/Refitter.Core/Settings/RefitGeneratorSettings.cs
  • src/Refitter.Core/Settings/SchemaConfig.cs
  • src/Refitter.Core/Settings/TypeConfig.cs

Comment thread src/Refitter.Core/Settings/CodeGenerationConfig.cs
Comment thread src/Refitter.Core/Settings/OutputConfig.cs
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.54%. Comparing base (5bb177f) to head (209d115).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1148   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files          67       67           
  Lines        3100     3100           
=======================================
  Hits         2931     2931           
  Misses         59       59           
  Partials      110      110           
Flag Coverage Δ
unittests 94.54% <ø> (ø)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Restore XML doc comments on RefitGeneratorSettings properties that were
removed during the composition refactoring. Add XML doc comments to all
new config record classes and their public properties/members.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Refitter.Core/Settings/RefitGeneratorSettings.cs (1)

204-209: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix stale public API description text.

Several docs/Description values are copy-paste stale or misleading: ResponseTypeOverride says “AddAcceptHeaders dictionary”, IncludeTags describes multiple interfaces, OutputFilename says “The the Source Generator”, GenerateDefaultAdditionalProperties describes skipping while the property controls generation, and ApizrSettings has “Get ot set”. These can leak into API docs, schema, or CLI help. As per coding guidelines, include XML documentation for public APIs in C# code.

Suggested wording cleanup
-        AddAcceptHeaders dictionary of operation ids and a specific response type that they should use.
+        Dictionary of operation ids and the specific response type that they should use.

-    [Description("Generate a Refit interface for each endpoint.")]
+    [Description("Only include endpoints that contain this tag. May be set multiple times and result in OR'ed evaluation.")]

-        The the Source Generator, this is the name of the generated class
+        For the Source Generator, this is the name of the generated class

-    [Description("Skip default additional properties. Default is true.")]
+    [Description("Generate default additional properties. Default is true.")]

-    /// Get ot set the settings describing how to configure Apizr
+    /// Gets or sets the settings describing how to configure Apizr.

Also applies to: 315-320, 387-394, 474-478, 494-496

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Refitter.Core/Settings/RefitGeneratorSettings.cs` around lines 204 - 209,
Fix stale and inaccurate Description attributes for several public API
properties in RefitGeneratorSettings.cs across multiple locations. The
ResponseTypeOverride property (lines 204-209) incorrectly references
"AddAcceptHeaders dictionary" instead of describing its actual purpose;
IncludeTags (lines 315-320) has misleading text about multiple interfaces;
OutputFilename (lines 387-394) contains "The the" and inaccurate description;
GenerateDefaultAdditionalProperties (lines 474-478) describes skipping instead
of generation; and ApizrSettings (lines 494-496) contains the typo "Get ot set".
Update each Description attribute to accurately reflect what each property
actually does, correcting copy-paste errors, typos, and misleading content.
Additionally, consider adding proper XML documentation comments (///) for these
public APIs as per C# coding guidelines.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/Refitter.Core/Settings/RefitGeneratorSettings.cs`:
- Around line 204-209: Fix stale and inaccurate Description attributes for
several public API properties in RefitGeneratorSettings.cs across multiple
locations. The ResponseTypeOverride property (lines 204-209) incorrectly
references "AddAcceptHeaders dictionary" instead of describing its actual
purpose; IncludeTags (lines 315-320) has misleading text about multiple
interfaces; OutputFilename (lines 387-394) contains "The the" and inaccurate
description; GenerateDefaultAdditionalProperties (lines 474-478) describes
skipping instead of generation; and ApizrSettings (lines 494-496) contains the
typo "Get ot set". Update each Description attribute to accurately reflect what
each property actually does, correcting copy-paste errors, typos, and misleading
content. Additionally, consider adding proper XML documentation comments (///)
for these public APIs as per C# coding guidelines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fdcc321c-5482-47f9-8e18-76ee5762bc73

📥 Commits

Reviewing files that changed from the base of the PR and between c518886 and bdbcea0.

📒 Files selected for processing (9)
  • src/Refitter.Core/Settings/CodeGenerationConfig.cs
  • src/Refitter.Core/Settings/FeatureConfig.cs
  • src/Refitter.Core/Settings/FilterConfig.cs
  • src/Refitter.Core/Settings/OpenApiSourceConfig.cs
  • src/Refitter.Core/Settings/OutputConfig.cs
  • src/Refitter.Core/Settings/ParameterConfig.cs
  • src/Refitter.Core/Settings/RefitGeneratorSettings.cs
  • src/Refitter.Core/Settings/SchemaConfig.cs
  • src/Refitter.Core/Settings/TypeConfig.cs
✅ Files skipped from review due to trivial changes (1)
  • src/Refitter.Core/Settings/CodeGenerationConfig.cs
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/Refitter.Core/Settings/FilterConfig.cs
  • src/Refitter.Core/Settings/TypeConfig.cs
  • src/Refitter.Core/Settings/OutputConfig.cs
  • src/Refitter.Core/Settings/SchemaConfig.cs
  • src/Refitter.Core/Settings/OpenApiSourceConfig.cs
  • src/Refitter.Core/Settings/FeatureConfig.cs
  • src/Refitter.Core/Settings/ParameterConfig.cs

@christianhelle
christianhelle enabled auto-merge June 15, 2026 09:12
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 2 unresolved review comments.

Files modified:

  • src/Refitter.Core/Settings/CodeGenerationConfig.cs
  • src/Refitter.Core/Settings/OutputConfig.cs

Commit: 209d115c36224303f44c0aaca7125b1f7f55d700

The changes have been pushed to the feat/deepen-refit-generator-settings branch.

Time taken: 1m 20s

Fixed 2 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@christianhelle
christianhelle merged commit 4cf407b into main Jun 15, 2026
7 of 10 checks passed
@christianhelle
christianhelle deleted the feat/deepen-refit-generator-settings branch June 15, 2026 09:22
@sonarqubecloud

Copy link
Copy Markdown

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 .NET Pull requests that contain changes to .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant