Skip to content

Commit 5fe88e8

Browse files
authored
Merge pull request #914 from microsoft/vnext
hidi docker image release
2 parents fe8d4fa + 22308bc commit 5fe88e8

14 files changed

+173
-18
lines changed

.github/workflows/docker.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Docker image
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [master, vnext]
6+
paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
7+
env:
8+
REGISTRY: msgraphprod.azurecr.io
9+
IMAGE_NAME: public/hidi
10+
jobs:
11+
push_to_registry:
12+
environment:
13+
name: acr
14+
name: Push Docker image
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v3
19+
- name: Login to GitHub package feed
20+
uses: docker/[email protected]
21+
with:
22+
username: ${{ secrets.ACR_USERNAME }}
23+
password: ${{ secrets.ACR_PASSWORD }}
24+
registry: ${{ env.REGISTRY }}
25+
- run: |
26+
$content = [XML](Get-Content ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)
27+
$version = $content.Project.PropertyGroup.Version
28+
echo "::set-output name=version::${version}"
29+
shell: pwsh
30+
id: getversion
31+
- name: Push to GitHub Packages - Nightly
32+
if: contains(github.ref, 'refs/head/vnext')
33+
uses: docker/[email protected]
34+
with:
35+
push: true
36+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
37+
- name: Push to GitHub Packages - Release
38+
if: contains(github.ref, 'refs/head/master')
39+
uses: docker/[email protected]
40+
with:
41+
push: true
42+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
2+
WORKDIR /app
3+
4+
COPY ./src ./hidi/src
5+
WORKDIR /app/hidi
6+
RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release
7+
8+
FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime
9+
WORKDIR /app
10+
11+
COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net6.0 ./
12+
13+
VOLUME /app/output
14+
VOLUME /app/openapi.yml
15+
VOLUME /app/api.csdl
16+
VOLUME /app/collection.json
17+
ENV HIDI_CONTAINER=true DOTNET_TieredPGO=1 DOTNET_TC_QuickJitForLoops=1
18+
ENTRYPOINT ["dotnet", "Microsoft.OpenApi.Hidi.dll"]
19+
LABEL description="# Welcome to Hidi \
20+
To start transforming OpenAPI documents checkout [the getting started documentation](https://github.com/microsoft/OpenAPI.NET/tree/vnext/src/Microsoft.OpenApi.Hidi) \
21+
[Source dockerfile](https://github.com/microsoft/OpenAPI.NET/blob/vnext/Dockerfile)"

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
1616
<ToolCommandName>hidi</ToolCommandName>
1717
<PackageOutputPath>./../../artifacts</PackageOutputPath>
18-
<Version>1.0.0-preview5</Version>
18+
<Version>1.0.0-preview6</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>
2222
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
2323
<PackageReleaseNotes>
24-
- Enables discriminator values
25-
- Adds new OpenAPI convert setting, ExpandDerivedTypesNavigationProperties and sets it to false
26-
- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview2
24+
- Bumps up the Microsoft.OpenAPI library to v1.3.2
25+
- Bumps up the Microsoft.OData library to v7.12.0
26+
- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview3
2727
</PackageReleaseNotes>
2828
<AssemblyName>Microsoft.OpenApi.Hidi</AssemblyName>
2929
<RootNamespace>Microsoft.OpenApi.Hidi</RootNamespace>
@@ -46,8 +46,8 @@
4646
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
4747
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
4848
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
49-
<PackageReference Include="Microsoft.OData.Edm" Version="7.11.0" />
50-
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview2" />
49+
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.0" />
50+
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview3" />
5151
</ItemGroup>
5252

5353
<ItemGroup>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.3.1</Version>
13+
<Version>1.3.2</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>
1717
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
1818
<PackageReleaseNotes>
19-
- Publish symbols.
19+
- Fixed a bug where contact information would not read properly. #892
2020
</PackageReleaseNotes>
2121
<AssemblyName>Microsoft.OpenApi.Readers</AssemblyName>
2222
<RootNamespace>Microsoft.OpenApi.Readers</RootNamespace>
@@ -40,7 +40,7 @@
4040
</ItemGroup>
4141

4242
<ItemGroup>
43-
<PackageReference Include="SharpYaml" Version="1.9.1" />
43+
<PackageReference Include="SharpYaml" Version="1.9.2" />
4444
</ItemGroup>
4545

4646
<ItemGroup>

src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic)
3434
private IDictionary<Type, Func<ParseNode, object>> _loaders = new Dictionary<Type, Func<ParseNode, object>>
3535
{
3636
[typeof(IOpenApiAny)] = OpenApiV2Deserializer.LoadAny,
37+
[typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact,
3738
[typeof(OpenApiExternalDocs)] = OpenApiV2Deserializer.LoadExternalDocs,
3839
[typeof(OpenApiHeader)] = OpenApiV2Deserializer.LoadHeader,
3940
[typeof(OpenApiInfo)] = OpenApiV2Deserializer.LoadInfo,

src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic)
3535
[typeof(IOpenApiAny)] = OpenApiV3Deserializer.LoadAny,
3636
[typeof(OpenApiCallback)] = OpenApiV3Deserializer.LoadCallback,
3737
[typeof(OpenApiComponents)] = OpenApiV3Deserializer.LoadComponents,
38+
[typeof(OpenApiContact)] = OpenApiV3Deserializer.LoadContact,
3839
[typeof(OpenApiEncoding)] = OpenApiV3Deserializer.LoadEncoding,
3940
[typeof(OpenApiExample)] = OpenApiV3Deserializer.LoadExample,
4041
[typeof(OpenApiExternalDocs)] = OpenApiV3Deserializer.LoadExternalDocs,

src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
11-
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.326103">
11+
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.330701">
1212
<PrivateAssets>all</PrivateAssets>
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<Company>Microsoft</Company>
1212
<Title>Microsoft.OpenApi</Title>
1313
<PackageId>Microsoft.OpenApi</PackageId>
14-
<Version>1.3.1</Version>
14+
<Version>1.3.2</Version>
1515
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
1616
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1717
<PackageTags>OpenAPI .NET</PackageTags>
1818
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
1919
<PackageReleaseNotes>
20-
- Publish symbols.
20+
- Adds support for c-style hex notation strings. #908
2121
</PackageReleaseNotes>
2222
<AssemblyName>Microsoft.OpenApi</AssemblyName>
2323
<RootNamespace>Microsoft.OpenApi</RootNamespace>

src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,10 @@ internal static string GetYamlCompatibleString(this string input)
187187
return $"'{input}'";
188188
}
189189

190-
// If string can be mistaken as a number, a boolean, or a timestamp,
191-
// wrap it in quote to indicate that this is indeed a string, not a number, a boolean, or a timestamp
190+
// If string can be mistaken as a number, c-style hexadecimal notation, a boolean, or a timestamp,
191+
// wrap it in quote to indicate that this is indeed a string, not a number, c-style hexadecimal notation, a boolean, or a timestamp
192192
if (decimal.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var _) ||
193+
IsHexadecimalNotation(input) ||
193194
bool.TryParse(input, out var _) ||
194195
DateTime.TryParse(input, out var _))
195196
{
@@ -225,5 +226,10 @@ internal static string GetJsonCompatibleString(this string value)
225226

226227
return $"\"{value}\"";
227228
}
229+
230+
internal static bool IsHexadecimalNotation(string input)
231+
{
232+
return input.StartsWith("0x") && int.TryParse(input.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var _);
233+
}
228234
}
229235
}

