Skip to content

Commit 1fc5629

Browse files
committed
Merge branch 'feat/oai-3-2-support' into copilot/fix-1e80ce48-c500-4024-9aa8-a50a721fd288
Signed-off-by: Vincent Biret <[email protected]>
2 parents 91f51bb + 0f84c3e commit 1fc5629

File tree

11 files changed

+125
-59
lines changed

11 files changed

+125
-59
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.3.2"
2+
".": "2.3.3"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [2.3.3](https://github.com/microsoft/OpenAPI.NET/compare/v2.3.2...v2.3.3) (2025-10-02)
4+
5+
6+
### Bug Fixes
7+
8+
* typo in allowReserved property name for deserialization ([1633453](https://github.com/microsoft/OpenAPI.NET/commit/16334536dcb5182f26c0d58463bd15a124dd1505))
9+
* typo in allowReserved property name for deserialization ([f7e34be](https://github.com/microsoft/OpenAPI.NET/commit/f7e34be28566a4f714d43667f8c43be7159d27a2))
10+
311
## [2.3.2](https://github.com/microsoft/OpenAPI.NET/compare/v2.3.1...v2.3.2) (2025-09-19)
412

513

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageProjectUrl>https://github.com/Microsoft/OpenAPI.NET</PackageProjectUrl>
1313
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1414
<PackageTags>OpenAPI .NET</PackageTags>
15-
<Version>2.3.2</Version>
15+
<Version>2.3.3</Version>
1616
</PropertyGroup>
1717
<!-- https://github.com/clairernovotny/DeterministicBuilds#deterministic-builds -->
1818
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,74 @@
11
using System;
22

3-
namespace Microsoft.OpenApi.Reader.V31
3+
namespace Microsoft.OpenApi.Reader.V31;
4+
/// <summary>
5+
/// Class containing logic to deserialize Open API V31 document into
6+
/// runtime Open API object model.
7+
/// </summary>
8+
internal static partial class OpenApiV31Deserializer
49
{
5-
/// <summary>
6-
/// Class containing logic to deserialize Open API V31 document into
7-
/// runtime Open API object model.
8-
/// </summary>
9-
internal static partial class OpenApiV31Deserializer
10+
private static readonly FixedFieldMap<OpenApiEncoding> _encodingFixedFields = new()
1011
{
11-
private static readonly FixedFieldMap<OpenApiEncoding> _encodingFixedFields = new()
1212
{
13+
"contentType", (o, n, _) =>
1314
{
14-
"contentType", (o, n, _) =>
15-
{
16-
o.ContentType = n.GetScalarValue();
17-
}
18-
},
15+
o.ContentType = n.GetScalarValue();
16+
}
17+
},
18+
{
19+
"headers", (o, n, t) =>
1920
{
20-
"headers", (o, n, t) =>
21-
{
22-
o.Headers = n.CreateMap(LoadHeader, t);
23-
}
24-
},
21+
o.Headers = n.CreateMap(LoadHeader, t);
22+
}
23+
},
24+
{
25+
"style", (o, n, _) =>
2526
{
26-
"style", (o, n, _) =>
27+
if(!n.GetScalarValue().TryGetEnumFromDisplayName<ParameterStyle>(n.Context, out var style))
2728
{
28-
if(!n.GetScalarValue().TryGetEnumFromDisplayName<ParameterStyle>(n.Context, out var style))
29-
{
30-
return;
31-
}
32-
o.Style = style;
29+
return;
3330
}
34-
},
31+
o.Style = style;
32+
}
33+
},
34+
{
35+
"explode", (o, n, _) =>
3536
{
36-
"explode", (o, n, _) =>
37+
var explode = n.GetScalarValue();
38+
if (explode is not null)
3739
{
38-
var explode = n.GetScalarValue();
39-
if (explode is not null)
40-
{
41-
o.Explode = bool.Parse(explode);
42-
}
43-
}
44-
},
40+
o.Explode = bool.Parse(explode);
41+
}
42+
}
43+
},
44+
{
45+
"allowReserved", (o, n, _) =>
4546
{
46-
"allowReserved", (o, n, _) =>
47+
var allowReserved = n.GetScalarValue();
48+
if (allowReserved is not null)
4749
{
48-
var allowReserved = n.GetScalarValue();
49-
if (allowReserved is not null)
50-
{
51-
o.AllowReserved = bool.Parse(allowReserved);
52-
}
50+
o.AllowReserved = bool.Parse(allowReserved);
5351
}
54-
},
55-
};
56-
57-
private static readonly PatternFieldMap<OpenApiEncoding> _encodingPatternFields =
58-
new()
59-
{
60-
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))}
61-
};
52+
}
53+
},
54+
};
6255

