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

Release libs. #1846

Merged
merged 31 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ad775b2
Add stub test to support trailing slashes
mderriey Mar 6, 2024
35398a1
Attempt at supporting trailing slashes
mderriey Mar 6, 2024
996407c
Ensure leaf nodes have no children
mderriey Mar 7, 2024
7fa2f2c
Add `StringComparison.OrdinalIgnoreCase`
mderriey Mar 11, 2024
6fd6884
Bump Verify.Xunit from 26.3.1 to 26.4.0 (#1825)
dependabot[bot] Sep 5, 2024
102c705
Bump Microsoft.NET.Test.Sdk from 17.11.0 to 17.11.1 (#1824)
dependabot[bot] Sep 5, 2024
82707ad
Bump Moq from 4.20.71 to 4.20.72
dependabot[bot] Sep 9, 2024
fcb316e
Merge pull request #1829 from microsoft/dependabot/nuget/Moq-4.20.72
andrueastman Sep 10, 2024
ba426af
Bump Verify.Xunit from 26.4.0 to 26.4.4
dependabot[bot] Sep 10, 2024
b9d2068
Bump FluentAssertions from 6.12.0 to 6.12.1
dependabot[bot] Sep 10, 2024
e026c58
Merge pull request #1828 from microsoft/dependabot/nuget/FluentAssert…
andrueastman Sep 10, 2024
11925be
Merge pull request #1830 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Sep 10, 2024
eb33299
Bump Verify.Xunit from 26.4.4 to 26.4.5 (#1831)
dependabot[bot] Sep 15, 2024
2e6b4b5
Updated for https://dev.azure.com/microsoftgraph/0985d294-5762-4bc2-a…
microsoft-github-policy-service[bot] Sep 15, 2024
97e43b6
Bump Verify.Xunit from 26.4.5 to 26.5.0 (#1834)
dependabot[bot] Sep 18, 2024
e18748f
Align on backslashes
chelkyl Sep 22, 2024
5b22ef4
Bump Verify.Xunit from 26.5.0 to 26.6.0
dependabot[bot] Sep 23, 2024
67a47c6
Merge pull request #1836 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Sep 24, 2024
def1b87
Bump xunit from 2.9.0 to 2.9.1
dependabot[bot] Sep 24, 2024
faa13eb
Merge pull request #1837 from microsoft/dependabot/nuget/xunit-2.9.1
andrueastman Sep 24, 2024
ff22ab9
Merge pull request #1835 from chelkyl/chelkyl/support-trailing-slashes
MaggieKimani1 Sep 25, 2024
8c0cf47
Bump lib versions
irvinesunday Sep 27, 2024
f7f184d
Update test
irvinesunday Sep 27, 2024
c2d3f99
Ensure unique parameters are added
irvinesunday Sep 27, 2024
d88a060
Bump xunit from 2.9.1 to 2.9.2
dependabot[bot] Sep 27, 2024
776d584
Merge pull request #1842 from microsoft/dependabot/nuget/xunit-2.9.2
andrueastman Sep 30, 2024
e035981
Merge pull request #1841 from microsoft/is/filtered-doc-fix
fey101 Sep 30, 2024
310b999
Merge branch 'vnext' into is/resolve-conflicts
irvinesunday Sep 30, 2024
1123e29
Merge pull request #1844 from microsoft/is/resolve-conflicts
irvinesunday Sep 30, 2024
dc6fee7
Bump readers lib.
irvinesunday Sep 30, 2024
9754cd1
Merge pull request #1845 from microsoft/is/bump-readers-lib
irvinesunday Sep 30, 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
15 changes: 15 additions & 0 deletions .config/1espt/PipelineAutobaseliningConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## DO NOT MODIFY THIS FILE MANUALLY. This is part of auto-baselining from 1ES Pipeline Templates. Go to [https://aka.ms/1espt-autobaselining] for more details.

pipelines:
107:
usedNonDefaultBranch: true
retail:
source:
credscan:
lastModifiedDate: 2024-09-13
eslint:
lastModifiedDate: 2024-09-13
psscriptanalyzer:
lastModifiedDate: 2024-09-13
armory:
lastModifiedDate: 2024-09-13
2 changes: 1 addition & 1 deletion 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.9</Version>
<Version>1.4.10</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 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.21</Version>
<Version>1.6.22</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
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.21</Version>
<Version>1.6.22</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
5 changes: 4 additions & 1 deletion src/Microsoft.OpenApi/Services/OpenApiFilterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@

if (result.Parameters?.Any() ?? false)
{
foreach (var parameter in result.Parameters)
{
pathItem.Parameters.Add(parameter);
if (!pathItem.Parameters.Contains(parameter))
{
pathItem.Parameters.Add(parameter);
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Microsoft.OpenApi/Services/OpenApiUrlTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ public OpenApiUrlTreeNode Attach(string path,
}

var segments = path.Split('/');
if (path.EndsWith("/", StringComparison.OrdinalIgnoreCase))
{
// Remove the last element, which is empty, and append the trailing slash to the new last element
// This is to support URLs with trailing slashes
Array.Resize(ref segments, segments.Length - 1);
segments[segments.Length - 1] += @"\";
}

return Attach(segments: segments,
pathItem: pathItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Moq" Version="4.20.71" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
</ItemGroup>
Expand Down
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 Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -105,6 +105,57 @@ public void TestPredicateFiltersUsingRelativeRequestUrls()
Assert.False(predicate("/foo", OperationType.Patch, null));
}

[Fact]
public void CreateFilteredDocumentUsingPredicateFromRequestUrl()
{
// Arrange
var openApiDocument = new OpenApiDocument
{
Info = new() { Title = "Test", Version = "1.0" },
Servers = new List<OpenApiServer> { new() { Url = "https://localhost/" } },
Paths = new()
{
["/test/{id}"] = new()
{
Operations = new Dictionary<OperationType, OpenApiOperation>
{
{ OperationType.Get, new() },
{ OperationType.Patch, new() }
},
Parameters = new List<OpenApiParameter>
{
new()
{
Name = "id",
In = ParameterLocation.Path,
Required = true,
Schema = new()
{
Type = "string"
}
}
}
}


}
};

var requestUrls = new Dictionary<string, List<string>>
{
{"/test/{id}", new List<string> {"GET","PATCH"}}
};

// Act
var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: openApiDocument);
var subsetDoc = OpenApiFilterService.CreateFilteredDocument(openApiDocument, predicate);

// Assert that there's only 1 parameter in the subset document
Assert.NotNull(subsetDoc);
Assert.NotEmpty(subsetDoc.Paths);
Assert.Single(subsetDoc.Paths.First().Value.Parameters);
}

[Fact]
public void ShouldParseNestedPostmanCollection()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
<!--STJ required until Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Configuration.Json update their dependencies -->
<PackageReference Include="System.Text.Json" Version="8.0.4" />
Expand Down
10 changes: 5 additions & 5 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="all" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Moq" Version="4.20.71" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpYaml" Version="2.1.1" />
<PackageReference Include="Verify.Xunit" Version="26.3.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Verify.Xunit" Version="26.6.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,5 +466,38 @@ public async Task VerifyDiagramFromSampleOpenAPIAsync()

await Verifier.Verify(diagram);
}

public static TheoryData<string, string[], string, string> SupportsTrailingSlashesInPathData => new TheoryData<string, string[], string, string>
{
// Path, children up to second to leaf, last expected leaf node name, expected leaf node path
{ "/cars/{car-id}/build/", ["cars", "{car-id}"], @"build\", @"\cars\{car-id}\build\" },
{ "/cars/", [], @"cars\", @"\cars\" },
};

[Theory]
[MemberData(nameof(SupportsTrailingSlashesInPathData))]
public void SupportsTrailingSlashesInPath(string path, string[] childrenBeforeLastNode, string expectedLeafNodeName, string expectedLeafNodePath)
{
var openApiDocument = new OpenApiDocument
{
Paths = new()
{
[path] = new()
}
};

var label = "trailing-slash";
var rootNode = OpenApiUrlTreeNode.Create(openApiDocument, label);

var secondToLeafNode = rootNode;
foreach (var childName in childrenBeforeLastNode)
{
secondToLeafNode = secondToLeafNode.Children[childName];
}

Assert.True(secondToLeafNode.Children.TryGetValue(expectedLeafNodeName, out var leafNode));
Assert.Equal(expectedLeafNodePath, leafNode.Path);
Assert.Empty(leafNode.Children);
}
}
}
Loading