test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
</PackageReference>
248248
<PackageReference Include="Newtonsoft.Json" Version="13.0.1">
249249
</PackageReference>
250-
<PackageReference Include="SharpYaml" Version="1.9.1">
250+
<PackageReference Include="SharpYaml" Version="1.9.2">
251251
</PackageReference>
252252
<PackageReference Include="xunit" Version="2.4.1">
253253
</PackageReference>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using FluentAssertions;
5+
using Microsoft.OpenApi.Models;
6+
using System;
7+
using Xunit;
8+
9+
namespace Microsoft.OpenApi.Readers.Tests.V2Tests
10+
{
11+
public class OpenApiContactTests
12+
{
13+
[Fact]
14+
public void ParseStringContactFragmentShouldSucceed()
15+
{
16+
var input = @"
17+
{
18+
""name"": ""API Support"",
19+
""url"": ""http://www.swagger.io/support"",
20+
""email"": ""[email protected]""
21+
}
22+
";
23+
var reader = new OpenApiStringReader();
24+
var diagnostic = new OpenApiDiagnostic();
25+
26+
// Act
27+
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic);
28+
29+
// Assert
30+
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
31+
32+
contact.Should().BeEquivalentTo(
33+
new OpenApiContact
34+
{
35+
Email = "[email protected]",
36+
Name = "API Support",
37+
Url = new Uri("http://www.swagger.io/support")
38+
});
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using FluentAssertions;
5+
using Microsoft.OpenApi.Models;
6+
using System;
7+
using Xunit;
8+
9+
namespace Microsoft.OpenApi.Readers.Tests.V3Tests
10+
{
11+
public class OpenApiContactTests
12+
{
13+
[Fact]
14+
public void ParseStringContactFragmentShouldSucceed()
15+
{
16+
var input = @"
17+
{
18+
""name"": ""API Support"",
19+
""url"": ""http://www.swagger.io/support"",
20+
""email"": ""[email protected]""
21+
}
22+
";
23+
var reader = new OpenApiStringReader();
24+
var diagnostic = new OpenApiDiagnostic();
25+
26+
// Act
27+
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
28+
29+
// Assert
30+
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
31+
32+
contact.Should().BeEquivalentTo(
33+
new OpenApiContact
34+
{
35+
Email = "[email protected]",
36+
Name = "API Support",
37+
Url = new Uri("http://www.swagger.io/support")
38+
});
39+
}
40+
}
41+
}

test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
2020
<PackageReference Include="Moq" Version="4.18.1" />
2121
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
22-
<PackageReference Include="SharpYaml" Version="1.9.1" />
23-
<PackageReference Include="Verify" Version="17.1.1" />
24-
<PackageReference Include="Verify.Xunit" Version="16.8.1" />
22+
<PackageReference Include="SharpYaml" Version="1.9.2" />
23+
<PackageReference Include="Verify" Version="17.1.4" />
24+
<PackageReference Include="Verify.Xunit" Version="17.1.4" />
2525
<PackageReference Include="xunit" Version="2.4.1" />
2626
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2727
<PrivateAssets>all</PrivateAssets>

test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from inputExpected in new[] {
3838
new[]{ "Test\\Test", "\"Test\\\\Test\""},
3939
new[]{ "Test\"Test", "\"Test\\\"Test\""},
4040
new[]{ "StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\""},
41+
new[]{ "0x1234", "\"0x1234\""},
4142
}
4243
from shouldBeTerse in shouldProduceTerseOutputValues
4344
select new object[] { inputExpected[0], inputExpected[1], shouldBeTerse };
@@ -79,6 +80,7 @@ public void WriteStringWithSpecialCharactersAsJsonWorks(string input, string exp
7980
[InlineData("trailingspace ", " 'trailingspace '")]
8081
[InlineData(" trailingspace", " ' trailingspace'")]
8182
[InlineData("terminal:", " 'terminal:'")]
83+
[InlineData("0x1234", " '0x1234'")]
8284
public void WriteStringWithSpecialCharactersAsYamlWorks(string input, string expected)
8385
{
8486
// Arrange

0 commit comments

Comments
 (0)