Skip to content

Commit 656ac9a

Browse files
Merge pull request #1084 from microsoft/vnext
Release libs
2 parents 1b02c01 + cbafb8c commit 656ac9a

File tree

23 files changed

+194
-51
lines changed

23 files changed

+194
-51
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ stages:
3131
- job: build
3232
steps:
3333
- task: UseDotNet@2
34-
displayName: 'Use .NET 6'
34+
displayName: 'Use .NET 2' # needed for ESRP signing
3535
inputs:
36-
version: 6.x
36+
version: 2.x
37+
38+
- task: UseDotNet@2
39+
displayName: 'Use .NET 7'
40+
inputs:
41+
version: 7.x
3742

3843
- task: PoliCheck@1
3944
displayName: 'Run PoliCheck "/src"'

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET
1717
uses: actions/setup-dotnet@v3
1818
with:
19-
dotnet-version: 6.0.x
19+
dotnet-version: 7.0.x
2020

2121
- name: Data gatherer
2222
id: data_gatherer
@@ -49,7 +49,7 @@ jobs:
4949
- if: steps.conditionals_handler.outputs.is_default_branch == 'true'
5050
name: Bump GH tag
5151
id: tag_generator
52-
uses: mathieudutour/github-tag-action@v6.0
52+
uses: mathieudutour/github-tag-action@v6.1
5353
with:
5454
github_token: ${{ secrets.GITHUB_TOKEN }}
5555
default_bump: false

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v3
2121
with:
22-
dotnet-version: 6.0.x
22+
dotnet-version: 7.0.x
2323

2424
- name: Initialize CodeQL
2525
id: init_codeql

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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.Hidi/bin/Debug/net6.0/Microsoft.OpenApi.Hidi.dll",
13+
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll",
1414
"args": [],
1515
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
22
WORKDIR /app
33

44
COPY ./src ./hidi/src
55
WORKDIR /app/hidi
66
RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release
77

8-
FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime
8+
FROM mcr.microsoft.com/dotnet/runtime:7.0 as runtime
99
WORKDIR /app
1010

11-
COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net6.0 ./
11+
COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net7.0 ./
1212

1313
VOLUME /app/output
1414
VOLUME /app/openapi.yml

src/Microsoft.OpenApi.Hidi/Handlers/TransformCommandHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ internal class TransformCommandHandler : ICommandHandler
2121
public Option<string?> VersionOption { get; set; }
2222
public Option<OpenApiFormat?> FormatOption { get; set; }
2323
public Option<bool> TerseOutputOption { get; set; }
24+
public Option<string> SettingsFileOption { get; set; }
2425
public Option<LogLevel> LogLevelOption { get; set; }
2526
public Option<string> FilterByOperationIdsOption { get; set; }
2627
public Option<string> FilterByTagsOption { get; set; }
@@ -42,6 +43,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
4243
string? version = context.ParseResult.GetValueForOption(VersionOption);
4344
OpenApiFormat? format = context.ParseResult.GetValueForOption(FormatOption);
4445
bool terseOutput = context.ParseResult.GetValueForOption(TerseOutputOption);
46+
string settingsFile = context.ParseResult.GetValueForOption(SettingsFileOption);
4547
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
4648
bool inlineLocal = context.ParseResult.GetValueForOption(InlineLocalOption);
4749
bool inlineExternal = context.ParseResult.GetValueForOption(InlineExternalOption);
@@ -54,7 +56,7 @@ public async Task<int> InvokeAsync(InvocationContext context)
5456
var logger = loggerFactory.CreateLogger<OpenApiService>();
5557
try
5658
{
57-
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken);
59+
await OpenApiService.TransformOpenApiDocument(openapi, csdl, csdlFilter, output, cleanOutput, version, format, terseOutput, settingsFile, logLevel, inlineLocal, inlineExternal, filterbyoperationids, filterbytags, filterbycollection, cancellationToken);
5860

5961
return 0;
6062
}

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
<LangVersion>9.0</LangVersion>
77
<PackAsTool>true</PackAsTool>
88
<PackageIconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</PackageIconUrl>
@@ -15,7 +15,7 @@
1515
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
1616
<ToolCommandName>hidi</ToolCommandName>
1717
<PackageOutputPath>./../../artifacts</PackageOutputPath>
18-
<Version>1.1.0-preview3</Version>
18+
<Version>1.1.0</Version>
1919
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
2020
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2121
<PackageTags>OpenAPI .NET</PackageTags>
@@ -37,18 +37,27 @@
3737
</ItemGroup>
3838

3939
<ItemGroup>
40-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
41-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
42-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
43-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
40+
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
41+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
42+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
43+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
4444
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
45-
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.4" />
46-
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.2.0-preview5" />
45+
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.5" />
46+
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.2.0-preview8" />
47+
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
4748
</ItemGroup>
4849

4950
<ItemGroup>
5051
<ProjectReference Include="..\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj" />
5152
<ProjectReference Include="..\Microsoft.OpenApi\Microsoft.OpenApi.csproj" />
5253
</ItemGroup>
5354

