Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releases Hidi #1703

Merged
merged 37 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5fa4cf0
Bump Microsoft.Windows.Compatibility from 8.0.5 to 8.0.6
dependabot[bot] May 28, 2024
4c7a471
Merge pull request #1682 from microsoft/dependabot/nuget/Microsoft.Wi…
baywet May 29, 2024
1c4d227
Bump Microsoft.OData.Edm from 7.21.2 to 7.21.3
dependabot[bot] Jun 3, 2024
53a5621
Bump Verify.Xunit from 24.2.0 to 25.0.1 (#1685)
dependabot[bot] Jun 4, 2024
037dbf3
Merge pull request #1684 from microsoft/dependabot/nuget/Microsoft.OD…
baywet Jun 4, 2024
2049b73
Bump docker/login-action from 3.1.0 to 3.2.0 (#1683)
dependabot[bot] Jun 4, 2024
71beac4
Return -1 exit code when the document is not valid
KuraiAndras Jun 7, 2024
d2fe762
Change to relative path in `Launch Hidi` task
KuraiAndras Jun 7, 2024
d9fc82b
Merge pull request #1687 from KuraiAndras/fix-launch-args
MaggieKimani1 Jun 10, 2024
09bef6c
Merge pull request #1686 from KuraiAndras/return-non-0-exit-code-on-v…
MaggieKimani1 Jun 10, 2024
5a83840
Bump docker/build-push-action from 5.3.0 to 5.4.0
dependabot[bot] Jun 10, 2024
05a5f4d
Merge pull request #1688 from microsoft/dependabot/github_actions/doc…
andrueastman Jun 11, 2024
bbc31f5
Update conversion lib. version (#1689)
irvinesunday Jun 11, 2024
f8ba576
Bump lib versions
MaggieKimani1 Jun 11, 2024
d49167e
Merge pull request #1691 from microsoft/mk/bump-lib-versions
MaggieKimani1 Jun 11, 2024
a1aa6ee
Bump Verify.Xunit from 25.0.1 to 25.0.2
dependabot[bot] Jun 11, 2024
c70b9a2
Merge pull request #1692 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jun 13, 2024
5261400
Bump Verify.Xunit from 25.0.2 to 25.0.3
dependabot[bot] Jun 14, 2024
5f5fa02
Bump docker/build-push-action from 5.4.0 to 6.0.0
dependabot[bot] Jun 17, 2024
62ec21b
Merge pull request #1694 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jun 18, 2024
80a02a2
Merge pull request #1696 from microsoft/dependabot/github_actions/doc…
andrueastman Jun 18, 2024
b26bd6e
Update the error message to insert the value of the referenceType
MaggieKimani1 Jun 20, 2024
71de0e0
Add a check to ascertain that the referenceType and the referencedObj…
MaggieKimani1 Jun 20, 2024
f9fc4db
Add test to validate
MaggieKimani1 Jun 20, 2024
2bb1203
Update logic to guard against null exceptions
MaggieKimani1 Jun 24, 2024
d758803
Update extensions to return null instead of throwing
MaggieKimani1 Jun 24, 2024
858e85d
Bump docker/build-push-action from 6.0.0 to 6.1.0
dependabot[bot] Jun 24, 2024
b3ddc2a
Bump Verify.Xunit from 25.0.3 to 25.0.4
dependabot[bot] Jun 24, 2024
d983c80
Merge pull request #1700 from microsoft/dependabot/github_actions/doc…
andrueastman Jun 25, 2024
bb9e5b5
Merge pull request #1701 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jun 25, 2024
8485685
Merge pull request #1697 from microsoft/mk/fix-ref-bug
MaggieKimani1 Jun 26, 2024
84e7680
Add test to validate
MaggieKimani1 Jun 26, 2024
ae79040
Merge pull request #1698 from microsoft/mk/fix-null-extension
MaggieKimani1 Jun 26, 2024
4fe5826
Update conversion library version (#1702)
irvinesunday Jun 26, 2024
e339757
Release Hidi and libs (#1690) (#1704)
irvinesunday Jun 27, 2024
f9bb190
merge
Jun 27, 2024
b3d2b32
Merge pull request #1708 from microsoft/andrueastman/fixMerge
andrueastman Jun 27, 2024
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/build-push-action@v5.4.0
uses: docker/build-push-action@v6.1.0
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@v5.4.0
uses: docker/build-push-action@v6.1.0
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 @@ -9,7 +9,7 @@
<Nullable>enable</Nullable>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.4.5</Version>
<Version>1.4.6</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand All @@ -35,7 +35,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.21.3" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.6.6" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.6.7" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.0-preview" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs
Original file line number Diff line number Diff line change
@@ -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.Collections.Generic;
Expand Down Expand Up @@ -113,16 +113,16 @@

private static IOpenApiExtension LoadExtension(string name, ParseNode node)
{
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser))
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser) && parser(
OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny()),
OpenApiSpecVersion.OpenApi2_0) is { } result)
{
return parser(
OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny()),
OpenApiSpecVersion.OpenApi2_0);
return result;
}
else
{
return OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny());
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement return - consider using '?' to express intent better.
}

private static string LoadString(ParseNode node)
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.OpenApi.Readers/V3/OpenApiV3Deserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@

private static IOpenApiExtension LoadExtension(string name, ParseNode node)
{
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser))
if (node.Context.ExtensionParsers.TryGetValue(name, out var parser) && parser(
OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny()),
OpenApiSpecVersion.OpenApi3_0) is { } result)
{
return parser(
OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny()),
OpenApiSpecVersion.OpenApi3_0);
return result;
}
else
{
return OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny());
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement return - consider using '?' to express intent better.
}

