-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from microsoft/vnext
Release v1.4.0-preview2
- Loading branch information
Showing
46 changed files
with
496 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,13 @@ jobs: | |
id: getversion | ||
- name: Push to GitHub Packages - Nightly | ||
if: ${{ github.ref == 'refs/heads/vnext' }} | ||
uses: docker/[email protected].0 | ||
uses: docker/[email protected].1 | ||
with: | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly | ||
- name: Push to GitHub Packages - Release | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
uses: docker/[email protected].0 | ||
uses: docker/[email protected].1 | ||
with: | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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 TransformCommandHandler : ICommandHandler | ||
{ | ||
public Option<string> DescriptionOption { get; set; } | ||
public Option<string> CsdlOption { get; set; } | ||
public Option<string> CsdlFilterOption { get; set; } | ||
public Option<FileInfo> OutputOption { get; set; } | ||
public Option<bool> CleanOutputOption { get; set; } | ||
public Option<string?> VersionOption { get; set; } | ||
public Option<OpenApiFormat?> FormatOption { get; set; } | ||
public Option<bool> TerseOutputOption { get; set; } | ||
public Option<LogLevel> LogLevelOption { get; set; } | ||
public Option<string> FilterByOperationIdsOption { get; set; } | ||
public Option<string> FilterByTagsOption { get; set; } | ||
public Option<string> FilterByCollectionOption { get; set; } | ||
public Option<bool> InlineLocalOption { get; set; } | ||
public Option<bool> InlineExternalOption { 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); | ||
string csdlFilter = context.ParseResult.GetValueForOption(CsdlFilterOption); | ||
string csdl = context.ParseResult.GetValueForOption(CsdlOption); | ||
FileInfo output = context.ParseResult.GetValueForOption(OutputOption); | ||
bool cleanOutput = context.ParseResult.GetValueForOption(CleanOutputOption); | ||
string? version = context.ParseResult.GetValueForOption(VersionOption); | ||
OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption); | ||
bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption); | ||
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption); | ||
bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption); | ||
bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption); | ||
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, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, 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 | ||
} | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Microsoft.OpenApi.Hidi/Handlers/ValidateCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.OpenApi.Hidi.Handlers | ||
{ | ||
internal class ValidateCommandHandler : ICommandHandler | ||
{ | ||
public Option<string> DescriptionOption { get; set; } | ||
public Option<LogLevel> LogLevelOption { 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); | ||
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption); | ||
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken)); | ||
|
||
|
||
using var loggerFactory = Logger.ConfigureLogger(logLevel); | ||
var logger = loggerFactory.CreateLogger<OpenApiService>(); | ||
try | ||
{ | ||
await OpenApiService.ValidateOpenApiDocument(openapi, logLevel, 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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.OpenApi.Hidi | ||
{ | ||
public class Logger | ||
{ | ||
public static ILoggerFactory ConfigureLogger(LogLevel logLevel) | ||
{ | ||
// Configure logger options | ||
#if DEBUG | ||
logLevel = logLevel > LogLevel.Debug ? LogLevel.Debug : logLevel; | ||
#endif | ||
|
||
return LoggerFactory.Create((builder) => | ||
{ | ||
builder | ||
.AddSimpleConsole(c => | ||
{ | ||
c.IncludeScopes = true; | ||
}) | ||
#if DEBUG | ||
.AddDebug() | ||
#endif | ||
.SetMinimumLevel(logLevel); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.