Skip to content

Commit

Permalink
Merge pull request #1482 from microsoft/vnext
Browse files Browse the repository at this point in the history
Release Hidi & libs
  • Loading branch information
MaggieKimani1 authored Nov 22, 2023
2 parents aab3d82 + 9037ca4 commit 7387007
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 36 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@v5.0.0
uses: docker/build-push-action@v5.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.0.0
uses: docker/build-push-action@v5.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<ItemGroup>
<PackageReference
Condition="!$(MSBuildProjectName.EndsWith('Tests'))"
Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>
</Project>
10 changes: 5 additions & 5 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.3.5</Version>
<Version>1.3.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 @@ -29,10 +29,10 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<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.18.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.5.0-preview9" />
Expand Down
11 changes: 8 additions & 3 deletions src/Microsoft.OpenApi.Hidi/Utilities/SettingsUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.OData;

Expand All @@ -11,15 +12,19 @@ internal static class SettingsUtilities
internal static IConfiguration GetConfiguration(string? settingsFile = null)
{
if (string.IsNullOrEmpty(settingsFile))
{
settingsFile = "appsettings.json";
}

var settingsFilePath = Path.Combine(Directory.GetCurrentDirectory(), settingsFile);

IConfiguration config = new ConfigurationBuilder()
.AddJsonFile(settingsFile, true)
.Build();
.AddJsonFile(settingsFilePath, true)
.Build();

return config;
}

internal static OpenApiConvertSettings GetOpenApiConvertSettings(IConfiguration config, string? metadataVersion)
{
if (config == null) { throw new System.ArgumentNullException(nameof(config)); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.6.10</Version>
<Version>1.6.11</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand Down
35 changes: 35 additions & 0 deletions src/Microsoft.OpenApi.Readers/ParseNodes/ParserHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Globalization;

namespace Microsoft.OpenApi.Readers.ParseNodes
{
/// <summary>
/// Useful tools to parse data
/// </summary>
internal class ParserHelper
{
/// <summary>
/// Parses decimal in invariant culture.
/// If the decimal is too big or small, it returns the default value
///
/// Note: sometimes developers put Double.MaxValue or Long.MaxValue as min/max values for numbers in json schema even if their numbers are not expected to be that big/small.
/// As we have already released the library with Decimal type for Max/Min, let's not introduce the breaking change and just fallback to Decimal.Max / Min. This should satisfy almost every scenario.
/// We can revisit this if somebody really needs to have double or long here.
/// </summary>
/// <returns></returns>
public static decimal ParseDecimalWithFallbackOnOverflow(string value, decimal defaultValue)
{
try
{
return decimal.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
}
catch (OverflowException)
{
return defaultValue;
}
}
}
}
6 changes: 3 additions & 3 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiHeaderDeserializer.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;
Expand Down Expand Up @@ -44,15 +44,15 @@ internal static partial class OpenApiV2Deserializer
},
{
"maximum",
(o, n) => GetOrCreateSchema(o).Maximum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture)
(o, n) => GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue)
},
{
"exclusiveMaximum",
(o, n) => GetOrCreateSchema(o).ExclusiveMaximum = bool.Parse(n.GetScalarValue())
},
{
"minimum",
(o, n) => GetOrCreateSchema(o).Minimum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture)
(o, n) => GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue)
},
{
"exclusiveMinimum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ internal static partial class OpenApiV2Deserializer
},
{
"minimum",
(o, n) => GetOrCreateSchema(o).Minimum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture)
(o, n) => GetOrCreateSchema(o).Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue)
},
{
"maximum",
(o, n) => GetOrCreateSchema(o).Maximum = decimal.Parse(n.GetScalarValue(), CultureInfo.InvariantCulture)
(o, n) => GetOrCreateSchema(o).Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue)
},
{
"maxLength",
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ internal static partial class OpenApiV2Deserializer
},
{
"maximum",
(o, n) => o.Maximum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture)
(o, n) => o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue)
},
{
"exclusiveMaximum",
(o, n) => o.ExclusiveMaximum = bool.Parse(n.GetScalarValue())
},
{
"minimum",
(o, n) => o.Minimum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture)
(o, n) => o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue)
},
{
"exclusiveMinimum",
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ internal static partial class OpenApiV3Deserializer
},
{
"maximum",
(o, n) => o.Maximum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture)
(o, n) => o.Maximum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MaxValue)
},
{
"exclusiveMaximum",
(o, n) => o.ExclusiveMaximum = bool.Parse(n.GetScalarValue())
},
{
"minimum",
(o, n) => o.Minimum = decimal.Parse(n.GetScalarValue(), NumberStyles.Float, CultureInfo.InvariantCulture)
(o, n) => o.Minimum = ParserHelper.ParseDecimalWithFallbackOnOverflow(n.GetScalarValue(), decimal.MinValue)
},
{
"exclusiveMinimum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.5" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.0" />
</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 @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>Latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.6.10</Version>
<Version>1.6.11</Version>
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public OpenApiFilterServiceTests()
[InlineData(null, "users.user", 2)]
[InlineData(null, "applications.application", 1)]
[InlineData(null, "reports.Functions", 2)]
public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string operationIds, string tags, int expectedPathCount)
public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string? operationIds, string? tags, int expectedPathCount)
{
// Act
var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags);
Expand Down Expand Up @@ -173,7 +173,7 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments
[Theory]
[InlineData("reports.getTeamsUserActivityUserDetail-a3f1", null)]
[InlineData(null, "reports.Functions")]
public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string operationIds, string tags)
public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string? operationIds, string? tags)
{
// Act
var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task ReturnConvertedCSDLFile()
[InlineData("Todos.Todo.UpdateTodo", null, 1)]
[InlineData("Todos.Todo.ListTodo", null, 1)]
[InlineData(null, "Todos.Todo", 5)]
public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount)
public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string? operationIds, string? tags, int expectedPathCount)
{
// Arrange
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "Todo.xml");
Expand All @@ -68,7 +68,7 @@ public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocumen
[Theory]
[InlineData("UtilityFiles/appsettingstest.json")]
[InlineData(null)]
public void ReturnOpenApiConvertSettingsWhenSettingsFileIsProvided(string filePath)
public void ReturnOpenApiConvertSettingsWhenSettingsFileIsProvided(string? filePath)
{
// Arrange
var config = SettingsUtilities.GetConfiguration(filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using Microsoft.OpenApi.Readers.ParseNodes;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.ParseNodes
{
[Collection("DefaultSettings")]
public class ParserHelperTests
{
[Fact]
public void ParseDecimalWithFallbackOnOverflow_ReturnsParsedValue()
{
Assert.Equal(23434, ParserHelper.ParseDecimalWithFallbackOnOverflow("23434", 10));
}

[Fact]
public void ParseDecimalWithFallbackOnOverflow_Overflows_ReturnsFallback()
{
Assert.Equal(10, ParserHelper.ParseDecimalWithFallbackOnOverflow(double.MaxValue.ToString(), 10));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="Verify.Xunit" Version="22.2.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
<PackageReference Include="Verify.Xunit" Version="22.5.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
</ItemGroup>
Expand Down

0 comments on commit 7387007

Please sign in to comment.