diff --git a/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
new file mode 100644
index 000000000..fb6eaecc1
--- /dev/null
+++ b/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
@@ -0,0 +1,54 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+ false
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+
+
diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs
rename to Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs b/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs
rename to Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/OpenApiDocumentMock.cs b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/OpenApiDocumentMock.cs
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/Todo.xml
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/Todo.xml
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver1.json
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver1.json
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver2.json
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver2.json
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver3.json
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver3.json
diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json b/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver4.json
similarity index 100%
rename from test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json
rename to Microsoft.OpenApi.Hidi.Tests/UtilityFiles/postmanCollection_ver4.json
diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln
index cca18f1e5..157cb18ff 100644
--- a/Microsoft.OpenApi.sln
+++ b/Microsoft.OpenApi.sln
@@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTest
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{D8F799DD-04AC-4A13-B344-45A5B944450A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -62,6 +64,10 @@ Global
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -74,6 +80,7 @@ Global
{1ED3C2C1-E1E7-4925-B4E6-2D969C3F5237} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{AD79B61D-88CF-497C-9ED5-41AE3867C5AC} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1}
+ {D8F799DD-04AC-4A13-B344-45A5B944450A} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565}
diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
index cee484046..1cb71a20a 100644
--- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
+++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
@@ -15,7 +15,7 @@
Microsoft.OpenApi.Hidi
hidi
./../../artifacts
- 1.0.0-preview7
+ 1.0.0-preview8
OpenAPI.NET CLI tool for slicing OpenAPI documents
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
@@ -43,7 +43,7 @@
-
+
diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
index 8e1838d95..d9f9887e1 100644
--- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
+++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
@@ -63,10 +63,11 @@ CancellationToken cancellationToken
{
throw new ArgumentException("Please input a file path");
}
- if(output == null)
+ if (output == null)
{
- throw new ArgumentNullException(nameof(output));
- }
+ var inputExtension = GetInputPathExtension(openapi, csdl);
+ output = new FileInfo($"./output{inputExtension}");
+ };
if (cleanoutput && output.Exists)
{
output.Delete();
@@ -249,8 +250,6 @@ private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslC
return stream;
}
-
-
///
/// Implementation of the validate command
///
@@ -575,6 +574,21 @@ private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger)
return !input.StartsWith("http") && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml;
}
+ private static string GetInputPathExtension(string openapi = null, string csdl = null)
+ {
+ var extension = String.Empty;
+ if (!string.IsNullOrEmpty(openapi))
+ {
+ extension = Path.GetExtension(openapi);
+ }
+ else if (!string.IsNullOrEmpty(csdl))
+ {
+ extension = ".yml";
+ }
+
+ return extension;
+ }
+
private static ILoggerFactory ConfigureLoggerInstance(LogLevel loglevel)
{
// Configure logger options
diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs
index c8ba8fdcd..d19e48cf4 100644
--- a/src/Microsoft.OpenApi.Hidi/Program.cs
+++ b/src/Microsoft.OpenApi.Hidi/Program.cs
@@ -27,7 +27,7 @@ static async Task Main(string[] args)
var csdlFilterOption = new Option("--csdl-filter", "Comma delimited list of EntitySets or Singletons to filter CSDL on. e.g. tasks,accounts");
csdlFilterOption.AddAlias("--csf");
- var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne };
+ var outputOption = new Option("--output", "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne };
outputOption.AddAlias("-o");
var cleanOutputOption = new Option("--clean-output", "Overwrite an existing file");
diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
index c04eb7fd2..bfb749d0f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -250,14 +250,14 @@
-
+
-
+
-
+
-
+
all
diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
index 58ecdc95a..6f1763b30 100644
--- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
+++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj
@@ -8,9 +8,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 9e1cb4f75..6d1d86593 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -19,7 +19,7 @@
-
+
@@ -37,20 +37,5 @@
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
\ No newline at end of file