Skip to content

Commit

Permalink
Merge pull request #1296 from microsoft/vnext
Browse files Browse the repository at this point in the history
Release v1.6.6
  • Loading branch information
MaggieKimani1 authored Jul 24, 2023
2 parents ffb9bd0 + 8d41a27 commit 137a456
Show file tree
Hide file tree
Showing 15 changed files with 793 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
id: getversion
- name: Push to GitHub Packages - Nightly
if: ${{ github.ref == 'refs/heads/vnext' }}
uses: docker/build-push-action@v4.1.0
uses: docker/build-push-action@v4.1.1
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
- name: Push to GitHub Packages - Release
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4.1.0
uses: docker/build-push-action@v4.1.1
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.2.5</Version>
<Version>1.2.6</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down Expand Up @@ -43,7 +43,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.16.0" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.17.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.5.0-preview2" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.0-preview" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi.Readers</Title>
<PackageId>Microsoft.OpenApi.Readers</PackageId>
<Version>1.6.5</Version>
<Version>1.6.6</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.3" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.4" />
</ItemGroup>
<ItemGroup>
<Resource Include="Themes\Metro\HowToApplyTheme.txt" />
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi</Title>
<PackageId>Microsoft.OpenApi</PackageId>
<Version>1.6.5</Version>
<Version>1.6.6</Version>
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
18 changes: 15 additions & 3 deletions src/Microsoft.OpenApi/Models/OpenApiDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ public void SerializeAsV2(IOpenApiWriter writer)
writer.WriteEndObject();
}

private static string ParseServerUrl(OpenApiServer server)
{
var parsedUrl = server.Url;

var variables = server.Variables;
foreach (var variable in variables.Where(static x => !string.IsNullOrEmpty(x.Value.Default)))
{
parsedUrl = parsedUrl.Replace($"{{{variable.Key}}}", variable.Value.Default);
}
return parsedUrl;
}

private static void WriteHostInfoV2(IOpenApiWriter writer, IList<OpenApiServer> servers)
{
if (servers == null || !servers.Any())
Expand All @@ -299,11 +311,11 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList<OpenApiServer>

// Arbitrarily choose the first server given that V2 only allows
// one host, port, and base path.
var firstServer = servers.First();
var serverUrl = ParseServerUrl(servers.First());

// Divide the URL in the Url property into host and basePath required in OpenAPI V2
// The Url property cannotcontain path templating to be valid for V2 serialization.
var firstServerUrl = new Uri(firstServer.Url, UriKind.RelativeOrAbsolute);
var firstServerUrl = new Uri(serverUrl, UriKind.RelativeOrAbsolute);

// host
if (firstServerUrl.IsAbsoluteUri)
Expand Down Expand Up @@ -337,7 +349,7 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList<OpenApiServer>
var schemes = servers.Select(
s =>
{
Uri.TryCreate(s.Url, UriKind.RelativeOrAbsolute, out var url);
Uri.TryCreate(ParseServerUrl(s), UriKind.RelativeOrAbsolute, out var url);
return url;
})
.Where(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -13,10 +13,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string opera
public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection()
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver2.json");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver2.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();

Expand Down Expand Up @@ -107,7 +107,7 @@ public void TestPredicateFiltersUsingRelativeRequestUrls()
public void ShouldParseNestedPostmanCollection()
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver3.json");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver3.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();

Expand All @@ -124,7 +124,7 @@ public void ShouldParseNestedPostmanCollection()
public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument()
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver1.json");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver1.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();

Expand All @@ -141,7 +141,7 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument()
public void ContinueProcessingWhenUrlsInCollectionAreMissingFromSourceDocument()
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver4.json");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver4.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();

Expand Down
33 changes: 18 additions & 15 deletions test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public OpenApiServiceTests()
public async Task ReturnConvertedCSDLFile()
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml");
var fileInput = new FileInfo(filePath);
var csdlStream = fileInput.OpenRead();
// Act
Expand All @@ -50,7 +50,7 @@ public async Task ReturnConvertedCSDLFile()
public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount)
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml");
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml");
var fileInput = new FileInfo(filePath);
var csdlStream = fileInput.OpenRead();

Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
// create a dummy ILogger instance for testing
var options = new HidiOptions()
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml",
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
Output = new FileInfo("sample.md")
};

