Skip to content

Commit 080095e

Browse files
irvinesundaydependabot[bot]baywetKuraiAndrasMaggieKimani1
authored
Release Hidi and libs (#1690)
* Bump Microsoft.Windows.Compatibility from 8.0.5 to 8.0.6 Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/windowsdesktop) from 8.0.5 to 8.0.6. - [Release notes](https://github.com/dotnet/windowsdesktop/releases) - [Commits](dotnet/windowsdesktop@v8.0.5...v8.0.6) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Bump Microsoft.OData.Edm from 7.21.2 to 7.21.3 Bumps Microsoft.OData.Edm from 7.21.2 to 7.21.3. --- updated-dependencies: - dependency-name: Microsoft.OData.Edm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Bump Verify.Xunit from 24.2.0 to 25.0.1 (#1685) Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 24.2.0 to 25.0.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/25.0.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump docker/login-action from 3.1.0 to 3.2.0 (#1683) Bumps [docker/login-action](https://github.com/docker/login-action) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](docker/login-action@v3.1.0...v3.2.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Return -1 exit code when the document is not valid * Change to relative path in `Launch Hidi` task * Bump docker/build-push-action from 5.3.0 to 5.4.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5.3.0 to 5.4.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](docker/build-push-action@v5.3.0...v5.4.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update conversion lib. version (#1689) * Bump lib versions --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vincent Biret <[email protected]> Co-authored-by: Kurai András <[email protected]> Co-authored-by: Maggie Kimani <[email protected]> Co-authored-by: Andrew Omondi <[email protected]>
1 parent a7283b0 commit 080095e

File tree

11 files changed

+66
-15
lines changed

11 files changed

+66
-15
lines changed

.github/workflows/docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Check out the repo
1818
uses: actions/checkout@v4
1919
- name: Login to GitHub package feed
20-
uses: docker/login-action@v3.1.0
20+
uses: docker/login-action@v3.2.0
2121
with:
2222
username: ${{ secrets.ACR_USERNAME }}
2323
password: ${{ secrets.ACR_PASSWORD }}
@@ -30,13 +30,13 @@ jobs:
3030
id: getversion
3131
- name: Push to GitHub Packages - Nightly
3232
if: ${{ github.ref == 'refs/heads/vnext' }}
33-
uses: docker/build-push-action@v5.3.0
33+
uses: docker/build-push-action@v5.4.0
3434
with:
3535
push: true
3636
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
3737
- name: Push to GitHub Packages - Release
3838
if: ${{ github.ref == 'refs/heads/master' }}
39-
uses: docker/build-push-action@v5.3.0
39+
uses: docker/build-push-action@v5.4.0
4040
with:
4141
push: true
4242
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// If you have changed target frameworks, make sure to update the program path.
1313
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net8.0/Microsoft.OpenApi.Hidi.dll",
1414
"args": ["plugin",
15-
"-m","C:\\Users\\darrmi\\src\\github\\microsoft\\openapi.net\\test\\Microsoft.OpenApi.Hidi.Tests\\UtilityFiles\\exampleapimanifest.json",
15+
"-m","${workspaceFolder}/test/Microsoft.OpenApi.Hidi.Tests/UtilityFiles/exampleapimanifest.json",
1616
"--of","./output"],
1717
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
1818
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public async Task<int> InvokeAsync(InvocationContext context)
3333
try
3434
{
3535
if (hidiOptions.OpenApi is null) throw new InvalidOperationException("OpenApi file is required");
36-
await OpenApiService.ValidateOpenApiDocument(hidiOptions.OpenApi, logger, cancellationToken).ConfigureAwait(false);
37-
return 0;
36+
var isValid = await OpenApiService.ValidateOpenApiDocument(hidiOptions.OpenApi, logger, cancellationToken).ConfigureAwait(false);
37+
return isValid is not false ? 0 : -1;
3838
}
3939
#if RELEASE
4040
#pragma warning disable CA1031 // Do not catch general exception types

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Nullable>enable</Nullable>
1010
<ToolCommandName>hidi</ToolCommandName>
1111
<PackageOutputPath>./../../artifacts</PackageOutputPath>
12-
<Version>1.4.4</Version>
12+
<Version>1.4.5</Version>
1313
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
1414
<SignAssembly>true</SignAssembly>
1515
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
@@ -34,8 +34,8 @@
3434
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
3535
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
3636
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
37-
<PackageReference Include="Microsoft.OData.Edm" Version="7.21.2" />
38-
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.6.5" />
37+
<PackageReference Include="Microsoft.OData.Edm" Version="7.21.3" />
38+
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.6.6" />
3939
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.0-preview" />
4040
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
4141
</ItemGroup>

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ private static MemoryStream ApplyFilterToCsdl(Stream csdlStream, string entitySe
322322
/// <summary>
323323
/// Implementation of the validate command
324324
/// </summary>
325-
public static async Task ValidateOpenApiDocument(
325+
/// <returns><see langword="true"/> when valid, <see langword="false"/> when invalid and <see langword="null"/> when cancelled</returns>
326+
public static async Task<bool?> ValidateOpenApiDocument(
326327
string openApi,
327328
ILogger logger,
328329
CancellationToken cancellationToken = default)
@@ -332,11 +333,13 @@ public static async Task ValidateOpenApiDocument(
332333
throw new ArgumentNullException(nameof(openApi));
333334
}
334335

336+
ReadResult? result = null;
337+
335338
try
336339
{
337340
using var stream = await GetStream(openApi, logger, cancellationToken).ConfigureAwait(false);
338341

339-
var result = await ParseOpenApi(openApi, false, logger, stream, cancellationToken).ConfigureAwait(false);
342+
result = await ParseOpenApi(openApi, false, logger, stream, cancellationToken).ConfigureAwait(false);
340343

341344
using (logger.BeginScope("Calculating statistics"))
342345
{
@@ -358,6 +361,10 @@ public static async Task ValidateOpenApiDocument(
358361
{
359362
throw new InvalidOperationException($"Could not validate the document, reason: {ex.Message}", ex);
360363
}
364+
365+
if (result is null) return null;
366+
367+
return result.OpenApiDiagnostic.Errors.Count == 0;
361368
}
362369

363370
private static async Task<ReadResult> ParseOpenApi(string openApiFile, bool inlineExternal, ILogger logger, Stream stream, CancellationToken cancellationToken = default)

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<LangVersion>latest</LangVersion>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6-
<Version>1.6.14</Version>
6+
<Version>1.6.15</Version>
77
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
88
<SignAssembly>true</SignAssembly>
99
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->

src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
12-
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.5" />
12+
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.6" />
1313
</ItemGroup>
1414
<ItemGroup>
1515
<Resource Include="Themes\Metro\HowToApplyTheme.txt" />

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<LangVersion>Latest</LangVersion>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6-
<Version>1.6.14</Version>
6+
<Version>1.6.15</Version>
77
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
88
<SignAssembly>true</SignAssembly>
99
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->

test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,31 @@ public async Task ValidateCommandProcessesOpenApi()
203203
Assert.True(true);
204204
}
205205

206+
[Fact]
207+
public async Task ValidFileReturnsTrue()
208+
{
209+
var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger);
210+
211+
Assert.True(isValid);
212+
}
213+
214+
[Fact]
215+
public async Task InvalidFileReturnsFalse()
216+
{
217+
var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger);
218+
219+
Assert.False(isValid);
220+
}
221+
222+
[Fact]
223+
public async Task CancellingValidationReturnsNull()
224+
{
225+
using var cts = new CancellationTokenSource();
226+
await cts.CancelAsync();
227+
var isValid = await OpenApiService.ValidateOpenApiDocument(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token);
228+
229+
Assert.Null(isValid);
230+
}
206231

207232
[Fact]
208233
public async Task TransformCommandConvertsOpenApi()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sample OpenApi
4+
version: 1.0.0
5+
paths:
6+
/api/editresource:
7+
get:
8+
operationId: api.ListEditresource
9+
patch:
10+
operationId: api.UpdateEditresource
11+
responses:
12+
'200':
13+
description: OK
14+
/api/viewresource:
15+
get:
16+
operationId: api.ListViewresource
17+
responses:
18+
'200':
19+
description: OK

test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="Moq" Version="4.20.70" />
1616
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1717
<PackageReference Include="SharpYaml" Version="2.1.1" />
18-
<PackageReference Include="Verify.Xunit" Version="24.2.0" />
18+
<PackageReference Include="Verify.Xunit" Version="25.0.1" />
1919
<PackageReference Include="xunit" Version="2.8.1" />
2020
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" PrivateAssets="all" />
2121
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

0 commit comments

Comments
 (0)