Skip to content

Commit 9c0fa21

Browse files
committed
Merge branch 'vnext' into mk/enhancement-create-hash-code
2 parents f9a32fa + c1b173e commit 9c0fa21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+660
-304
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ stages:
266266
echo "$artifactName"
267267
echo "$artifactVersion"
268268
displayName: 'Fetch Artifact Name'
269-
270269
- task: NuGetCommand@2
271270
displayName: 'NuGet push'
272271
inputs:
@@ -276,6 +275,7 @@ stages:
276275
publishFeedCredentials: 'OpenAPI Nuget Connection'
277276
- task: GitHubRelease@1
278277
displayName: 'GitHub release (edit)'
278+
condition: succeededOrFailed()
279279
inputs:
280280
gitHubConnection: 'Github-MaggieKimani1'
281281
action: edit

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the current behavior:
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Screenshots/Code Snippets**
20+
If applicable, add screenshots of the stack trace or a code snippet to help explain your problem.
21+
If applicable, add a link to your project
22+
23+
**Additional context**
24+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is.
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
id: getversion
3131
- name: Push to GitHub Packages - Nightly
3232
if: ${{ github.ref == 'refs/heads/vnext' }}
33-
uses: docker/[email protected].0
33+
uses: docker/[email protected].1
3434
with:
3535
push: true
3636
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
3737
- name: Push to GitHub Packages - Release
3838
if: ${{ github.ref == 'refs/heads/master' }}
39-
uses: docker/[email protected].0
39+
uses: docker/[email protected].1
4040
with:
4141
push: true
4242
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0-preview-20220612-01" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
1313
<PackageReference Include="Moq" Version="4.18.2" />
1414
<PackageReference Include="xunit" Version="2.4.2" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Project Objectives
2121

2222
# Installation
2323