private static string LoadString(ParseNode node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// <exception cref="ArgumentOutOfRangeException">When the source element is not an object</exception>
public static OpenApiDeprecationExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiObject rawObject) return null;
var extension = new OpenApiDeprecationExtension();
if (rawObject.TryGetValue(nameof(RemovalDate).ToFirstCharacterLowerCase(), out var removalDate) && removalDate is OpenApiDateTime removalDateValue)
extension.RemovalDate = removalDateValue.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// <exception cref="ArgumentOutOfRangeException">When the source element is not an object</exception>
public static OpenApiEnumFlagsExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiObject rawObject) return null;
var extension = new OpenApiEnumFlagsExtension();
if (rawObject.TryGetValue(nameof(IsFlags).ToFirstCharacterLowerCase(), out var flagsValue) && flagsValue is OpenApiBoolean isFlags)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// <exception cref="ArgumentOutOfRangeException">When the source element is not an object</exception>
public static OpenApiEnumValuesDescriptionExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiObject rawObject) return null;
var extension = new OpenApiEnumValuesDescriptionExtension();
if (rawObject.TryGetValue("values", out var values) && values is OpenApiArray valuesArray)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// <exception cref="ArgumentOutOfRangeException">When the source element is not an object</exception>
public static OpenApiPagingExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiObject rawObject) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiObject rawObject) return null;
var extension = new OpenApiPagingExtension();
if (rawObject.TryGetValue(nameof(NextLinkName).ToFirstCharacterLowerCase(), out var nextLinkName) && nextLinkName is OpenApiString nextLinkNameStr)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
Expand Down Expand Up @@ -39,7 +39,7 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
/// <returns>The <see cref="OpenApiPrimaryErrorMessageExtension"/>.</returns>
public static OpenApiPrimaryErrorMessageExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiBoolean rawObject) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiBoolean rawObject) return null;
return new()
{
IsPrimaryErrorMessage = rawObject.Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public bool? IsReserved
/// <returns></returns>
public static OpenApiReservedParameterExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiBoolean rawBoolean) throw new ArgumentOutOfRangeException(nameof(source));
if (source is not OpenApiBoolean rawBoolean) return null;
return new()
{
IsReserved = rawBoolean.Value
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Properties/SRResource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Properties/SRResource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<value>Invalid Reference identifier '{0}'.</value>
</data>
<data name="InvalidReferenceType" xml:space="preserve">
<value>Invalid Reference Type.</value>
<value>Invalid Reference Type '{0}'.</value>
</data>
<data name="LocalReferenceRequiresType" xml:space="preserve">
<value>Local reference must have type specified.</value>
Expand Down
7 changes: 7 additions & 0 deletions src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@
{
try
{
var referencedObject = typeof(T).Name;
var referenceType = reference?.Type.ToString();
if (referenceType is not null && !referencedObject.Contains(referenceType))
{
throw new OpenApiException(string.Format(Properties.SRResource.InvalidReferenceType, referenceType));
}

return _currentDocument.ResolveReference(reference, false) as T;
}
catch (OpenApiException ex)
Expand All @@ -269,7 +276,7 @@
}
// The concept of merging references with their target at load time is going away in the next major version
// External references will not support this approach.
//else if (_resolveRemoteReferences == true)

Check warning on line 279 in src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
//{
// if (_currentDocument.Workspace == null)
// {
Expand All @@ -283,7 +290,7 @@
// }
// var target = _currentDocument.Workspace.ResolveReference(reference);

// // TODO: If it is a document fragment, then we should resolve it within the current context

Check warning on line 293 in src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

// return target as T;
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
using System.Threading;
using FluentAssertions;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers.Interface;
using Microsoft.OpenApi.Validations;
using Microsoft.OpenApi.Validations.Rules;
using Microsoft.OpenApi.Writers;
Expand Down Expand Up @@ -1355,5 +1357,15 @@ public void ValidateExampleShouldNotHaveDataTypeMismatch()
var warnings = diagnostic.Warnings;
Assert.False(warnings.Any());
}

[Fact]
public void ParseDocumetWithWrongReferenceTypeShouldReturnADiagnosticError()
{
using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "docWithWrongRef.json"));
_ = new OpenApiStreamReader().Read(stream, out var diagnostic);

diagnostic.Errors.Should().BeEquivalentTo(new List<OpenApiError> {
new( new OpenApiException("Invalid Reference Type 'Schema'.")) });
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"openapi":"3.0.0",
"info":{
"title":"some api",
"description":"some description",
"version": "1"
},
"servers":[{"url":"https://localhost"}],
"paths":{
"/count":{
"get":{
"responses":{
"200":{
"$ref":"#/components/schemas/count"
},
},
}
}
},
"components":{
"schemas":{
"count":{
"type": "number"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.1" />
<PackageReference Include="Verify.Xunit" Version="25.0.1" />
<PackageReference Include="Verify.Xunit" Version="25.0.4" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public void Parses()
Assert.NotNull(value);
Assert.True(value.IsReserved);
}

[Fact]
public void DoesNotThrowExceptionIfValueIsNull()
{
var oaiValue = new OpenApiObject
{
["foo"] = new OpenApiString("foo")
};

var value = OpenApiReservedParameterExtension.Parse(oaiValue);
Assert.Null(value);
}

[Fact]
public void Serializes()
{
Expand Down
Loading