55+
<!-- Make internals available for Unit Testing -->
56+
<ItemGroup>
57+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
58+
<_Parameter1>Microsoft.OpenApi.Hidi.Tests</_Parameter1>
59+
</AssemblyAttribute>
60+
</ItemGroup>
61+
<!-- End Unit test Internals -->
62+
5463
</Project>

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
using System.Xml.Xsl;
2828
using System.Xml;
2929
using System.Reflection;
30+
using Microsoft.Extensions.Configuration;
31+
using System.Runtime.CompilerServices;
3032

3133
namespace Microsoft.OpenApi.Hidi
3234
{
@@ -44,6 +46,7 @@ public static async Task TransformOpenApiDocument(
4446
string? version,
4547
OpenApiFormat? format,
4648
bool terseOutput,
49+
string settingsFile,
4750
LogLevel logLevel,
4851
bool inlineLocal,
4952
bool inlineExternal,
@@ -98,7 +101,8 @@ CancellationToken cancellationToken
98101
stream = ApplyFilter(csdl, csdlFilter, transform);
99102
stream.Position = 0;
100103
}
101-
document = await ConvertCsdlToOpenApi(stream);
104+
105+
document = await ConvertCsdlToOpenApi(stream, settingsFile);
102106
stopwatch.Stop();
103107
logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count);
104108
}
@@ -304,25 +308,37 @@ public static async Task ValidateOpenApiDocument(
304308
}
305309
}
306310

311+
internal static IConfiguration GetConfiguration(string settingsFile)
312+
{
313+
settingsFile ??= "appsettings.json";
314+
315+
IConfiguration config = new ConfigurationBuilder()
316+
.AddJsonFile(settingsFile, true)
317+
.Build();
318+
319+
return config;
320+
}
321+
307322
/// <summary>
308323
/// Converts CSDL to OpenAPI
309324
/// </summary>
310325
/// <param name="csdl">The CSDL stream.</param>
311326
/// <returns>An OpenAPI document.</returns>
312-
public static async Task<OpenApiDocument> ConvertCsdlToOpenApi(Stream csdl)
327+
public static async Task<OpenApiDocument> ConvertCsdlToOpenApi(Stream csdl, string settingsFile = null)
313328
{
314329
using var reader = new StreamReader(csdl);
315330
var csdlText = await reader.ReadToEndAsync();
316331
var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader());
317-
332+
333+
var config = GetConfiguration(settingsFile);
318334
var settings = new OpenApiConvertSettings()
319335
{
320336
AddSingleQuotesForStringParameters = true,
321337
AddEnumDescriptionExtension = true,
322338
DeclarePathParametersOnPathItem = true,
323339
EnableKeyAsSegment = true,
324340
EnableOperationId = true,
325-
ErrorResponsesAsDefault = false,
341+
ErrorResponsesAsDefault = false,
326342
PrefixEntityTypeNameBeforeKey = true,
327343
TagDepth = 2,
328344
EnablePagination = true,
@@ -335,6 +351,8 @@ public static async Task<OpenApiDocument> ConvertCsdlToOpenApi(Stream csdl)
335351
EnableCount = true,
336352
UseSuccessStatusCodeRange = true
337353
};
354+
config.GetSection("OpenApiConvertSettings").Bind(settings);
355+
338356
OpenApiDocument document = edmModel.ConvertToOpenApi(settings);
339357

340358
document = FixReferences(document);

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
// Licensed under the MIT license.
33

44
using System.CommandLine;
5+
using System.CommandLine.Builder;
6+
using System.CommandLine.Hosting;
7+
using System.CommandLine.Parsing;
8+
59
using System.IO;
610
using System.Threading.Tasks;
11+
using Microsoft.Extensions.Configuration;
12+
using Microsoft.Extensions.Hosting;
713
using Microsoft.Extensions.Logging;
814
using Microsoft.OpenApi.Hidi.Handlers;
915

@@ -41,6 +47,9 @@ static async Task Main(string[] args)
4147
var terseOutputOption = new Option<bool>("--terse-output", "Produce terse json output");
4248
terseOutputOption.AddAlias("--to");
4349

50+
var settingsFileOption = new Option<string>("--settings-path", "The configuration file with CSDL conversion settings.");
51+
settingsFileOption.AddAlias("--sp");
52+
4453
var logLevelOption = new Option<LogLevel>("--log-level", () => LogLevel.Information, "The log level to use when logging messages to the main output.");
4554
logLevelOption.AddAlias("--ll");
4655

@@ -81,6 +90,7 @@ static async Task Main(string[] args)
8190
versionOption,
8291
formatOption,
8392
terseOutputOption,
93+
settingsFileOption,
8494
logLevelOption,
8595
filterByOperationIdsOption,
8696
filterByTagsOption,
@@ -99,6 +109,7 @@ static async Task Main(string[] args)
99109
VersionOption = versionOption,
100110
FormatOption = formatOption,
101111
TerseOutputOption = terseOutputOption,
112+
SettingsFileOption = settingsFileOption,
102113
LogLevelOption = logLevelOption,
103114
FilterByOperationIdsOption = filterByOperationIdsOption,
104115
FilterByTagsOption = filterByTagsOption,

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.4.4-preview1</Version>
13+
<Version>1.4.4</Version>
1414
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

0 commit comments

Comments
 (0)