Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c588976
Bump docker/build-push-action from 4.1.0 to 4.1.1
dependabot[bot] Jun 19, 2023
4bbb876
Merge pull request #1280 from microsoft/dependabot/github_actions/doc…
baywet Jun 20, 2023
619552b
Bump Verify.Xunit from 20.3.2 to 20.4.0
dependabot[bot] Jun 20, 2023
3c53f1d
Merge pull request #1281 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jun 21, 2023
4e17d06
Bump Microsoft.Windows.Compatibility from 7.0.3 to 7.0.4
dependabot[bot] Jun 22, 2023
5a99e7b
Merge pull request #1282 from microsoft/dependabot/nuget/Microsoft.Wi…
baywet Jun 22, 2023
4093310
Bump Microsoft.OData.Edm from 7.16.0 to 7.17.0
dependabot[bot] Jun 23, 2023
e44eff5
Merge pull request #1283 from microsoft/dependabot/nuget/Microsoft.OD…
baywet Jun 23, 2023
a89ab95
Fix hardcoded non-portable path separators
mikekistler Jun 27, 2023
973cc41
Merge pull request #1284 from mikekistler/support-macos-arm
baywet Jun 27, 2023
9276848
Bump Microsoft.NET.Test.Sdk from 17.6.2 to 17.6.3
dependabot[bot] Jun 27, 2023
069a410
Merge pull request #1285 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Jun 27, 2023
0560a4a
Bump xunit from 2.4.2 to 2.5.0
dependabot[bot] Jul 7, 2023
a0c505a
Merge pull request #1288 from microsoft/dependabot/nuget/xunit-2.5.0
baywet Jul 8, 2023
5eba558
Bump xunit.runner.visualstudio from 2.4.5 to 2.5.0
dependabot[bot] Jul 8, 2023
4606cd9
Merge pull request #1289 from microsoft/dependabot/nuget/xunit.runner…
baywet Jul 8, 2023
b5c03a2
Bump Verify.Xunit from 20.4.0 to 20.5.0
dependabot[bot] Jul 10, 2023
166dafd
Merge pull request #1291 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jul 10, 2023
dd7f72b
Bump Verify.Xunit from 20.5.0 to 20.5.1
dependabot[bot] Jul 17, 2023
b91a229
Merge pull request #1292 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 18, 2023
da0fd1c
parse server's url with variables when convert openapi 3.0 to 2.0
TinaLiu02 Jul 18, 2023
bd12c69
Update src/Microsoft.OpenApi/Models/OpenApiDocument.cs
TinaLiu02 Jul 19, 2023
da71361
Merge pull request #1293 from TinaLiu02/parse-server-variable
MaggieKimani1 Jul 20, 2023
637ac1d
Bump lib versions
MaggieKimani1 Jul 21, 2023
8d41a27
Merge pull request #1295 from microsoft/mk/release-libs
MaggieKimani1 Jul 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected].0
uses: docker/[email protected].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/[email protected].0
uses: docker/[email protected].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