24-
- Install core Nuget package `Microsoft.OpenApi`
25-
- Install readers Nuget package `Microsoft.OpenApi.Readers`
24+
- Install core Nuget package [**Microsoft.OpenApi**](https://www.nuget.org/packages/Microsoft.OpenApi)
25+
- Install readers Nuget package [**Microsoft.OpenApi.Readers**](https://www.nuget.org/packages/Microsoft.OpenApi.Readers)
2626

2727
# Processors
2828
The OpenAPI.NET project holds the base object model for representing OpenAPI documents as .NET objects. Some developers have found the need to write processors that convert other data formats into this OpenAPI.NET object model. We'd like to curate that list of processors in this section of the readme.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
using System.CommandLine;
6+
using System.CommandLine.Invocation;
7+
using System.IO;
8+
using System.Threading;
9+
using System.Threading.Tasks;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace Microsoft.OpenApi.Hidi.Handlers
13+
{
14+
internal class TransformCommandHandler : ICommandHandler
15+
{
16+
public Option<string> DescriptionOption { get; set; }
17+
public Option<string> CsdlOption { get; set; }
18+
public Option<string> CsdlFilterOption { get; set; }
19+
public Option<FileInfo> OutputOption { get; set; }
20+
public Option<bool> CleanOutputOption { get; set; }
21+
public Option<string?> VersionOption { get; set; }
22+
public Option<OpenApiFormat?> FormatOption { get; set; }
23+
public Option<bool> TerseOutputOption { get; set; }
24+
public Option<LogLevel> LogLevelOption { get; set; }
25+
public Option<string> FilterByOperationIdsOption { get; set; }
26+
public Option<string> FilterByTagsOption { get; set; }
27+
public Option<string> FilterByCollectionOption { get; set; }
28+
public Option<bool> InlineLocalOption { get; set; }
29+
public Option<bool> InlineExternalOption { get; set; }
30+
31+
public int Invoke(InvocationContext context)
32+
{
33+
return InvokeAsync(context).GetAwaiter().GetResult();
34+
}
35+
public async Task<int> InvokeAsync(InvocationContext context)
36+
{
37+
string openapi = context.ParseResult.GetValueForOption(DescriptionOption);
38+
string csdlFilter = context.ParseResult.GetValueForOption(CsdlFilterOption);
39+
string csdl = context.ParseResult.GetValueForOption(CsdlOption);
40+
FileInfo output = context.ParseResult.GetValueForOption(OutputOption);
41+
bool cleanOutput = context.ParseResult.GetValueForOption(CleanOutputOption);
42+
string? version = context.ParseResult.GetValueForOption(VersionOption);
43+
OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption);
44+
bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption);
45+
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
46+
bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption);
47+
bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption);
48+
string filterbyoperationids = context.ParseResult.GetValueForOption(FilterByOperationIdsOption);
49+
string filterbytags = context.ParseResult.GetValueForOption(FilterByTagsOption);
50+
string filterbycollection = context.ParseResult.GetValueForOption(FilterByCollectionOption);
51+
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));
52+
53+
using var loggerFactory = Logger.ConfigureLogger(logLevel);
54+
var logger = loggerFactory.CreateLogger<OpenApiService>();
55+
try
56+
{
57+
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken);
58+
59+
return 0;
60+
}
61+
catch (Exception ex)
62+
{
63+
#if DEBUG
64+
logger.LogCritical(ex, ex.Message);
65+
throw; // so debug tools go straight to the source of the exception when attached
66+
#else
67+
logger.LogCritical( ex.Message);
68+
return 1;
69+
#endif
70+
}
71+
}
72+
}
73+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
using System.CommandLine;
6+
using System.CommandLine.Invocation;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace Microsoft.OpenApi.Hidi.Handlers
12+
{
13+
internal class ValidateCommandHandler : ICommandHandler
14+
{
15+
public Option<string> DescriptionOption { get; set; }
16+
public Option<LogLevel> LogLevelOption { get; set; }
17+
18+
public int Invoke(InvocationContext context)
19+
{
20+
return InvokeAsync(context).GetAwaiter().GetResult();
21+
}
22+
public async Task<int> InvokeAsync(InvocationContext context)
23+
{
24+
string openapi = context.ParseResult.GetValueForOption(DescriptionOption);
25+
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
26+
CancellationToken cancellationToken = (CancellationToken)context.BindingContext.GetService(typeof(CancellationToken));
27+
28+
29+
using var loggerFactory = Logger.ConfigureLogger(logLevel);
30+
var logger = loggerFactory.CreateLogger<OpenApiService>();
31+
try
32+
{
33+
await OpenApiService.ValidateOpenApiDocument(openapi, logLevel, cancellationToken);
34+
return 0;
35+
}
36+
catch (Exception ex)
37+
{
38+
#if DEBUG
39+
logger.LogCritical(ex, ex.Message);
40+
throw; // so debug tools go straight to the source of the exception when attached
41+
#else
42+
logger.LogCritical( ex.Message);
43+
return 1;
44+
#endif
45+
}
46+
}
47+
}
48+
}

src/Microsoft.OpenApi.Hidi/Logger.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace Microsoft.OpenApi.Hidi
7+
{
8+
public class Logger
9+
{
10+
public static ILoggerFactory ConfigureLogger(LogLevel logLevel)
11+
{
12+
// Configure logger options
13+
#if DEBUG
14+
logLevel = logLevel > LogLevel.Debug ? LogLevel.Debug : logLevel;
15+
#endif
16+
17+
return LoggerFactory.Create((builder) =>
18+
{
19+
builder
20+
.AddSimpleConsole(c =>
21+
{
22+
c.IncludeScopes = true;
23+
})
24+
#if DEBUG
25+
.AddDebug()
26+
#endif
27+
.SetMinimumLevel(logLevel);
28+
});
29+
}
30+
}
31+
}

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
4242
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
4343
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
44-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
45-
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.1" />
44+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
45+
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.2" />
4646
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11" />
4747
</ItemGroup>
4848

0 commit comments

Comments
 (0)