Allow input and setting files on command line#848
Conversation
WalkthroughReworks input validation in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.cs📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (7)📓 Common learnings📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
📚 Learning: 2025-12-04T23:11:05.599ZApplied to files:
🧬 Code graph analysis (1)src/Refitter/SettingsValidator.cs (1)
🔇 Additional comments (2)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/Refitter/SettingsValidator.cs (3)
33-33: Critical: Unconditional assignment destroys CLI-provided OpenAPI path.This line unconditionally overwrites
settings.OpenApiPathwith the value from the settings file, even if the user provided an OpenAPI file via CLI. This breaks the primary use case from issue #847 where a user provides./openapi.jsonon the command line and a settings file for other configuration.Example failure:
refitter ./openapi.json --settings-file ./openapi.refitter --output ./GeneratedCode.csIf
openapi.refitterdoesn't defineopenApiPath, line 33 setssettings.OpenApiPathto null/empty, and line 48-51 returns "openApiPath in settings file is required"—even though the user provided it via CLI.🔎 Apply this diff to preserve CLI-provided values:
- settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) + { + settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + }
21-27: Minor: Fix typo in error message.Line 25 contains a grammatical error: "or use specify" should be "or specify".
🔎 Apply this diff to fix the typo:
return ValidationResult.Error( "You should either specify an input URL/file directly " + - "or use specify it in 'openApiPath' from the settings file, " + + "or specify it in 'openApiPath' from the settings file, " + "not both");
48-51: Fix the logic for handling CLI and settings file OpenApiPath precedence.Line 33 unconditionally overwrites
settings.OpenApiPathwith the settings file value, destroying CLI arguments. When a user provides a CLI argument and the settings file lacksopenApiPath, line 33 wipes out the CLI value, causing the check at lines 48-50 to incorrectly report that no path was specified in the CLI even though one was provided.The validation at lines 42-45 cannot detect the double-specification scenario because
settings.OpenApiPathhas already been destroyed. Preserve the CLI value if provided, using it only as a fallback when the settings file path is absent.
🧹 Nitpick comments (1)
src/Refitter/SettingsValidator.cs (1)
8-19: Verify validation logic with comprehensive tests.The changes to validation logic require thorough testing across multiple input scenarios:
- CLI OpenApiPath only
- Settings file with openApiPath only
- CLI OpenApiPath + settings file without openApiPath (issue #847 use case)
- CLI OpenApiPath + settings file with openApiPath (should error)
- Neither provided (should error)
Based on learnings, CLI changes should be tested with real OpenAPI specifications to ensure generation works correctly.
Do you want me to generate comprehensive unit tests covering all these validation scenarios? I can create test cases that verify the fix for issue #847 and prevent regression.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (1)
src/Refitter/SettingsValidator.cs (1)
10-14: Approve the empty-inputs check, but note incomplete validation.The check correctly handles the case where neither CLI nor settings file provides an input source. However, the validation doesn't prevent the problematic scenario where the user provides OpenApiPath via CLI AND the settings file also contains openApiPath—this should ideally be caught before line 33's assignment.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Refitter/SettingsValidator.cs (1)
49-52: Related issue: Check uses wrong source for OpenApiPath validation.After applying the fix at line 40 (conditional assignment), this check will still incorrectly fail when CLI provides
OpenApiPathbut the settings file doesn't. The check should validate the effective/mergedsettings.OpenApiPathrather thanrefitGeneratorSettings.OpenApiPath.🔎 Apply this diff to check the effective path:
- if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) { return GetValidationErrorForOpenApiPath(); }
♻️ Duplicate comments (1)
src/Refitter/SettingsValidator.cs (1)
40-40: Critical: Unconditional assignment overwrites CLI-provided OpenApiPath.When a user provides an input file on the CLI and a settings file that does NOT contain
openApiPath, this line unconditionally overwrites the CLI value withnull/empty from the settings file. This causes the validation at line 49 to fail with an incorrect error.Example failure:
refitter ./openapi.json --settings-file ./settings.refitter # If settings.refitter has no openApiPath → CLI value is lost → errorThe assignment should only occur when the CLI didn't provide a path.
🔎 Apply this diff to preserve CLI-provided OpenApiPath:
- settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) + { + settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (2)
src/Refitter/SettingsValidator.cs (2)
10-14: LGTM!The guard correctly validates that at least one input source is provided (either CLI path or settings file). This is the appropriate first-level validation.
21-27: LGTM!The renamed method
GetValidationErrorForNoOrTwoInputFilesbetter describes its purpose. The error message clearly communicates the constraint.
|
@all-contributors please add @lilinus for code |
|
I've put up a pull request to add @lilinus! 🎉 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #848 +/- ##
=======================================
Coverage 92.76% 92.76%
=======================================
Files 23 23
Lines 1948 1948
=======================================
Hits 1807 1807
Misses 48 48
Partials 93 93
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9ba15f5 to
d4d75ac
Compare
|
@christianhelle I noticed there were some errors in my code, I have pushed a fix now. |
d4d75ac to
65a47b9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Refitter/SettingsValidator.cs (1)
38-55: Critical: CLI-provided OpenApiPath is overwritten before dual-input validation.The logic flaw from the previous review remains. Line 42 unconditionally overwrites
settings.OpenApiPathwith the settings file value BEFORE the check at lines 51-55. This breaks the intended fix for issue #847:Scenario:
refitter ./openapi.json --settings-file ./settings.refitter
settings.OpenApiPath="./openapi.json"(from CLI)- Line 42 overwrites it with
refitGeneratorSettings.OpenApiPath- Lines 51-55 compare identical values (both from settings file)
Result: If settings file has
openApiPath→ false positive error. If it doesn't → CLI path is lost and line 57-60 fails.🔎 Apply this diff to preserve CLI value and fix the validation:
private static ValidationResult ValidateFilePath(Settings settings) { + var cliOpenApiPath = settings.OpenApiPath; var json = File.ReadAllText(settings.SettingsFilePath!); var refitGeneratorSettings = Serializer.Deserialize<RefitGeneratorSettings>(json); - settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + + if (string.IsNullOrWhiteSpace(cliOpenApiPath)) + { + settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + } - return ValidateFileAndOutputSettings(settings, refitGeneratorSettings); + return ValidateFileAndOutputSettings(settings, refitGeneratorSettings, cliOpenApiPath); } private static ValidationResult ValidateFileAndOutputSettings( Settings settings, - RefitGeneratorSettings refitGeneratorSettings) + RefitGeneratorSettings refitGeneratorSettings, + string? cliOpenApiPath = null) { - if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) && + if (!string.IsNullOrWhiteSpace(cliOpenApiPath) && !string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) { return GetValidationErrorForTwoInputFiles(); }
🧹 Nitpick comments (1)
src/Refitter/SettingsValidator.cs (1)
22-29: LGTM with minor nit.Clear error message. Line 29 introduces an unnecessary blank line before
GetValidationErrorForTwoInputFiles.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (1)
src/Refitter/SettingsValidator.cs (1)
10-14: LGTM!Clean consolidation of the no-input validation into a single, clear check.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Refitter/SettingsValidator.cs (2)
22-36: Fix grammar in error messages.Both messages contain "or use specify it" which should be "or specify it".
🔎 Apply this diff to fix the grammar:
private static ValidationResult GetValidationErrorForNoInputNoSettings() { return ValidationResult.Error( "You should specify an input URL/file directly " + - "or use specify it in 'openApiPath' from the settings file"); + "or specify it in 'openApiPath' from the settings file"); } private static ValidationResult GetValidationErrorForTwoInputFiles() { return ValidationResult.Error( "You should either specify an input URL/file directly " + - "or use specify it in 'openApiPath' from the settings file, " + + "or specify it in 'openApiPath' from the settings file, " + "not both"); }
82-88: Fix grammar: same issue in output path error message.Line 86 also contains "or use specify it".
🔎 Apply this diff:
private static ValidationResult GetValidationErrorForOutputPath() { return ValidationResult.Error( "You should either specify an output path directly from --output " + - "or use specify it in 'outputFolder' and 'outputFilename' from the settings file, " + + "or specify it in 'outputFolder' and 'outputFilename' from the settings file, " + "not both"); }
♻️ Duplicate comments (1)
src/Refitter/SettingsValidator.cs (1)
20-20: Critical: Extra closing brace causes compilation error.This stray
}was previously identified and should have been removed. It closes the class prematurely, causing all subsequent methods to be outside the class scope.🔎 Apply this diff to remove the extra brace:
return !string.IsNullOrWhiteSpace(settings.SettingsFilePath) ? ValidateFilePath(settings) : ValidateOperationNameAndUrl(settings); } - }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (1)
src/Refitter/SettingsValidator.cs (1)
10-14: LGTM!The early validation correctly catches the case when no input source is provided at all.
| if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) && | ||
| !string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) | ||
| { | ||
| return GetValidationErrorForTwoInputFiles(); | ||
| } | ||
|
|
||
| if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) | ||
| { | ||
| return GetValidationErrorForOpenApiPath(); | ||
| } | ||
|
|
||
| settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; |
There was a problem hiding this comment.
Critical: Logic prevents CLI input file with settings file that lacks openApiPath.
When a user runs refitter ./openapi.json --settings-file ./openapi.refitter where the settings file does not contain openApiPath (using it only for other options), the current logic fails:
- Line 50-51:
settings.OpenApiPathis non-empty,refitGeneratorSettings.OpenApiPathis empty → condition FALSE - Line 56:
refitGeneratorSettings.OpenApiPathis empty → returns error
This defeats the PR objective. The check at line 56 should only trigger when neither source provides the path. Additionally, line 61 unconditionally overwrites the CLI value.
🔎 Apply this diff to fix the validation logic:
private static ValidationResult ValidateFileAndOutputSettings(
Settings settings,
RefitGeneratorSettings refitGeneratorSettings)
{
if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) &&
!string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath))
{
return GetValidationErrorForTwoInputFiles();
}
- if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath))
+ if (string.IsNullOrWhiteSpace(settings.OpenApiPath) &&
+ string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath))
{
return GetValidationErrorForOpenApiPath();
}
- settings.OpenApiPath = refitGeneratorSettings.OpenApiPath;
+ if (string.IsNullOrWhiteSpace(settings.OpenApiPath))
+ {
+ settings.OpenApiPath = refitGeneratorSettings.OpenApiPath;
+ }
if (!string.IsNullOrWhiteSpace(settings.OutputPath) &&🤖 Prompt for AI Agents
In src/Refitter/SettingsValidator.cs around lines 50 to 61, the logic
incorrectly returns an error when the CLI provides OpenApiPath but the settings
file does not, and then unconditionally overwrites the CLI value; change the
second validation to only error when both sources are empty (use && instead of
the current single-source check), and only assign settings.OpenApiPath from
refitGeneratorSettings.OpenApiPath when settings.OpenApiPath is empty so the CLI
value is not overwritten.
65a47b9 to
5a7e82c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Refitter/SettingsValidator.cs (2)
30-36: Fix grammatical error in user-facing message.Line 34 contains "or use specify it" which should be "or specify it".
🔎 Apply this diff to correct the grammar:
return ValidationResult.Error( "You should either specify an input URL/file directly " + - "or use specify it in 'openApiPath' from the settings file, " + + "or specify it in 'openApiPath' from the settings file, " + "not both");
58-61: Critical: Validation checks source instead of merged value.After the assignment at line 56, the validation at line 58 should check
settings.OpenApiPath(the merged result) rather thanrefitGeneratorSettings.OpenApiPath(the settings file source). This forces the settings file to always provideopenApiPatheven when the CLI provides it.Combined with the issue at line 56, this prevents the PR's intended behavior. After fixing line 56 to conditional assignment, this line should validate the final merged value.
🔎 Apply this diff (after fixing line 56) to validate the merged value:
- if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) { return GetValidationErrorForOpenApiPath(); }
♻️ Duplicate comments (2)
src/Refitter/SettingsValidator.cs (2)
50-56: Critical: Unconditional assignment destroys CLI input, breaking the PR objective.Line 56 unconditionally overwrites
settings.OpenApiPathwith the settings file value, which destroys any CLI-provided input. This defeats the entire purpose of PR #848.Example failure (the exact scenario from issue #847):
refitter ./openapi.json --settings-file ./openapi.refitterIf the settings file does NOT contain
openApiPath(using it only for other options):
- Line 50-51: Check passes because
refitGeneratorSettings.OpenApiPathis empty- Line 56: Overwrites
settings.OpenApiPath = null→ CLI value./openapi.jsonis destroyed- Line 58: Detects empty
refitGeneratorSettings.OpenApiPath→ returns errorThe user cannot use CLI input with a settings file unless the settings file also specifies
openApiPath, which contradicts the PR objective.🔎 Apply this diff to preserve the CLI value:
if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) && !string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) { return GetValidationErrorForTwoInputFiles(); } - settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) + { + settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + }
20-20: Critical: Extra closing brace causes compilation failure.Line 20 contains a stray
}that prematurely closes theSettingsValidatorclass. All methods defined after this line (lines 22-119) would be outside the class scope, causing compilation to fail.This was flagged in a previous review comment as addressed in commit 65a47b9, but the issue persists in the current code.
🔎 Apply this diff to remove the stray brace:
return !string.IsNullOrWhiteSpace(settings.SettingsFilePath) ? ValidateFilePath(settings) : ValidateOperationNameAndUrl(settings); } - }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (2)
src/Refitter/SettingsValidator.cs (2)
10-14: LGTM! Clean consolidation of initial validation.The combined check correctly ensures at least one input source is provided before proceeding to deeper validation.
38-44: LGTM! Settings file loading is correct.The deserialization correctly loads the settings file and delegates validation to the next stage.
| private static ValidationResult GetValidationErrorForNoInputNoSettings() | ||
| { | ||
| return !string.IsNullOrWhiteSpace(settings.OpenApiPath) && | ||
| !string.IsNullOrWhiteSpace(settings.SettingsFilePath); | ||
| return ValidationResult.Error( | ||
| "You should specify an input URL/file directly " + | ||
| "or use specify it in 'openApiPath' from the settings file"); | ||
| } |
There was a problem hiding this comment.
Fix grammatical error in user-facing message.
Line 25 contains "or use specify it" which should be "or specify it".
🔎 Apply this diff to correct the grammar:
return ValidationResult.Error(
"You should specify an input URL/file directly " +
- "or use specify it in 'openApiPath' from the settings file");
+ "or specify it in 'openApiPath' from the settings file");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private static ValidationResult GetValidationErrorForNoInputNoSettings() | |
| { | |
| return !string.IsNullOrWhiteSpace(settings.OpenApiPath) && | |
| !string.IsNullOrWhiteSpace(settings.SettingsFilePath); | |
| return ValidationResult.Error( | |
| "You should specify an input URL/file directly " + | |
| "or use specify it in 'openApiPath' from the settings file"); | |
| } | |
| private static ValidationResult GetValidationErrorForNoInputNoSettings() | |
| { | |
| return ValidationResult.Error( | |
| "You should specify an input URL/file directly " + | |
| "or specify it in 'openApiPath' from the settings file"); | |
| } |
🤖 Prompt for AI Agents
In src/Refitter/SettingsValidator.cs around lines 22 to 27, the user-facing
error message contains a grammatical mistake ("or use specify it"); update the
returned string to replace "or use specify it in 'openApiPath' from the settings
file" with "or specify it in 'openApiPath' in the settings file" (or equivalent
correct phrasing) so the message reads clearly and grammatically correct.
|
@lilinus latest change doesn't build. There's an extra |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Refitter/SettingsValidator.cs (1)
32-33: Fix grammatical error in error message.The message contains "or use specify it" which is grammatically incorrect.
🔎 Apply this diff to correct the grammar:
- "or use specify it in 'openApiPath' from the settings file, " + + "or specify it in 'openApiPath' from the settings file, " +
♻️ Duplicate comments (2)
src/Refitter/SettingsValidator.cs (2)
49-60: Critical: Unconditional assignment breaks CLI input + settings file combination.Line 55 unconditionally overwrites the CLI-provided
OpenApiPathwith the value from the settings file. This defeats the PR objective of allowingrefitter ./openapi.json --settings-file ./openapi.refitterwhen the settings file doesn't containopenApiPath.Example failure:
refitter ./openapi.json --settings-file ./openapi.refitterIf
openapi.refittercontains noopenApiPath:
- Line 49-50: CLI has value, settings file doesn't → condition FALSE
- Line 55:
settings.OpenApiPath = null→ CLI value lost!- Line 57: Now empty → ERROR
The assignment should only occur when the CLI didn't provide a value, and the validation should check if both sources are empty.
🔎 Apply this diff to fix the validation logic:
if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) && !string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) { return GetValidationErrorForTwoInputFiles(); } - settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; - - if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) + { + settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; + } + + if (string.IsNullOrWhiteSpace(settings.OpenApiPath)) { return GetValidationErrorForOpenApiPath(); }
24-25: Fix grammatical error in user-facing message.Line 25 contains "or use specify it" which should be "or specify it".
🔎 Apply this diff to correct the grammar:
- "or use specify it in 'openApiPath' from the settings file"); + "or specify it in 'openApiPath' from the settings file");
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Refitter/SettingsValidator.cs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.cs: Use PascalCase for public members and camelCase for parameters and local variables in C# code
Include XML documentation for public APIs in C# code
Use meaningful variable and method names in C# code
Follow existing C# coding conventions defined in.editorconfig
Files:
src/Refitter/SettingsValidator.cs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/Settings/RefitGeneratorSettings.cs : Add corresponding property to `src/Refitter.Core/Settings/RefitGeneratorSettings.cs` for each new CLI option
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test CLI changes with real OpenAPI specifications to ensure generation works correctly
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Tests/**/*.cs : Test with both OpenAPI 2.0 and 3.0 specifications when working with OpenAPI specifications
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/GenerateCommand.cs : Update `CreateRefitGeneratorSettings()` method in `src/Refitter/GenerateCommand.cs` when adding new CLI options
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter/Settings.cs : Add new CLI options as properties in `src/Refitter/Settings.cs` with `[CommandOption("--option-name")]` attribute
Applied to files:
src/Refitter/SettingsValidator.cs
📚 Learning: 2025-12-04T23:11:05.599Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-04T23:11:05.599Z
Learning: Applies to src/Refitter.Core/**/*.cs : Implement new CLI option logic in `src/Refitter.Core/RefitInterfaceGenerator.cs` or related generator classes
Applied to files:
src/Refitter/SettingsValidator.cs
🧬 Code graph analysis (1)
src/Refitter/SettingsValidator.cs (1)
src/Refitter/GenerateCommand.cs (1)
ValidationResult(15-25)
🔇 Additional comments (2)
src/Refitter/SettingsValidator.cs (2)
10-14: LGTM: No-input validation is correct.The check correctly ensures at least one input source (CLI or settings file) is provided before proceeding.
37-43: Assignment moved to ValidateFileAndOutputSettings - verify downstream logic.The removal of
settings.OpenApiPathassignment here is intentional, as it's been moved to line 55. Ensure the downstream validation logic handles all scenarios correctly.
|
@lilinus I checked out this branch locally to try it out Given the following .refitter file: {
"namespace": "Petstore"
}and the following command I get the an error message: I guess there's more work do be done to properly support this. This sort of falls back to the original idea of either using a .refitter settings file, or using CLI arguments. Combining CLI arguments with a .refitter settings file means we need to handle merging the options available from CLI arguments with the .refitter settings file, and showing specialized error messages per conflicting option |
|
Ah thanks for such quick feedback. Sorry, I did the changes in a bit of a rush yesterday. Thanks for an awesome tool btw. |
|
clicked approved by accident from VS Code
|
I closed this becuase I couldn't find any way to distinguish between missing and default value on the refit generator settings, without duplicating alot of code. Sorry! |
No problem ❤️ I probably hit the same wall before, but just couldn't remember it |



Fixes #847
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.