Skip to content

Commit

Permalink
Merge pull request #1120 from microsoft/vnext
Browse files Browse the repository at this point in the history
master refresh
  • Loading branch information
baywet authored Jan 17, 2023
2 parents 0381437 + 95e598b commit 60c11ad
Show file tree
Hide file tree
Showing 37 changed files with 1,136 additions and 334 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@v3.2.0
uses: docker/build-push-action@v3.3.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@v3.2.0
uses: docker/build-push-action@v3.3.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
56 changes: 56 additions & 0 deletions src/Microsoft.OpenApi.Hidi/Handlers/ShowCommandHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace Microsoft.OpenApi.Hidi.Handlers
{
internal class ShowCommandHandler : ICommandHandler
{
public Option<string> DescriptionOption { get; set; }
public Option<FileInfo> OutputOption { get; set; }
public Option<LogLevel> LogLevelOption { get; set; }
public Option<string> CsdlOption { get; set; }
public Option<string> CsdlFilterOption { get; set; }


public int Invoke(InvocationContext context)
{
return InvokeAsync(context).GetAwaiter().GetResult();
}
public async Task<int> InvokeAsync(InvocationContext context)
{
string openapi = context.ParseResult.GetValueForOption(DescriptionOption);
FileInfo output = context.ParseResult.GetValueForOption(OutputOption);
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
string csdlFilter = context.ParseResult.GetValueForOption(CsdlFilterOption);
string csdl = context.ParseResult.GetValueForOption(CsdlOption);
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));

using var loggerFactory = Logger.ConfigureLogger(logLevel);
var logger = loggerFactory.CreateLogger<OpenApiService>();
try
{
await OpenApiService.ShowOpenApiDocument(openapi, csdl, csdlFilter, output, logger, cancellationToken);

return 0;
}
catch (Exception ex)
{
#if DEBUG
logger.LogCritical(ex, ex.Message);
throw; // so debug tools go straight to the source of the exception when attached
#else
logger.LogCritical( ex.Message);
return 1;
#endif
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ public async Task<int> InvokeAsync(InvocationContext context)
string filterbyoperationids = context.ParseResult.GetValueForOption(FilterByOperationIdsOption);
string filterbytags = context.ParseResult.GetValueForOption(FilterByTagsOption);
string filterbycollection = context.ParseResult.GetValueForOption(FilterByCollectionOption);

CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));

using var loggerFactory = Logger.ConfigureLogger(logLevel);
var logger = loggerFactory.CreateLogger<OpenApiService>();
try
{
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, settingsFile, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken);
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, settingsFile, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, logger, cancellationToken);

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
var logger = loggerFactory.CreateLogger<OpenApiService>();
try
{
await OpenApiService.ValidateOpenApiDocument(openapi, logLevel, cancellationToken);
await OpenApiService.ValidateOpenApiDocument(openapi, logger, cancellationToken);
return 0;
}
catch (Exception ex)
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand All @@ -42,8 +42,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.5" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.2.0-preview8" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.14.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.2.0-preview9" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 60c11ad

Please sign in to comment.