-
-
Notifications
You must be signed in to change notification settings - Fork 64
Allow input and setting files on command line #848
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,29 +7,27 @@ | |||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| public static ValidationResult Validate(Settings settings) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| if (BothSettingsFilesAreEmpty(settings) || BothSettingsFilesArePresent(settings)) | ||||||||||||||||||||||||||||||
| if (string.IsNullOrWhiteSpace(settings.OpenApiPath) && | ||||||||||||||||||||||||||||||
| string.IsNullOrWhiteSpace(settings.SettingsFilePath)) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return GetValidationErrorForSettingsFiles(); | ||||||||||||||||||||||||||||||
| return GetValidationErrorForNoInputNoSettings(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return !string.IsNullOrWhiteSpace(settings.SettingsFilePath) | ||||||||||||||||||||||||||||||
| ? ValidateFilePath(settings) | ||||||||||||||||||||||||||||||
| : ValidateOperationNameAndUrl(settings); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private static bool BothSettingsFilesAreEmpty(Settings settings) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return string.IsNullOrWhiteSpace(settings.OpenApiPath) && | ||||||||||||||||||||||||||||||
| string.IsNullOrWhiteSpace(settings.SettingsFilePath); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Check failure on line 20 in src/Refitter/SettingsValidator.cs
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private static bool BothSettingsFilesArePresent(Settings settings) | ||||||||||||||||||||||||||||||
| 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"); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private static ValidationResult GetValidationErrorForSettingsFiles() | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private static ValidationResult GetValidationErrorForTwoInputFiles() | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return ValidationResult.Error( | ||||||||||||||||||||||||||||||
| "You should either specify an input URL/file directly " + | ||||||||||||||||||||||||||||||
|
|
@@ -41,7 +39,6 @@ | |||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| var json = File.ReadAllText(settings.SettingsFilePath!); | ||||||||||||||||||||||||||||||
| var refitGeneratorSettings = Serializer.Deserialize<RefitGeneratorSettings>(json); | ||||||||||||||||||||||||||||||
| settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return ValidateFileAndOutputSettings(settings, refitGeneratorSettings); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
@@ -50,6 +47,14 @@ | |||||||||||||||||||||||||||||
| Settings settings, | ||||||||||||||||||||||||||||||
| RefitGeneratorSettings refitGeneratorSettings) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| if (!string.IsNullOrWhiteSpace(settings.OpenApiPath) && | ||||||||||||||||||||||||||||||
| !string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return GetValidationErrorForTwoInputFiles(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| settings.OpenApiPath = refitGeneratorSettings.OpenApiPath; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (string.IsNullOrWhiteSpace(refitGeneratorSettings.OpenApiPath)) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return GetValidationErrorForOpenApiPath(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.