From d6ae550549746f925886d0cc7b61bee594e6b71f Mon Sep 17 00:00:00 2001 From: HavenDV Date: Sat, 6 Jul 2024 04:52:47 +0400 Subject: [PATCH] fix: Fixed CLI issues. --- src/libs/Directory.Build.props | 2 +- .../OpenApiGenerator.Cli/Commands/GenerateCommand.cs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libs/Directory.Build.props b/src/libs/Directory.Build.props index ecc80c54ce..6dfaf6abc5 100644 --- a/src/libs/Directory.Build.props +++ b/src/libs/Directory.Build.props @@ -39,7 +39,7 @@ - 0.11.9 + 0.11.10 0.1 v dev diff --git a/src/libs/OpenApiGenerator.Cli/Commands/GenerateCommand.cs b/src/libs/OpenApiGenerator.Cli/Commands/GenerateCommand.cs index e179c390cb..93ed4b22e5 100644 --- a/src/libs/OpenApiGenerator.Cli/Commands/GenerateCommand.cs +++ b/src/libs/OpenApiGenerator.Cli/Commands/GenerateCommand.cs @@ -16,7 +16,7 @@ public class GenerateCommand : Command description: "Input file path"); var outputOption = new Option( aliases: ["--output", "-o"], - getDefaultValue: () => string.Empty, + getDefaultValue: () => "Generated", description: "Output file path"); var targetFrameworkOption = new Option( aliases: ["--targetFramework", "-t"], @@ -83,7 +83,7 @@ private static async Task HandleAsync( JsonSerializerType: default, UseRequiredKeyword: default, GenerateConstructors: false, - GroupByTags: false, + GroupByTags: true, GenerateMethods: false, MethodNamingConvention: default, MethodNamingConventionFallback: MethodNamingConvention.MethodAndPath, @@ -117,6 +117,8 @@ private static async Task HandleAsync( .Where(x => !x.IsEmpty) .ToArray(); + Directory.CreateDirectory(outputPath); + if (generateAsSingleFile) { var text = string.Join(Environment.NewLine, files.Select(x => x.Text)); @@ -124,12 +126,6 @@ private static async Task HandleAsync( return; } - if (string.IsNullOrWhiteSpace(outputPath)) - { - outputPath = name; - Directory.CreateDirectory(outputPath); - } - foreach (var file in files) { await File.WriteAllTextAsync(Path.Combine(outputPath, file.Name), file.Text).ConfigureAwait(false);