Skip to content

Commit c2f0bd3

Browse files
committed
Update tests and integration test files
1 parent 72a6401 commit c2f0bd3

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiRequestBodyGeneratorTests.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public OpenApiRequestBodyGeneratorTest()
3636
var edmAction = new EdmAction("NS", "Checkout", boolType, true, actionEntitySetPath);
3737
edmAction.AddParameter(new EdmOperationParameter(edmAction, "bindingParameter", new EdmEntityTypeReference(customer, true)));
3838
edmAction.AddParameter("param", EdmCoreModel.Instance.GetString(true));
39+
edmAction.AddParameter("param2", EdmCoreModel.Instance.GetString(false));
40+
3941
model.AddElement(edmAction);
4042

4143
var actionImportEntitySetPath = new EdmPathExpression("Param1/Nav2");
@@ -89,9 +91,17 @@ public void CreateRequestBodyForActionImportReturnCorrectRequestBody()
8991
var schema = content.Value.Schema;
9092
Assert.Equal("object", schema.Type);
9193
Assert.NotNull(schema.Properties);
92-
var parameter = Assert.Single(schema.Properties);
93-
Assert.Equal("param", parameter.Key);
94-
Assert.Equal("string", parameter.Value.Type);
94+
95+
var parameters = schema.Properties;
96+
Assert.Equal(2, parameters.Count);
97+
98+
var parameter1 = parameters.First(p => p.Key == "param");
99+
Assert.Equal("param", parameter1.Key);
100+
Assert.Equal("string", parameter1.Value.Type);
101+
102+
var parameter2 = parameters.First(p => p.Key == "param2");
103+
Assert.Equal("param2", parameter2.Key);
104+
Assert.Equal("string", parameter2.Value.Type);
95105
}
96106

97107
[Fact]
@@ -116,6 +126,9 @@ public void CanSerializeAsJsonFromTheCreatedRequestBody()
116126
""param"": {
117127
""type"": ""string"",
118128
""nullable"": true
129+
},
130+
""param2"": {
131+
""type"": ""string""
119132
}
120133
}
121134
}
@@ -146,9 +159,17 @@ public void CreateRequestBodyForActionReturnCorrectRequestBody()
146159
var schema = content.Value.Schema;
147160
Assert.Equal("object", schema.Type);
148161
Assert.NotNull(schema.Properties);
149-
var parameter = Assert.Single(schema.Properties);
150-
Assert.Equal("param", parameter.Key);
151-
Assert.Equal("string", parameter.Value.Type);
162+
163+
var parameters = schema.Properties;
164+
Assert.Equal(2, parameters.Count);
165+
166+
var parameter1 = parameters.First(p => p.Key == "param");
167+
Assert.Equal("param", parameter1.Key);
168+
Assert.Equal("string", parameter1.Value.Type);
169+
170+
var parameter2 = parameters.First(p => p.Key == "param2");
171+
Assert.Equal("param2", parameter2.Key);
172+
Assert.Equal("string", parameter2.Value.Type);
152173
}
153174

154175
[Fact]

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10943,7 +10943,6 @@
1094310943
"in": "body",
1094410944
"name": "body",
1094510945
"description": "Action parameters",
10946-
"required": true,
1094710946
"schema": {
1094810947
"type": "object",
1094910948
"properties": {
@@ -15768,7 +15767,6 @@
1576815767
"in": "body",
1576915768
"name": "body",
1577015769
"description": "Action parameters",
15771-
"required": true,
1577215770
"schema": {
1577315771
"type": "object",
1577415772
"properties": {
@@ -28333,7 +28331,6 @@
2833328331
"in": "body",
2833428332
"name": "body",
2833528333
"description": "Action parameters",
28336-
"required": true,
2833728334
"schema": {
2833828335
"type": "object",
2833928336
"properties": {

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.V2.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7362,7 +7362,6 @@ paths:
73627362
- in: body
73637363
name: body
73647364
description: Action parameters
7365-
required: true
73667365
schema:
73677366
type: object
73687367
properties:
@@ -10613,7 +10612,6 @@ paths:
1061310612
- in: body
1061410613
name: body
1061510614
description: Action parameters
10616-
required: true
1061710615
schema:
1061810616
type: object
1061910617
properties:
@@ -19205,7 +19203,6 @@ paths:
1920519203
- in: body
1920619204
name: body
1920719205
description: Action parameters
19208-
required: true
1920919206
schema:
1921019207
type: object
1921119208
properties:

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12080,8 +12080,7 @@
1208012080
}
1208112081
}
1208212082
}
12083-
},
12084-
"required": true
12083+
}
1208512084
},
1208612085
"responses": {
1208712086
"204": {
@@ -17516,8 +17515,7 @@
1751617515
}
1751717516
}
1751817517
}
17519-
},
17520-
"required": true
17518+
}
1752117519
},
1752217520
"responses": {
1752317521
"204": {
@@ -31640,8 +31638,7 @@
3164031638
}
3164131639
}
3164231640
}
31643-
},
31644-
"required": true
31641+
}
3164531642
},
3164631643
"responses": {
3164731644
"204": {

test/Microsoft.OpenAPI.OData.Reader.Tests/Resources/TripService.OpenApi.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8095,7 +8095,6 @@ paths:
80958095
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
80968096
- type: object
80978097
nullable: true
8098-
required: true
80998098
responses:
81008099
'204':
81018100
description: Success
@@ -11734,7 +11733,6 @@ paths:
1173411733
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
1173511734
- type: object
1173611735
nullable: true
11737-
required: true
1173811736
responses:
1173911737
'204':
1174011738
description: Success
@@ -21275,7 +21273,6 @@ paths:
2127521273
- $ref: '#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person'
2127621274
- type: object
2127721275
nullable: true
21278-
required: true
2127921276
responses:
2128021277
'204':
2128121278
description: Success

0 commit comments

Comments
 (0)