diff --git a/OpenApiGenerator.sln b/OpenApiGenerator.sln index 26902354f4..78a3bcd5da 100644 --- a/OpenApiGenerator.sln +++ b/OpenApiGenerator.sln @@ -62,6 +62,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "specs", "specs", "{7E829AE4 specs\twitch.json = specs\twitch.json EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenApiGenerator.IntegrationTests.Cli", "src\tests\OpenApiGenerator.IntegrationTests.Cli\OpenApiGenerator.IntegrationTests.Cli.csproj", "{41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -124,6 +126,10 @@ Global {7C8C2EF1-2E1E-4623-92B6-95BDDBE4A32E}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C8C2EF1-2E1E-4623-92B6-95BDDBE4A32E}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C8C2EF1-2E1E-4623-92B6-95BDDBE4A32E}.Release|Any CPU.Build.0 = Release|Any CPU + {41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -144,6 +150,7 @@ Global {01D74ED6-33E1-456C-AD74-C7F5BE90D042} = {9CAA231D-7BE1-46C9-ACD6-EB2E569CEBEA} {7C8C2EF1-2E1E-4623-92B6-95BDDBE4A32E} = {9CAA231D-7BE1-46C9-ACD6-EB2E569CEBEA} {7E829AE4-1ACD-43C0-87ED-9902566DF437} = {94FE90BF-FA05-46C6-A207-6E454A236659} + {41F1B4D8-5F6F-40FB-A1C2-A5E6A4B62AA7} = {9CAA231D-7BE1-46C9-ACD6-EB2E569CEBEA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1493AEE4-9211-46E9-BFE6-8F629EAC5693} diff --git a/src/tests/OpenApiGenerator.IntegrationTests.Cli/CliTests.cs b/src/tests/OpenApiGenerator.IntegrationTests.Cli/CliTests.cs new file mode 100644 index 0000000000..f985677195 --- /dev/null +++ b/src/tests/OpenApiGenerator.IntegrationTests.Cli/CliTests.cs @@ -0,0 +1,68 @@ +using CliWrap.Buffered; + +namespace OpenApiGenerator.IntegrationTests; + +[TestClass] +public class CliTests +{ + [DataTestMethod] + //[DataRow("github.yaml")] + [DataRow("ipinfo.yaml")] + [DataRow("langsmith.yaml")] + //[DataRow("langsmith.json")] + [DataRow("ollama.yaml")] + [DataRow("openai.yaml")] + [DataRow("petstore.yaml")] + [DataRow("replicate.json")] + //[DataRow("special-cases.yaml")] + [DataRow("twitch.json")] + public async Task Run(string spec) + { + var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + try + { + Directory.CreateDirectory(tempDirectory); + + var currentDirectory = Directory.GetCurrentDirectory(); + var repositoryDirectory = Path.GetFullPath(Path.Combine(currentDirectory, "../../../../../..")); + _ = await CliWrap.Cli.Wrap("dotnet") + .WithArguments([ + "run", + "--project", "src/libs/OpenApiGenerator.Cli", + "generate", $"specs/{spec}", + "--output", tempDirectory, + "--namespace", "Oag", + // --json-serializer-type SystemTextJson --target-framework netstandard2.0 --generate-sdk + ]) + .WithWorkingDirectory(repositoryDirectory) + .ExecuteBufferedAsync(); + + Directory.EnumerateFiles(tempDirectory, "*", SearchOption.AllDirectories) + .Should() + .NotBeEmpty(); + + await File.WriteAllTextAsync(Path.Combine(tempDirectory, "Oag.csproj"), @" + + + net8.0 + + + + true + latest + All + + +"); + + var response = await DotnetCliWrapper.Dotnet.BuildAsync(tempDirectory + "/"); + Console.WriteLine(response.StandardOutput); + Console.WriteLine(response.StandardError); + response.Diagnostics.Should().BeEmpty(); + } + finally + { + Directory.Delete(tempDirectory, recursive: true); + } + } +} \ No newline at end of file diff --git a/src/tests/OpenApiGenerator.IntegrationTests.Cli/OpenApiGenerator.IntegrationTests.Cli.csproj b/src/tests/OpenApiGenerator.IntegrationTests.Cli/OpenApiGenerator.IntegrationTests.Cli.csproj new file mode 100644 index 0000000000..4e6e764a23 --- /dev/null +++ b/src/tests/OpenApiGenerator.IntegrationTests.Cli/OpenApiGenerator.IntegrationTests.Cli.csproj @@ -0,0 +1,41 @@ + + + + net8.0 + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + +