Skip to content

Commit 8c64b50

Browse files
authored
Merge pull request #1885 from microsoft/vnext
Release Hidi lib.
2 parents 97f8450 + 95e25ba commit 8c64b50

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Nullable>enable</Nullable>
1010
<ToolCommandName>hidi</ToolCommandName>
1111
<PackageOutputPath>./../../artifacts</PackageOutputPath>
12-
<Version>1.4.12</Version>
12+
<Version>1.4.13</Version>
1313
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
1414
<SignAssembly>true</SignAssembly>
1515
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
@@ -38,8 +38,8 @@
3838
<PrivateAssets>all</PrivateAssets>
3939
</PackageReference>
4040
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
41-
<PackageReference Include="Microsoft.OData.Edm" Version="8.0.2" />
42-
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.5" />
41+
<PackageReference Include="Microsoft.OData.Edm" Version="8.1.0" />
42+
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.6" />
4343
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.0-preview" />
4444
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
4545
<!--STJ

src/Microsoft.OpenApi.Readers/ParseNodes/OpenApiAnyConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ public static IOpenApiAny GetSpecificOpenApiAny(IOpenApiAny openApiAny, OpenApiS
157157
}
158158
else
159159
{
160-
if (type == "integer" && format == "int32")
160+
if (type is "integer" or "number" && format == "int32")
161161
{
162162
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue))
163163
{
164164
return new OpenApiInteger(intValue);
165165
}
166166
}
167167

