Skip to content

Commit 77bdafe

Browse files
Merge branch 'vnext' into mk/add-push-trigger-filter
2 parents e95833a + 0834f1f commit 77bdafe

File tree

14 files changed

+85
-39
lines changed

14 files changed

+85
-39
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ steps:
3030
inputs:
3131
testAssemblyVer2: |
3232
**\*.Tests.dll
33-
33+
3434
vsTestVersion: 16.0
3535
codeCoverageEnabled: true
3636

@@ -94,6 +94,13 @@ steps:
9494
configuration: Release
9595
msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg'
9696

97+
- task: MSBuild@1
98+
displayName: 'Pack OpenApi Hidi'
99+
inputs:
100+
solution: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
101+
configuration: Release
102+
msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg'
103+
97104
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
98105
displayName: 'ESRP CodeSigning Nuget Packages'
99106
inputs:

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
$projectsArray = @(
6363
'.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj',
6464
'.\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj',
65-
'.\src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj'
65+
'.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj'
6666
)
6767
$gitNewVersion = if ("${{ steps.tag_generator.outputs.new_version }}") {"${{ steps.tag_generator.outputs.new_version }}"} else {$null}
6868
$projectCurrentVersion = ([xml](Get-Content .\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj)).Project.PropertyGroup.Version

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
$projectsArray = @(
3535
'.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj',
3636
'.\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj',
37-
'.\src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj'
37+
'.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj'
3838
)
3939
4040
$projectsArray | ForEach-Object {

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Tool/bin/Debug/netcoreapp3.1/Microsoft.OpenApi.Tool.dll",
13+
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/netcoreapp3.1/Microsoft.OpenApi.Hidi.dll",
1414
"args": [],
15-
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Tool",
15+
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
1717
"console": "internalConsole",
1818
"stopAtEntry": false

Microsoft.OpenApi.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2
2626
EndProject
2727
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}"
2828
EndProject
29-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Tool", "src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}"
3030
EndProject
3131
Global
3232
GlobalSection(SolutionConfigurationPlatforms) = preSolution

build.cmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@echo off
2-
Echo Building Microsoft.OpenApi
2+
Echo Building Microsoft.OpenApi
33

4-
SET PROJ=%~dp0src\Microsoft.OpenApi\Microsoft.OpenApi.csproj
4+
SET PROJ=%~dp0src\Microsoft.OpenApi\Microsoft.OpenApi.csproj
55
dotnet msbuild %PROJ% /t:restore /p:Configuration=Release
66
dotnet msbuild %PROJ% /t:build /p:Configuration=Release
77
dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
88

99
Echo Building Microsoft.OpenApi.Readers
1010

11-
SET PROJ=%~dp0src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj
11+
SET PROJ=%~dp0src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj
1212
dotnet msbuild %PROJ% /t:restore /p:Configuration=Release
1313
dotnet msbuild %PROJ% /t:build /p:Configuration=Release
1414
dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
1515

16-
Echo Building Microsoft.OpenApi.Tool
16+
Echo Building Microsoft.OpenApi.Hidi
1717

18-
SET PROJ=%~dp0src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj
18+
SET PROJ=%~dp0src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj
1919
dotnet msbuild %PROJ% /t:restore /p:Configuration=Release
2020
dotnet msbuild %PROJ% /t:build /p:Configuration=Release
2121
dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts

install-tool.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
$latest = Get-ChildItem .\artifacts\ Microsoft.OpenApi.Tool* | select-object -Last 1
1+
$latest = Get-ChildItem .\artifacts\Microsoft.OpenApi.Hidi* | select-object -Last 1
22
$version = $latest.Name.Split(".")[3..5] | join-string -Separator "."
33

4-
if (Test-Path -Path ./artifacts/openapi-parser.exe) {
5-
dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Tool
4+
if (Test-Path -Path ./artifacts/hidi.exe) {
5+
dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Hidi
66
}
7-
dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Tool
7+
dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Hidi

src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj renamed to src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<PackAsTool>true</PackAsTool>
7-
<ToolCommandName>openapi-parser</ToolCommandName>
7+
<ToolCommandName>hidi</ToolCommandName>
88
<PackageOutputPath>./../../artifacts</PackageOutputPath>
9-
<Version>1.3.0-preview</Version>
9+
<Version>0.5.0-preview</Version>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

src/Microsoft.OpenApi.Tool/OpenApiService.cs renamed to src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using Microsoft.OpenApi.Validations;
1515
using Microsoft.OpenApi.Writers;
1616

17-
namespace Microsoft.OpenApi.Tool
17+
namespace Microsoft.OpenApi.Hidi
1818
{
1919
static class OpenApiService
2020
{
@@ -24,6 +24,7 @@ public static void ProcessOpenApiDocument(
2424
OpenApiSpecVersion version,
2525
OpenApiFormat format,
2626
string filterByOperationIds,
27+
string filterByTags,
2728
bool inline,
2829
bool resolveExternal)
2930
{
@@ -52,9 +53,19 @@ public static void ProcessOpenApiDocument(
5253
document = result.OpenApiDocument;
5354

5455
// Check if filter options are provided, then execute
56+
if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags))
57+
{
58+
throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time.");
59+
}
60+
5561
if (!string.IsNullOrEmpty(filterByOperationIds))
5662
{
57-
var predicate = OpenApiFilterService.CreatePredicate(filterByOperationIds);
63+
var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds);
64+
document = OpenApiFilterService.CreateFilteredDocument(document, predicate);
65+
}
66+
if (!string.IsNullOrEmpty(filterByTags))
67+
{
68+
var predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags);
5869
document = OpenApiFilterService.CreateFilteredDocument(document, predicate);
5970
}
6071

src/Microsoft.OpenApi.Tool/Program.cs renamed to src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.IO;
77
using System.Threading.Tasks;
88

9-
namespace Microsoft.OpenApi.Tool
9+
namespace Microsoft.OpenApi.Hidi
1010
{
1111
static class Program
1212
{
@@ -29,9 +29,10 @@ static async Task<int> Main(string[] args)
2929
new Option("--format", "File format",typeof(OpenApiFormat) ),
3030
new Option("--inline", "Inline $ref instances", typeof(bool) ),
3131
new Option("--resolveExternal","Resolve external $refs", typeof(bool)),
32-
new Option("--filterByOperationIds", "Filters by OperationId provided", typeof(string))
32+
new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)),
33+
new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string))
3334
};
34-
transformCommand.Handler = CommandHandler.Create<string, FileInfo, OpenApiSpecVersion, OpenApiFormat, string, bool, bool>(
35+
transformCommand.Handler = CommandHandler.Create<string, FileInfo, OpenApiSpecVersion, OpenApiFormat, string, string, bool, bool>(
3536
OpenApiService.ProcessOpenApiDocument);
3637

3738
rootCommand.Add(transformCommand);

0 commit comments

Comments
 (0)