Skip to content

Commit 6eeca52

Browse files
authored
Merge pull request #2519 from microsoft/fix/allow-reserved-to-v1
fix: typo in encoding allow reserved deserialization
2 parents 63e0715 + 3fadb7d commit 6eeca52

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static partial class OpenApiV3Deserializer
3232
(o, n) => o.Explode = bool.Parse(n.GetScalarValue())
3333
},
3434
{
35-
"allowedReserved",
35+
"allowReserved",
3636
(o, n) => o.AllowReserved = bool.Parse(n.GetScalarValue())
3737
},
3838
};

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,29 @@ public void ParseAdvancedEncodingShouldSucceed()
7676
}
7777
});
7878
}
79+
[Fact]
80+
public void ParseEncodingWithAllowReservedShouldSucceed()
81+
{
82+
using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "encodingWithAllowReserved.yaml"));
83+
var yamlStream = new YamlStream();
84+
yamlStream.Load(new StreamReader(stream));
85+
var yamlNode = yamlStream.Documents.First().RootNode;
86+
87+
var diagnostic = new OpenApiDiagnostic();
88+
var context = new ParsingContext(diagnostic);
89+
90+
var node = new MapNode(context, (YamlMappingNode)yamlNode);
91+
var encoding = OpenApiV3Deserializer.LoadEncoding(node);
92+
93+
// Assert
94+
Assert.Equivalent(
95+
new OpenApiEncoding
96+
{
97+
ContentType = "application/x-www-form-urlencoded",
98+
Style = ParameterStyle.Form,
99+
Explode = true,
100+
AllowReserved = true
101+
}, encoding);
102+
}
79103
}
80104
}
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)