Skip to content

Commit 9548a21

Browse files
committed
clean up code and update failing tests
1 parent 47b3873 commit 9548a21

7 files changed

+10
-24
lines changed

src/Microsoft.OpenApi/Models/OpenApiParameter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
240240
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
241241

242242
// style
243-
writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
243+
if (_style.HasValue)
244+
{
245+
writer.WriteProperty(OpenApiConstants.Style, Style.Value.GetDisplayName());
246+
}
244247

245248
// explode
246249
writer.WriteProperty(OpenApiConstants.Explode, Explode, Style.HasValue && Style.Value == ParameterStyle.Form);

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"name": "tags",
3131
"in": "query",
3232
"description": "tags to filter by",
33-
"style": "form",
3433
"schema": {
3534
"type": "array",
3635
"items": {
@@ -42,7 +41,6 @@
4241
"name": "limit",
4342
"in": "query",
4443
"description": "maximum number of results to return",
45-
"style": "form",
4644
"schema": {
4745
"type": "integer",
4846
"format": "int32"
@@ -266,7 +264,6 @@
266264
"in": "path",
267265
"description": "ID of pet to fetch",
268266
"required": true,
269-
"style": "simple",
270267
"schema": {
271268
"type": "integer",
272269
"format": "int64"
@@ -378,7 +375,6 @@
378375
"in": "path",
379376
"description": "ID of pet to delete",
380377
"required": true,
381-
"style": "simple",
382378
"schema": {
383379
"type": "integer",
384380
"format": "int64"

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"name": "tags",
3131
"in": "query",
3232
"description": "tags to filter by",
33-
"style": "form",
3433
"schema": {
3534
"type": "array",
3635
"items": {
@@ -42,7 +41,6 @@
4241
"name": "limit",
4342
"in": "query",
4443
"description": "maximum number of results to return",
45-
"style": "form",
4644
"schema": {
4745
"type": "integer",
4846
"format": "int32"
@@ -151,7 +149,6 @@
151149
"in": "path",
152150
"description": "ID of pet to fetch",
153151
"required": true,
154-
"style": "simple",
155152
"schema": {
156153
"type": "integer",
157154
"format": "int64"
@@ -205,7 +202,6 @@
205202
"in": "path",
206203
"description": "ID of pet to delete",
207204
"required": true,
208-
"style": "simple",
209205
"schema": {
210206
"type": "integer",
211207
"format": "int64"

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"in": "path",
2121
"description": "The first operand",
2222
"required": true,
23-
"style": "simple",
2423
"schema": {
2524
"type": "integer",
2625
"my-extension": 4
@@ -32,7 +31,6 @@
3231
"in": "path",
3332
"description": "The second operand",
3433
"required": true,
35-
"style": "simple",
3634
"schema": {
3735
"type": "integer",
3836
"my-extension": 4

test/Microsoft.OpenApi.Tests/Models/OpenApiOperationTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,11 @@ public void SerializeOperationWithBodyAsV3JsonWorks()
334334
""parameters"": [
335335
{
336336
""name"": ""parameter1"",
337-
""in"": ""path"",
338-
""style"": ""simple""
337+
""in"": ""path""
339338
},
340339
{
341340
""name"": ""parameter2"",
342-
""in"": ""header"",
343-
""style"": ""simple""
341+
""in"": ""header""
344342
}
345343
],
346344
""requestBody"": {
@@ -409,13 +407,11 @@ public void SerializeAdvancedOperationWithTagAndSecurityAsV3JsonWorks()
409407
""parameters"": [
410408
{
411409
""name"": ""parameter1"",
412-
""in"": ""path"",
413-
""style"": ""simple""
410+
""in"": ""path""
414411
},
415412
{
416413
""name"": ""parameter2"",
417-
""in"": ""header"",
418-
""style"": ""simple""
414+
""in"": ""header""
419415
}
420416
],
421417
""requestBody"": {
@@ -505,7 +501,6 @@ public void SerializeOperationWithFormDataAsV3JsonWorks()
505501
""in"": ""path"",
506502
""description"": ""ID of pet that needs to be updated"",
507503
""required"": true,
508-
""style"": ""simple"",
509504
""schema"": {
510505
""type"": ""string""
511506
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"name": "name1",
3-
"in": "path",
4-
"style": "simple"
3+
"in": "path"
54
}

test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ public void SerializeBasicParameterAsV3JsonWorks()
250250
// Arrange
251251
var expected = @"{
252252
""name"": ""name1"",
253-
""in"": ""path"",
254-
""style"": ""simple""
253+
""in"": ""path""
255254
}";
256255

257256
// Act

0 commit comments

Comments
 (0)