Expand All @@ -152,7 +152,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram()
{
var options = new HidiOptions()
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml"
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml")
};
var filePath = await OpenApiService.ShowOpenApiDocument(options, _logger, new CancellationToken());
Assert.True(File.Exists(filePath));
Expand All @@ -163,7 +163,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiag
{
var options = new HidiOptions()
{
Csdl = "UtilityFiles\\Todo.xml",
Csdl = Path.Combine("UtilityFiles", "Todo.xml"),
CsdlFilter = "todos",
Output = new FileInfo("sample.md")
};
Expand Down Expand Up @@ -201,7 +201,7 @@ await Assert.ThrowsAsync<InvalidOperationException>(async () =>
public async Task ValidateCommandProcessesOpenApi()
{
// create a dummy ILogger instance for testing
await OpenApiService.ValidateOpenApiDocument("UtilityFiles\\SampleOpenApi.yml", _logger, new CancellationToken());
await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, new CancellationToken());

Assert.True(true);
}
Expand All @@ -212,7 +212,7 @@ public async Task TransformCommandConvertsOpenApi()
{
HidiOptions options = new HidiOptions
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml",
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
Output = new FileInfo("sample.json"),
CleanOutput = true,
TerseOutput = false,
Expand All @@ -232,7 +232,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputname()
{
HidiOptions options = new HidiOptions
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml",
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
CleanOutput = true,
TerseOutput = false,
InlineLocal = false,
Expand All @@ -250,7 +250,7 @@ public async Task TransformCommandConvertsCsdlWithDefaultOutputname()
{
HidiOptions options = new HidiOptions
{
Csdl = "UtilityFiles\\Todo.xml",
Csdl = Path.Combine("UtilityFiles", "Todo.xml"),
CleanOutput = true,
TerseOutput = false,
InlineLocal = false,
Expand All @@ -268,7 +268,7 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputnameAndSwitchF
{
HidiOptions options = new HidiOptions
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml",
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
CleanOutput = true,
Version = "3.0",
OpenApiFormat = OpenApiFormat.Yaml,
Expand Down Expand Up @@ -301,10 +301,10 @@ await Assert.ThrowsAsync<ArgumentException>(async () =>
[Fact]
public async Task TransformToPowerShellCompliantOpenApi()
{
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\examplepowershellsettings.json");
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json");
HidiOptions options = new HidiOptions
{
OpenApi = "UtilityFiles\\SampleOpenApi.yml",
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
CleanOutput = true,
Version = "3.0",
OpenApiFormat = OpenApiFormat.Yaml,
Expand All @@ -324,7 +324,8 @@ public async Task TransformToPowerShellCompliantOpenApi()
public void InvokeTransformCommand()
{
var rootCommand = Program.CreateRootCommand();
var args = new string[] { "transform", "-d", ".\\UtilityFiles\\SampleOpenApi.yml", "-o", "sample.json", "--co" };
var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
var args = new string[] { "transform", "-d", openapi, "-o", "sample.json", "--co" };
var parseResult = rootCommand.Parse(args);
var handler = rootCommand.Subcommands.Where(c => c.Name == "transform").First().Handler;
var context = new InvocationContext(parseResult);
Expand All @@ -340,7 +341,8 @@ public void InvokeTransformCommand()
public void InvokeShowCommand()
{
var rootCommand = Program.CreateRootCommand();
var args = new string[] { "show", "-d", ".\\UtilityFiles\\SampleOpenApi.yml", "-o", "sample.md" };
var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
var args = new string[] { "show", "-d", openapi, "-o", "sample.md" };
var parseResult = rootCommand.Parse(args);
var handler = rootCommand.Subcommands.Where(c => c.Name == "show").First().Handler;
var context = new InvocationContext(parseResult);
Expand All @@ -355,7 +357,8 @@ public void InvokeShowCommand()
public void InvokePluginCommand()
{
var rootCommand = Program.CreateRootCommand();
var args = new string[] { "plugin", "-m", ".\\UtilityFiles\\exampleapimanifest.json", "--of", AppDomain.CurrentDomain.BaseDirectory };
var manifest = Path.Combine(".", "UtilityFiles", "exampleapimanifest.json");
var args = new string[] { "plugin", "-m", manifest, "--of", AppDomain.CurrentDomain.BaseDirectory };
var parseResult = rootCommand.Parse(args);
var handler = rootCommand.Subcommands.Where(c => c.Name == "plugin").First().Handler;
var context = new InvocationContext(parseResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="FluentAssertions" Version="6.11.0">
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
</PackageReference>
<PackageReference Include="SharpYaml" Version="2.1.0">
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2">
<PackageReference Include="xunit" Version="2.5.0">
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="Verify.Xunit" Version="20.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Verify.Xunit" Version="20.5.1" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 137a456

Please sign in to comment.