63-
public static OpenApiEncoding LoadEncoding(ParseNode node, OpenApiDocument hostDocument)
56+
private static readonly PatternFieldMap<OpenApiEncoding> _encodingPatternFields =
57+
new()
6458
{
65-
var mapNode = node.CheckMapNode("encoding");
59+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))}
60+
};
6661

67-
var encoding = new OpenApiEncoding();
68-
foreach (var property in mapNode)
69-
{
70-
property.ParseField(encoding, _encodingFixedFields, _encodingPatternFields, hostDocument);
71-
}
62+
public static OpenApiEncoding LoadEncoding(ParseNode node, OpenApiDocument hostDocument)
63+
{
64+
var mapNode = node.CheckMapNode("encoding");
7265

73-
return encoding;
66+
var encoding = new OpenApiEncoding();
67+
foreach (var property in mapNode)
68+
{
69+
property.ParseField(encoding, _encodingFixedFields, _encodingPatternFields, hostDocument);
7470
}
71+
72+
return encoding;
7573
}
7674
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="coverlet.msbuild" Version="6.0.4" PrivateAssets="all" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
1818
<PackageReference Include="Moq" Version="4.20.72" />
1919
<PackageReference Include="xunit" Version="2.9.3" />
2020
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" PrivateAssets="all" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ItemGroup>
1818
<PackageReference Include="coverlet.collector" Version="6.0.4" PrivateAssets="all" />
1919
<PackageReference Include="coverlet.msbuild" Version="6.0.4" PrivateAssets="all" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
2121
<PackageReference Include="FluentAssertions" Version="7.2.0" />
2222
<PackageReference Include="system.text.json" Version="9.0.9" />
2323
<PackageReference Include="xunit" Version="2.9.3" />
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System.IO;
5+
using System.Threading.Tasks;
6+
using Microsoft.OpenApi.Reader;
7+
using Xunit;
8+
9+
namespace Microsoft.OpenApi.Readers.Tests.V31Tests
10+
{
11+
[Collection("DefaultSettings")]
12+
public class OpenApiEncodingTests
13+
{
14+
private const string SampleFolderPath = "V31Tests/Samples/OpenApiEncoding/";
15+
16+
[Fact]
17+
public async Task ParseEncodingWithAllowReservedShouldSucceed()
18+
{
19+
// Act
20+
var encoding = await OpenApiModelFactory.LoadAsync<OpenApiEncoding>(Path.Combine(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
21+
22+
// Assert
23+
Assert.Equivalent(
24+
new OpenApiEncoding
25+
{
26+
ContentType = "application/x-www-form-urlencoded",
27+
Style = ParameterStyle.Form,
28+
Explode = true,
29+
AllowReserved = true
30+
}, encoding);
31+
}
32+
}
33+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encodingObject
2+
contentType: application/x-www-form-urlencoded
3+
style: form
4+
explode: true
5+
allowReserved: true

test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,22 @@ public async Task ParseAdvancedEncodingShouldSucceed()
5555
}
5656
}, encoding);
5757
}
58+
59+
[Fact]
60+
public async Task ParseEncodingWithAllowReservedShouldSucceed()
61+
{
62+
// Act
63+
var encoding = await OpenApiModelFactory.LoadAsync<OpenApiEncoding>(Path.Combine(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
64+
65+
// Assert
66+
Assert.Equivalent(
67+
new OpenApiEncoding
68+
{
69+
ContentType = "application/x-www-form-urlencoded",
70+
Style = ParameterStyle.Form,
71+
Explode = true,
72+
AllowReserved = true
73+
}, encoding);
74+
}
5875
}
5976
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#encodingObject
2+
contentType: application/x-www-form-urlencoded
3+
style: form
4+
explode: true
5+
allowReserved: true

0 commit comments

Comments
 (0)