Add explicit support for OpenAPI configuration files - #1604
Add explicit support for OpenAPI configuration files#1604christianhelle wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughAdds a ChangesConfigurationFile option end-to-end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 (1)
src/VSIX/ApiClientCodeGen.VSIX.Extensibility/Settings/ExtensionSettingsProvider.cs (1)
92-113: 🎯 Functional Correctness | 🔴 CriticalAdd missing
OpenApiConfigurationFilesetting and populateConfigurationFileproperty.The
ConfigurationFileproperty (line 223) is declared but never initialized from settings. UnlikeTemplatesPath(line 222), which reads fromOpenApiGeneratorSettings.OpenApiTemplatesPath, there is no correspondingOpenApiConfigurationFilesetting defined inOpenApiGeneratorSettings.cs. The setting must be created as a String setting, then added to the read list inGetOpenApiGeneratorOptionsAsync(lines 94-109) and used to initialize theConfigurationFileproperty.🤖 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/VSIX/ApiClientCodeGen.VSIX.Extensibility/Settings/ExtensionSettingsProvider.cs` around lines 92 - 113, The ConfigurationFile property is declared but never populated from settings, unlike the TemplatesPath property which correctly reads from OpenApiGeneratorSettings.OpenApiTemplatesPath. First, add a new String setting constant called OpenApiConfigurationFile to the OpenApiGeneratorSettings class (following the pattern of OpenApiTemplatesPath). Then, add this new OpenApiConfigurationFile setting to the settings array parameter in the ReadAsync call within the GetOpenApiGeneratorOptionsAsync method (lines 94-109). Finally, ensure that the OpenApiOptions constructor or the method that populates it uses the retrieved value to initialize the ConfigurationFile property, matching how TemplatesPath is currently being handled.
🤖 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/VSIX/ApiClientCodeGen.VSIX.Extensibility/Settings/ExtensionSettingsProvider.cs`:
- Line 223: The ConfigurationFile property is declared but not initialized from
the settings values like other properties in the class (e.g., TemplatesPath).
Initialize the ConfigurationFile property by reading from the values dictionary
using the appropriate OpenApiGeneratorSettings key (OpenApiConfigurationFile or
similar), following the same pattern as TemplatesPath at line 222. Additionally,
add this setting key to the list of settings being retrieved in the
GetOpenApiGeneratorOptionsAsync method (lines 94-109) to ensure the value is
actually fetched and available in the values dictionary.
---
Outside diff comments:
In
`@src/VSIX/ApiClientCodeGen.VSIX.Extensibility/Settings/ExtensionSettingsProvider.cs`:
- Around line 92-113: The ConfigurationFile property is declared but never
populated from settings, unlike the TemplatesPath property which correctly reads
from OpenApiGeneratorSettings.OpenApiTemplatesPath. First, add a new String
setting constant called OpenApiConfigurationFile to the OpenApiGeneratorSettings
class (following the pattern of OpenApiTemplatesPath). Then, add this new
OpenApiConfigurationFile setting to the settings array parameter in the
ReadAsync call within the GetOpenApiGeneratorOptionsAsync method (lines 94-109).
Finally, ensure that the OpenApiOptions constructor or the method that populates
it uses the retrieved value to initialize the ConfigurationFile property,
matching how TemplatesPath is currently being handled.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f35669ec-7217-4fef-b3ac-a8031b23b813
📒 Files selected for processing (8)
README.mdsrc/CLI/ApiClientCodeGen.CLI/Commands/CSharp/OpenApiCSharpGeneratorCommand.cssrc/Core/ApiClientCodeGen.Core.Tests/Generators/OpenApi/OpenApiCSharpCodeGeneratorTests.cssrc/Core/ApiClientCodeGen.Core/Generators/OpenApi/OpenApiCSharpCodeGenerator.cssrc/Core/ApiClientCodeGen.Core/Options/OpenApiGenerator/DefaultOpenApiGeneratorOptions.cssrc/Core/ApiClientCodeGen.Core/Options/OpenApiGenerator/IOpenApiGeneratorOptions.cssrc/VSIX/ApiClientCodeGen.VSIX.Extensibility/Settings/ExtensionSettingsProvider.cssrc/VSIX/ApiClientCodeGen.VSIX.Shared/Options/OpenApiGenerator/OpenApiGeneratorOptionsPage.cs
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 2 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 2 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/VSIX/ApiClientCodeGen.VSIX.Shared/Options/OpenApiGenerator/OpenApiGeneratorOptions.cs`:
- Line 47: The logging in OpenApiGeneratorOptions currently writes the raw
ConfigurationFile path, which should be sanitized. Update the logging around
Logger.Instance.WriteLine in OpenApiGeneratorOptions so it only reports that a
configuration file was provided or a redacted/safe representation, and avoid
emitting the full path value from ConfigurationFile.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 57c5f93e-5b85-4ac9-8627-447d14c4e084
📒 Files selected for processing (1)
src/VSIX/ApiClientCodeGen.VSIX.Shared/Options/OpenApiGenerator/OpenApiGeneratorOptions.cs
|


This pull request adds support for specifying an explicit OpenAPI Generator configuration file when generating C# code from OpenAPI specs, and improves configuration file handling throughout the codebase. The changes also update the documentation and add tests to ensure correct behavior.
OpenAPI Generator configuration file support:
--config-fileoption to the CLI (OpenApiCSharpGeneratorCommandSettings) to allow users to specify an explicit OpenAPI Generator configuration file path.OpenApiCSharpCodeGenerator) to prioritize the explicit configuration file if provided, falling back to auto-discovery only if not specified.IOpenApiGeneratorOptions,DefaultOpenApiGeneratorOptions,OpenApiGeneratorOptionsPage, and VSIX settings) to support the newConfigurationFileproperty. [1] [2] [3] [4]Testing and documentation:
OpenApiCSharpCodeGeneratorTests).README.mdto document the new--config-fileoption and explain the auto-discovery mechanism for configuration files.Code quality:
Summary by CodeRabbit
--config-file <path>option to explicitly provide an OpenAPI Generator configuration file (takes precedence over auto-discovery).--config-fileand the auto-discovery naming patterns:<spec>.config.<ext>,<spec>.config.json,<spec>.config.yaml.