168-
if (type == "integer" && format == "int64")
168+
if (type is "integer" or "number" && format == "int64")
169169
{
170170
if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var longValue))
171171
{

src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public static class OpenApiTypeMapper
1616
{
1717
[typeof(bool)] = () => new() { Type = "boolean" },
1818
[typeof(byte)] = () => new() { Type = "string", Format = "byte" },
19-
[typeof(int)] = () => new() { Type = "integer", Format = "int32" },
20-
[typeof(uint)] = () => new() { Type = "integer", Format = "int32" },
21-
[typeof(long)] = () => new() { Type = "integer", Format = "int64" },
22-
[typeof(ulong)] = () => new() { Type = "integer", Format = "int64" },
19+
[typeof(int)] = () => new() { Type = "number", Format = "int32" },
20+
[typeof(uint)] = () => new() { Type = "number", Format = "int32" },
21+
[typeof(long)] = () => new() { Type = "number", Format = "int64" },
22+
[typeof(ulong)] = () => new() { Type = "number", Format = "int64" },
2323
[typeof(float)] = () => new() { Type = "number", Format = "float" },
2424
[typeof(double)] = () => new() { Type = "number", Format = "double" },
2525
[typeof(decimal)] = () => new() { Type = "number", Format = "double" },
@@ -31,10 +31,10 @@ public static class OpenApiTypeMapper
3131
// Nullable types
3232
[typeof(bool?)] = () => new() { Type = "boolean", Nullable = true },
3333
[typeof(byte?)] = () => new() { Type = "string", Format = "byte", Nullable = true },
34-
[typeof(int?)] = () => new() { Type = "integer", Format = "int32", Nullable = true },
35-
[typeof(uint?)] = () => new() { Type = "integer", Format = "int32", Nullable = true },
36-
[typeof(long?)] = () => new() { Type = "integer", Format = "int64", Nullable = true },
37-
[typeof(ulong?)] = () => new() { Type = "integer", Format = "int64", Nullable = true },
34+
[typeof(int?)] = () => new() { Type = "number", Format = "int32", Nullable = true },
35+
[typeof(uint?)] = () => new() { Type = "number", Format = "int32", Nullable = true },
36+
[typeof(long?)] = () => new() { Type = "number", Format = "int64", Nullable = true },
37+
[typeof(ulong?)] = () => new() { Type = "number", Format = "int64", Nullable = true },
3838
[typeof(float?)] = () => new() { Type = "number", Format = "float", Nullable = true },
3939
[typeof(double?)] = () => new() { Type = "number", Format = "double", Nullable = true },
4040
[typeof(decimal?)] = () => new() { Type = "number", Format = "double", Nullable = true },
@@ -98,8 +98,9 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
9898
var type = (schema.Type?.ToLowerInvariant(), schema.Format?.ToLowerInvariant(), schema.Nullable) switch
9999
{
100100
("boolean", null, false) => typeof(bool),
101-
("integer", "int32", false) => typeof(int),
102-
("integer", "int64", false) => typeof(long),
101+
// integer is technically not valid with format, but we must provide some compatibility
102+
("integer" or "number", "int32", false) => typeof(int),
103+
("integer" or "number", "int64", false) => typeof(long),
103104
("integer", null, false) => typeof(int),
104105
("number", "float", false) => typeof(float),
105106
("number", "double", false) => typeof(double),
@@ -113,8 +114,8 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
113114
("string", null, false) => typeof(string),
114115
("object", null, false) => typeof(object),
115116
("string", "uri", false) => typeof(Uri),
116-
("integer", "int32", true) => typeof(int?),
117-
("integer", "int64", true) => typeof(long?),
117+
("integer" or "number", "int32", true) => typeof(int?),
118+
("integer" or "number", "int64", true) => typeof(long?),
118119
("integer", null, true) => typeof(int?),
119120
("number", "float", true) => typeof(float?),
120121
("number", "double", true) => typeof(double?),

src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static void ValidateDataTypeMismatch(
134134
return;
135135
}
136136

137-
if (type == "integer" && format == "int32")
137+
if (type is "integer" or "number" && format == "int32")
138138
{
139139
if (value is not OpenApiInteger)
140140
{
@@ -146,7 +146,7 @@ public static void ValidateDataTypeMismatch(
146146
return;
147147
}
148148

149-
if (type == "integer" && format == "int64")
149+
if (type is "integer" or "number" && format == "int64")
150150
{
151151
if (value is not OpenApiLong)
152152
{
@@ -158,7 +158,7 @@ public static void ValidateDataTypeMismatch(
158158
return;
159159
}
160160

161-
if (type == "integer" && value is not OpenApiInteger)
161+
if (type is "integer" && value is not OpenApiInteger)
162162
{
163163
if (value is not OpenApiInteger)
164164
{

test/Microsoft.OpenApi.Tests/Extensions/OpenApiTypeMapperTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class OpenApiTypeMapperTests
1414
{
1515
public static IEnumerable<object[]> PrimitiveTypeData => new List<object[]>
1616
{
17-
new object[] { typeof(int), new OpenApiSchema { Type = "integer", Format = "int32" } },
17+
new object[] { typeof(int), new OpenApiSchema { Type = "number", Format = "int32" } },
1818
new object[] { typeof(string), new OpenApiSchema { Type = "string" } },
1919
new object[] { typeof(double), new OpenApiSchema { Type = "number", Format = "double" } },
2020
new object[] { typeof(float?), new OpenApiSchema { Type = "number", Format = "float", Nullable = true } },
@@ -24,6 +24,7 @@ public class OpenApiTypeMapperTests
2424
public static IEnumerable<object[]> OpenApiDataTypes => new List<object[]>
2525
{
2626
new object[] { new OpenApiSchema { Type = "integer", Format = "int32"}, typeof(int) },
27+
new object[] { new OpenApiSchema { Type = "number", Format = "int32"}, typeof(int) },
2728
new object[] { new OpenApiSchema { Type = "integer", Format = null, Nullable = false}, typeof(int) },
2829
new object[] { new OpenApiSchema { Type = "integer", Format = null, Nullable = true}, typeof(int?) },
2930
new object[] { new OpenApiSchema { Type = "string" }, typeof(string) },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="Moq" Version="4.20.72" />
1616
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1717
<PackageReference Include="SharpYaml" Version="2.1.1" />
18-
<PackageReference Include="Verify.Xunit" Version="26.6.0" />
18+
<PackageReference Include="Verify.Xunit" Version="27.0.1" />
1919
<PackageReference Include="xunit" Version="2.9.2" />
2020
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="all" />
2121
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

0 commit comments

Comments
 (0)