Skip to content

Commit 42614be

Browse files
committed
Resolve merge conflicts
2 parents d0fb2c7 + 5c35c7b commit 42614be

File tree

8 files changed

+55
-35
lines changed

8 files changed

+55
-35
lines changed

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

Lines changed: 5 additions & 5 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.11</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 -->
@@ -31,15 +31,15 @@
3131
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
3232
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
3333
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
34-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
35-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
34+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
35+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
3636
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20">
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
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.3" />
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.Workbench/MainModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.OpenApi.Extensions;
1212
using Microsoft.OpenApi.Models;
1313
using Microsoft.OpenApi.Reader;
14+
using Microsoft.OpenApi.Readers;
1415
using Microsoft.OpenApi.Services;
1516
using Microsoft.OpenApi.Validations;
1617

@@ -158,6 +159,7 @@ public OpenApiSpecVersion Version
158159
_version = value;
159160
OnPropertyChanged(nameof(IsV2_0));
160161
OnPropertyChanged(nameof(IsV3_0));
162+
OnPropertyChanged(nameof(IsV3_1));
161163
}
162164
}
163165

@@ -185,6 +187,12 @@ public bool IsV3_0
185187
set => Version = OpenApiSpecVersion.OpenApi3_0;
186188
}
187189

190+
public bool IsV3_1
191+
{
192+
get => Version == OpenApiSpecVersion.OpenApi3_1;
193+
set => Version = OpenApiSpecVersion.OpenApi3_1;
194+
}
195+
188196
/// <summary>
189197
/// Handling method when the property with given name has changed.
190198
/// </summary>
@@ -203,6 +211,9 @@ protected void OnPropertyChanged(string propertyName)
203211
/// </summary>
204212
internal async Task ParseDocumentAsync()
205213
{
214+
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader());
215+
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yml, new OpenApiYamlReader());
216+
206217
Stream stream = null;
207218
try
208219
{

src/Microsoft.OpenApi.Workbench/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</StackPanel>
4141
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
4242
<Label>Version:</Label>
43+
<RadioButton GroupName="Format" Content="V3.1.0" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV3_1}" />
4344
<RadioButton GroupName="Format" Content="V3.0.1" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV3_0}" />
4445
<RadioButton GroupName="Format" Content="V2.0" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV2_0}" />
4546
</StackPanel>

src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -139,9 +139,10 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
139139
var type = (ToIdentifier(schema.Type), schema.Format?.ToLowerInvariant(), schema.Nullable) switch
140140
{
141141
("boolean", null, false) => typeof(bool),
142-
("integer", "int32", false) => typeof(int),
143-
("integer", "int64", false) => typeof(long),
144-
("integer", null, false) => typeof(int),
142+
// integer is technically not valid with format, but we must provide some compatibility
143+
("integer" or "number", "int32", false) => typeof(int),
144+
("integer" or "number", "int64", false) => typeof(long),
145+
("integer", null, false) => typeof(long),
145146
("number", "float", false) => typeof(float),
146147
("number", "double", false) => typeof(double),
147148
("number", "decimal", false) => typeof(decimal),
@@ -154,9 +155,9 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
154155
("string", null, false) => typeof(string),
155156
("object", null, false) => typeof(object),
156157
("string", "uri", false) => typeof(Uri),
157-
("integer", "int32", true) => typeof(int?),
158-
("integer", "int64", true) => typeof(long?),
159-
("integer", null, true) => typeof(int?),
158+
("integer" or "number", "int32", true) => typeof(int?),
159+
("integer" or "number", "int64", true) => typeof(long?),
160+
("integer", null, true) => typeof(long?),
160161
("number", "float", true) => typeof(float?),
161162
("number", "double", true) => typeof(double?),
162163
("number", null, true) => typeof(double?),

src/Microsoft.OpenApi/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static class Utils
2020
/// <returns>The input value.</returns>
2121
internal static T CheckArgumentNull<T>(
2222
T value,
23-
[CallerArgumentExpression("value")] string parameterName = "")
23+
[CallerArgumentExpression(nameof(value))] string parameterName = "")
2424
{
2525
return value ?? throw new ArgumentNullException(parameterName, $"Value cannot be null: {parameterName}");
2626
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static void ValidateDataTypeMismatch(
138138
return;
139139
}
140140

141-
if (type == "integer" && format == "int32")
141+
if (type is "integer" or "number" && format is "int32")
142142
{
143143
if (jsonElement.ValueKind is not JsonValueKind.Number)
144144
{
@@ -150,7 +150,7 @@ public static void ValidateDataTypeMismatch(
150150
return;
151151
}
152152

153-
if (type == "integer" && format == "int64")
153+
if (type is "integer" or "number" && format is "int64")
154154
{
155155
if (jsonElement.ValueKind is not JsonValueKind.Number)
156156
{
@@ -162,7 +162,7 @@ public static void ValidateDataTypeMismatch(
162162
return;
163163
}
164164

165-
if (type == "integer" && jsonElement.ValueKind is not JsonValueKind.Number)
165+
if (type is "integer")
166166
{
167167
if (jsonElement.ValueKind is not JsonValueKind.Number)
168168
{
@@ -174,7 +174,7 @@ public static void ValidateDataTypeMismatch(
174174
return;
175175
}
176176

177-
if (type == "number" && format == "float")
177+
if (type is "number" && format is "float")
178178
{
179179
if (jsonElement.ValueKind is not JsonValueKind.Number)
180180
{
@@ -186,7 +186,7 @@ public static void ValidateDataTypeMismatch(
186186
return;
187187
}
188188

189-
if (type == "number" && format == "double")
189+
if (type is "number" && format is "double")
190190
{
191191
if (jsonElement.ValueKind is not JsonValueKind.Number)
192192
{
@@ -198,7 +198,7 @@ public static void ValidateDataTypeMismatch(
198198
return;
199199
}
200200

201-
if (type == "number")
201+
if (type is "number")
202202
{
203203
if (jsonElement.ValueKind is not JsonValueKind.Number)
204204
{
@@ -210,7 +210,7 @@ public static void ValidateDataTypeMismatch(
210210
return;
211211
}
212212

213-
if (type == "string" && format == "byte")
213+
if (type is "string" && format is "byte")
214214
{
215215
if (jsonElement.ValueKind is not JsonValueKind.String)
216216
{
@@ -222,7 +222,7 @@ public static void ValidateDataTypeMismatch(
222222
return;
223223
}
224224

225-
if (type == "string" && format == "date")
225+
if (type is "string" && format is "date")
226226
{
227227
if (jsonElement.ValueKind is not JsonValueKind.String)
228228
{
@@ -234,7 +234,7 @@ public static void ValidateDataTypeMismatch(
234234
return;
235235
}
236236

237-
if (type == "string" && format == "date-time")
237+
if (type is "string" && format is "date-time")
238238
{
239239
if (jsonElement.ValueKind is not JsonValueKind.String)
240240
{
@@ -246,7 +246,7 @@ public static void ValidateDataTypeMismatch(
246246
return;
247247
}
248248

249-
if (type == "string" && format == "password")
249+
if (type is "string" && format is "password")
250250
{
251251
if (jsonElement.ValueKind is not JsonValueKind.String)
252252
{
@@ -258,7 +258,7 @@ public static void ValidateDataTypeMismatch(
258258
return;
259259
}
260260

261-
if (type == "string")
261+
if (type is "string")
262262
{
263263
if (jsonElement.ValueKind is not JsonValueKind.String)
264264
{
@@ -270,7 +270,7 @@ public static void ValidateDataTypeMismatch(
270270
return;
271271
}
272272

273-
if (type == "boolean")
273+
if (type is "boolean")
274274
{
275275
if (jsonElement.ValueKind is not JsonValueKind.True && jsonElement.ValueKind is not JsonValueKind.False)
276276
{

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ public class OpenApiTypeMapperTests
1414
{
1515
public static IEnumerable<object[]> PrimitiveTypeData => new List<object[]>
1616
{
17-
new object[] { typeof(int), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32" } },
17+
new object[] { typeof(int), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32" } },
1818
new object[] { typeof(decimal), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double" } },
19+
new object[] { typeof(decimal?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double", Nullable = true } },
1920
new object[] { typeof(bool?), new OpenApiSchema { Type = JsonSchemaType.Boolean, Nullable = true } },
2021
new object[] { typeof(Guid), new OpenApiSchema { Type = JsonSchemaType.String, Format = "uuid" } },
21-
new object[] { typeof(uint), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32" } },
22-
new object[] { typeof(long), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int64" } },
23-
new object[] { typeof(ulong), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int64" } },
22+
new object[] { typeof(Guid?), new OpenApiSchema { Type = JsonSchemaType.String, Format = "uuid", Nullable = true } },
23+
new object[] { typeof(uint), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32" } },
24+
new object[] { typeof(long), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int64" } },
25+
new object[] { typeof(long?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int64", Nullable = true } },
26+
new object[] { typeof(ulong), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int64" } },
2427
new object[] { typeof(string), new OpenApiSchema { Type = JsonSchemaType.String } },
2528
new object[] { typeof(double), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double" } },
2629
new object[] { typeof(float?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "float", Nullable = true } },
2730
new object[] { typeof(byte?), new OpenApiSchema { Type = JsonSchemaType.String, Format = "byte", Nullable = true } },
28-
new object[] { typeof(int?), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32", Nullable = true } },
29-
new object[] { typeof(uint?), new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32", Nullable = true } },
31+
new object[] { typeof(int?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32", Nullable = true } },
32+
new object[] { typeof(uint?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32", Nullable = true } },
3033
new object[] { typeof(DateTimeOffset?), new OpenApiSchema { Type = JsonSchemaType.String, Format = "date-time", Nullable = true } },
3134
new object[] { typeof(double?), new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double", Nullable = true } },
3235
new object[] { typeof(char?), new OpenApiSchema { Type = JsonSchemaType.String, Nullable = true } },
@@ -35,11 +38,15 @@ public class OpenApiTypeMapperTests
3538

3639
public static IEnumerable<object[]> OpenApiDataTypes => new List<object[]>
3740
{
38-
new object[] { new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32"}, typeof(int) },
41+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32", Nullable = false}, typeof(int) },
42+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int32", Nullable = true}, typeof(int?) },
43+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int64", Nullable = false}, typeof(long) },
44+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "int64", Nullable = true}, typeof(long?) },
3945
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "decimal"}, typeof(decimal) },
46+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Integer, Format = null, Nullable = false}, typeof(long) },
47+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Integer, Format = null, Nullable = true}, typeof(long?) },
4048
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = null, Nullable = false}, typeof(double) },
41-
new object[] { new OpenApiSchema { Type = JsonSchemaType.Integer, Format = null, Nullable = false}, typeof(int) },
42-
new object[] { new OpenApiSchema { Type = JsonSchemaType.Integer, Format = null, Nullable = true}, typeof(int?) },
49+
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = null, Nullable = true}, typeof(double?) },
4350
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "decimal", Nullable = true}, typeof(decimal?) },
4451
new object[] { new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double", Nullable = true}, typeof(double?) },
4552
new object[] { new OpenApiSchema { Type = JsonSchemaType.String, Format = "date-time", Nullable = true}, typeof(DateTimeOffset?) },

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)