diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5efd92b..c221fd5 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v5 with: - dotnet-version: 9.x + dotnet-version: 10.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.vscode/launch.json b/.vscode/launch.json index a7b8135..d1ec525 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/bin/Debug/net9.0/CheckCloudSupport.dll", + "program": "${workspaceFolder}/src/bin/Debug/net10.0/CheckCloudSupport.dll", "args": [ "--open-api", "C:/Source/Repos/msgraph-metadata/schemas/openapi/v1.0", @@ -33,7 +33,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/bin/Debug/net9.0/CheckCloudSupport.dll", + "program": "${workspaceFolder}/src/bin/Debug/net10.0/CheckCloudSupport.dll", "args": [ "--open-api", "C:/Source/Repos/msgraph-metadata/schemas/openapi/beta", @@ -59,7 +59,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/bin/Debug/net9.0/CheckCloudSupport.dll", + "program": "${workspaceFolder}/src/bin/Debug/net10.0/CheckCloudSupport.dll", "args": [ "--help" ], diff --git a/src/CheckCloudSupport.csproj b/src/CheckCloudSupport.csproj index d1b0d1a..b19388e 100644 --- a/src/CheckCloudSupport.csproj +++ b/src/CheckCloudSupport.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 enable enable true @@ -14,10 +14,10 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Extensions/OpenApiUrlTreeNodeExtensions.cs b/src/Extensions/OpenApiUrlTreeNodeExtensions.cs index cf8e124..939484a 100644 --- a/src/Extensions/OpenApiUrlTreeNodeExtensions.cs +++ b/src/Extensions/OpenApiUrlTreeNodeExtensions.cs @@ -35,29 +35,45 @@ public static class OpenApiUrlTreeNodeExtensions OpenApiUrlTreeNode result = parentNode; foreach (var segment in pathParts) { + var segmentToMatch = segment; OpenApiUrlTreeNode? nextNode = null; - if (segment == "{id}") + if (segmentToMatch == "{id}") { nextNode = result.Children.FirstOrDefault(c => c.Value.Segment.StartsWith('{') && c.Value.Segment.EndsWith('}') && c.Value.Segment.Contains("id", StringComparison.InvariantCultureIgnoreCase)).Value; } else { - var matchNodes = result.Children.Where(c => c.Value.Segment.IsEqualIgnoringCase(segment) || - c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segment}") || - c.Value.Segment.IsEqualIgnoringCase($"{segment}()") || - c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segment}()")); + var matchNodes = result.Children.Where(c => c.Value.Segment.IsEqualIgnoringCase(segmentToMatch) || + c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segmentToMatch}") || + c.Value.Segment.IsEqualIgnoringCase($"{segmentToMatch}()") || + c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segmentToMatch}()")); + + if (matchNodes?.Count() == 0 && + segmentToMatch.StartsWith("microsoft.graph", StringComparison.InvariantCultureIgnoreCase)) + { + // OpenAPI docs sometimes leave off the "microsoft." prefix + var trimmedSegment = segmentToMatch.Replace("microsoft.", string.Empty, StringComparison.InvariantCultureIgnoreCase); + + matchNodes = result.Children.Where(c => c.Value.Segment.IsEqualIgnoringCase(trimmedSegment) || + c.Value.Segment.IsEqualIgnoringCase($"{trimmedSegment}()")); + + if (matchNodes?.Count() >= 1) + { + segmentToMatch = trimmedSegment; + } + } if (matchNodes?.Count() > 1) { var matchCount = matchNodes.Count(); } - nextNode = result.Children.FirstOrDefault(c => c.Value.Segment.IsEqualIgnoringCase(segment) || - c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segment}")).Value ?? - result.Children.FirstOrDefault(c => c.Value.Segment.IsEqualIgnoringCase($"{segment}()") || - c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segment}()")).Value; + nextNode = result.Children.FirstOrDefault(c => c.Value.Segment.IsEqualIgnoringCase(segmentToMatch) || + c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segmentToMatch}")).Value ?? + result.Children.FirstOrDefault(c => c.Value.Segment.IsEqualIgnoringCase($"{segmentToMatch}()") || + c.Value.Segment.IsEqualIgnoringCase($"{graphNamespace}.{segmentToMatch}()")).Value; } if (nextNode == null) diff --git a/test/CheckCloudSupportTests.csproj b/test/CheckCloudSupportTests.csproj index 69d624d..b459eae 100644 --- a/test/CheckCloudSupportTests.csproj +++ b/test/CheckCloudSupportTests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable