Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a955bb1
Add Contact for ReadFragment
matt9ucci Jun 5, 2022
ba9ac7a
Bump Verify.Xunit from 16.8.1 to 17.1.2
dependabot[bot] Jun 7, 2022
94de45a
- bumps verify to 17.1.2
baywet Jun 7, 2022
e2f3766
Merge pull request #898 from microsoft/dependabot/nuget/Verify.Xunit-…
baywet Jun 7, 2022
e9deeea
Bump Verify from 17.1.2 to 17.1.4
dependabot[bot] Jun 8, 2022
d032253
added support for c-style hex numbers to be exported as strings
hoonality Jun 10, 2022
e125a56
resolved merge conflicts to add unit tests
hoonality Jun 15, 2022
125961b
Merge pull request #902 from microsoft/dependabot/nuget/Verify-17.1.4
zengin Jun 18, 2022
e8dded7
Bump Verify.Xunit from 17.1.2 to 17.1.4
dependabot[bot] Jun 18, 2022
6b2dab4
Merge pull request #901 from microsoft/dependabot/nuget/Verify.Xunit-…
zengin Jun 18, 2022
d8ad5f2
Bump Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers
dependabot[bot] Jun 18, 2022
e6d02cb
Bump SharpYaml from 1.9.1 to 1.9.2
dependabot[bot] Jun 18, 2022
9176e3b
Merge pull request #903 from microsoft/dependabot/nuget/Microsoft.Dot…
zengin Jun 18, 2022
b3c4b54
Merge pull request #906 from microsoft/dependabot/nuget/SharpYaml-1.9.2
zengin Jun 18, 2022
8a50764
- adds docker image definition for hidi
baywet Jun 21, 2022
9b1c35c
- fixes branch filters for docker image release
baywet Jun 21, 2022
8bee807
- fixes image name
baywet Jun 21, 2022
d239dab
Bump Microsoft.OData.Edm from 7.11.0 to 7.12.0
dependabot[bot] Jun 21, 2022
c0aca71
Merge pull request #911 from microsoft/dependabot/nuget/Microsoft.ODa…
zengin Jun 22, 2022
82ca744
Bump Microsoft.OpenApi.OData from 1.0.11-preview2 to 1.0.11-preview3
dependabot[bot] Jun 23, 2022
0970eff
Merge pull request #910 from microsoft/feature/docker-image
baywet Jun 23, 2022
d2b2774
Merge pull request #912 from microsoft/dependabot/nuget/Microsoft.Ope…
baywet Jun 23, 2022
a768c72
- removes unecessary condition for get version step
baywet Jun 23, 2022
c8e75e7
- removes unecessary branch name variable
baywet Jun 23, 2022
5fa5c65
Merge pull request #908 from VitaliyKurokhtin/apim-hexstring-notation…
baywet Jun 23, 2022
4c8ab29
Merge pull request #892 from matt9ucci/contact-fragment
baywet Jun 23, 2022
2ae43e8
- adds release notes
baywet Jun 23, 2022
22308bc
Merge pull request #915 from microsoft/bugfix/version-condition
baywet Jun 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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/[email protected]
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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)"
12 changes: 6 additions & 6 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.0.0-preview5</Version>
<Version>1.0.0-preview6</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- 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
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.Hidi</AssemblyName>
<RootNamespace>Microsoft.OpenApi.Hidi</RootNamespace>
Expand All @@ -46,8 +46,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.11.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview2" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi.Readers</Title>
<PackageId>Microsoft.OpenApi.Readers</PackageId>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Publish symbols.
- Fixed a bug where contact information would not read properly. #892
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.Readers</AssemblyName>
<RootNamespace>Microsoft.OpenApi.Readers</RootNamespace>
Expand All @@ -40,7 +40,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpYaml" Version="1.9.1" />
<PackageReference Include="SharpYaml" Version="1.9.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic)
private IDictionary<Type, Func<ParseNode, object>> _loaders = new Dictionary<Type, Func<ParseNode, object>>
{
[typeof(IOpenApiAny)] = OpenApiV2Deserializer.LoadAny,
[typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact,
[typeof(OpenApiExternalDocs)] = OpenApiV2Deserializer.LoadExternalDocs,
[typeof(OpenApiHeader)] = OpenApiV2Deserializer.LoadHeader,
[typeof(OpenApiInfo)] = OpenApiV2Deserializer.LoadInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.326103">
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.330701">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi</Title>
<PackageId>Microsoft.OpenApi</PackageId>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Publish symbols.
- Adds support for c-style hex notation strings. #908
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi</AssemblyName>
<RootNamespace>Microsoft.OpenApi</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 _))
{
Expand Down Expand Up @@ -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 _);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1">
</PackageReference>
<PackageReference Include="SharpYaml" Version="1.9.1">
<PackageReference Include="SharpYaml" Version="1.9.2">
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1">
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -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"": ""[email protected]""
}
";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());

contact.Should().BeEquivalentTo(
new OpenApiContact
{
Email = "[email protected]",
Name = "API Support",
Url = new Uri("http://www.swagger.io/support")
});
}
}
}
Original file line number Diff line number Diff line change
@@ -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"": ""[email protected]""
}
";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());

contact.Should().BeEquivalentTo(
new OpenApiContact
{
Email = "[email protected]",
Name = "API Support",
Url = new Uri("http://www.swagger.io/support")
});
}
}
}
6 changes: 3 additions & 3 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SharpYaml" Version="1.9.1" />
<PackageReference Include="Verify" Version="17.1.1" />
<PackageReference Include="Verify.Xunit" Version="16.8.1" />
<PackageReference Include="SharpYaml" Version="1.9.2" />
<PackageReference Include="Verify" Version="17.1.4" />
<PackageReference Include="Verify.Xunit" Version="17.1.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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
Expand Down