diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 000000000..90bf97929
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,42 @@
+name: Publish Docker image
+on:
+ workflow_dispatch:
+ push:
+ branches: [master, vnext]
+ paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
+env:
+ REGISTRY: msgraphprod.azurecr.io
+ IMAGE_NAME: public/hidi
+jobs:
+ push_to_registry:
+ environment:
+ name: acr
+ name: Push Docker image
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out the repo
+ uses: actions/checkout@v3
+ - name: Login to GitHub package feed
+ uses: docker/login-action@v2.0.0
+ with:
+ username: ${{ secrets.ACR_USERNAME }}
+ password: ${{ secrets.ACR_PASSWORD }}
+ registry: ${{ env.REGISTRY }}
+ - run: |
+ $content = [XML](Get-Content ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj)
+ $version = $content.Project.PropertyGroup.Version
+ echo "::set-output name=version::${version}"
+ shell: pwsh
+ id: getversion
+ - name: Push to GitHub Packages - Nightly
+ if: contains(github.ref, 'refs/head/vnext')
+ uses: docker/build-push-action@v3.0.0
+ with:
+ push: true
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
+ - name: Push to GitHub Packages - Release
+ if: contains(github.ref, 'refs/head/master')
+ uses: docker/build-push-action@v3.0.0
+ with:
+ push: true
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..8326ce3b9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,21 @@
+FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
+WORKDIR /app
+
+COPY ./src ./hidi/src
+WORKDIR /app/hidi
+RUN dotnet publish ./src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj -c Release
+
+FROM mcr.microsoft.com/dotnet/runtime:6.0 as runtime
+WORKDIR /app
+
+COPY --from=build-env /app/hidi/src/Microsoft.OpenApi.Hidi/bin/Release/net6.0 ./
+
+VOLUME /app/output
+VOLUME /app/openapi.yml
+VOLUME /app/api.csdl
+VOLUME /app/collection.json
+ENV HIDI_CONTAINER=true DOTNET_TieredPGO=1 DOTNET_TC_QuickJitForLoops=1
+ENTRYPOINT ["dotnet", "Microsoft.OpenApi.Hidi.dll"]
+LABEL description="# Welcome to Hidi \
+To start transforming OpenAPI documents checkout [the getting started documentation](https://github.com/microsoft/OpenAPI.NET/tree/vnext/src/Microsoft.OpenApi.Hidi) \
+[Source dockerfile](https://github.com/microsoft/OpenAPI.NET/blob/vnext/Dockerfile)"
diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
index 6bc530517..f885e8d6f 100644
--- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
+++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
@@ -15,15 +15,15 @@
Microsoft.OpenApi.Hidi
hidi
./../../artifacts
- 1.0.0-preview5
+ 1.0.0-preview6
OpenAPI.NET CLI tool for slicing OpenAPI documents
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
https://github.com/Microsoft/OpenAPI.NET
-- Enables discriminator values
-- Adds new OpenAPI convert setting, ExpandDerivedTypesNavigationProperties and sets it to false
-- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview2
+- Bumps up the Microsoft.OpenAPI library to v1.3.2
+- Bumps up the Microsoft.OData library to v7.12.0
+- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview3
Microsoft.OpenApi.Hidi
Microsoft.OpenApi.Hidi
@@ -46,8 +46,8 @@
-
-
+
+
diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
index b6d43cf4c..8835b373c 100644
--- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
+++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj
@@ -10,13 +10,13 @@
Microsoft
Microsoft.OpenApi.Readers
Microsoft.OpenApi.Readers
- 1.3.1
+ 1.3.2
OpenAPI.NET Readers for JSON and YAML documents
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
https://github.com/Microsoft/OpenAPI.NET
-- Publish symbols.
+- Fixed a bug where contact information would not read properly. #892
Microsoft.OpenApi.Readers
Microsoft.OpenApi.Readers
@@ -40,7 +40,7 @@
-
+
diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs
index c4d765734..718dcec04 100644
--- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs
+++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs
@@ -34,6 +34,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic)
private IDictionary> _loaders = new Dictionary>
{
[typeof(IOpenApiAny)] = OpenApiV2Deserializer.LoadAny,
+ [typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact,
[typeof(OpenApiExternalDocs)] = OpenApiV2Deserializer.LoadExternalDocs,
[typeof(OpenApiHeader)] = OpenApiV2Deserializer.LoadHeader,
[typeof(OpenApiInfo)] = OpenApiV2Deserializer.LoadInfo,
diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs
index c967cde55..40b40e85a 100644
--- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs
+++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs
@@ -35,6 +35,7 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic)
[typeof(IOpenApiAny)] = OpenApiV3Deserializer.LoadAny,
[typeof(OpenApiCallback)] = OpenApiV3Deserializer.LoadCallback,
[typeof(OpenApiComponents)] = OpenApiV3Deserializer.LoadComponents,
+ [typeof(OpenApiContact)] = OpenApiV3Deserializer.LoadContact,
[typeof(OpenApiEncoding)] = OpenApiV3Deserializer.LoadEncoding,
[typeof(OpenApiExample)] = OpenApiV3Deserializer.LoadExample,
[typeof(OpenApiExternalDocs)] = OpenApiV3Deserializer.LoadExternalDocs,
diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
index 5cb2f25c6..96dae450b 100644
--- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
+++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
@@ -8,7 +8,7 @@
-
+
all
diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
index cbdcde393..980265e98 100644
--- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
+++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
@@ -11,13 +11,13 @@
Microsoft
Microsoft.OpenApi
Microsoft.OpenApi
- 1.3.1
+ 1.3.2
.NET models with JSON and YAML writers for OpenAPI specification
© Microsoft Corporation. All rights reserved.
OpenAPI .NET
https://github.com/Microsoft/OpenAPI.NET
-- Publish symbols.
+- Adds support for c-style hex notation strings. #908
Microsoft.OpenApi
Microsoft.OpenApi
diff --git a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs
index 5c6831cb1..d4f78a5c1 100644
--- a/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs
+++ b/src/Microsoft.OpenApi/Writers/SpecialCharacterStringExtensions.cs
@@ -187,9 +187,10 @@ internal static string GetYamlCompatibleString(this string input)
return $"'{input}'";
}
- // If string can be mistaken as a number, a boolean, or a timestamp,
- // wrap it in quote to indicate that this is indeed a string, not a number, a boolean, or a timestamp
+ // If string can be mistaken as a number, c-style hexadecimal notation, a boolean, or a timestamp,
+ // wrap it in quote to indicate that this is indeed a string, not a number, c-style hexadecimal notation, a boolean, or a timestamp
if (decimal.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out var _) ||
+ IsHexadecimalNotation(input) ||
bool.TryParse(input, out var _) ||
DateTime.TryParse(input, out var _))
{
@@ -225,5 +226,10 @@ internal static string GetJsonCompatibleString(this string value)
return $"\"{value}\"";
}
+
+ internal static bool IsHexadecimalNotation(string input)
+ {
+ return input.StartsWith("0x") && int.TryParse(input.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var _);
+ }
}
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
index 73fa9f239..e1ec38f8f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -247,7 +247,7 @@
-
+
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
new file mode 100644
index 000000000..71489d39f
--- /dev/null
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using FluentAssertions;
+using Microsoft.OpenApi.Models;
+using System;
+using Xunit;
+
+namespace Microsoft.OpenApi.Readers.Tests.V2Tests
+{
+ public class OpenApiContactTests
+ {
+ [Fact]
+ public void ParseStringContactFragmentShouldSucceed()
+ {
+ var input = @"
+{
+ ""name"": ""API Support"",
+ ""url"": ""http://www.swagger.io/support"",
+ ""email"": ""support@swagger.io""
+}
+";
+ var reader = new OpenApiStringReader();
+ var diagnostic = new OpenApiDiagnostic();
+
+ // Act
+ var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic);
+
+ // Assert
+ diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
+
+ contact.Should().BeEquivalentTo(
+ new OpenApiContact
+ {
+ Email = "support@swagger.io",
+ Name = "API Support",
+ Url = new Uri("http://www.swagger.io/support")
+ });
+ }
+ }
+}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
new file mode 100644
index 000000000..be78f942b
--- /dev/null
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using FluentAssertions;
+using Microsoft.OpenApi.Models;
+using System;
+using Xunit;
+
+namespace Microsoft.OpenApi.Readers.Tests.V3Tests
+{
+ public class OpenApiContactTests
+ {
+ [Fact]
+ public void ParseStringContactFragmentShouldSucceed()
+ {
+ var input = @"
+{
+ ""name"": ""API Support"",
+ ""url"": ""http://www.swagger.io/support"",
+ ""email"": ""support@swagger.io""
+}
+";
+ var reader = new OpenApiStringReader();
+ var diagnostic = new OpenApiDiagnostic();
+
+ // Act
+ var contact = reader.ReadFragment(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
+
+ // Assert
+ diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
+
+ contact.Should().BeEquivalentTo(
+ new OpenApiContact
+ {
+ Email = "support@swagger.io",
+ Name = "API Support",
+ Url = new Uri("http://www.swagger.io/support")
+ });
+ }
+ }
+}
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 0d93018b0..60bf287cc 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -19,9 +19,9 @@
-
-
-
+
+
+
all
diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs
index a81e9fc85..f23cc442a 100644
--- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs
@@ -38,6 +38,7 @@ from inputExpected in new[] {
new[]{ "Test\\Test", "\"Test\\\\Test\""},
new[]{ "Test\"Test", "\"Test\\\"Test\""},
new[]{ "StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\""},
+ new[]{ "0x1234", "\"0x1234\""},
}
from shouldBeTerse in shouldProduceTerseOutputValues
select new object[] { inputExpected[0], inputExpected[1], shouldBeTerse };
@@ -79,6 +80,7 @@ public void WriteStringWithSpecialCharactersAsJsonWorks(string input, string exp
[InlineData("trailingspace ", " 'trailingspace '")]
[InlineData(" trailingspace", " ' trailingspace'")]
[InlineData("terminal:", " 'terminal:'")]
+ [InlineData("0x1234", " '0x1234'")]
public void WriteStringWithSpecialCharactersAsYamlWorks(string input, string expected)
{
// Arrange