File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed
test/Microsoft.OpenApi.Readers.Tests Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 14
14
</PropertyGroup >
15
15
<ItemGroup >
16
16
<None Remove =" V2Tests\Samples\ComponentRootReference.json" />
17
+ <None Remove =" V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml" />
17
18
<None Remove =" V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml" />
18
19
<None Remove =" V3Tests\Samples\OpenApiWorkspace\TodoComponents.yaml" />
19
20
<None Remove =" V3Tests\Samples\OpenApiWorkspace\TodoMain.yaml" />
89
90
<EmbeddedResource Include =" V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml" >
90
91
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
91
92
</EmbeddedResource >
93
+ <EmbeddedResource Include =" V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml" >
94
+ <CopyToOutputDirectory >Never</CopyToOutputDirectory >
95
+ </EmbeddedResource >
92
96
<EmbeddedResource Include =" V2Tests\Samples\OpenApiPathItem\basicPathItemWithFormData.yaml" >
93
97
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
94
98
</EmbeddedResource >
Original file line number Diff line number Diff line change @@ -275,7 +275,29 @@ public void ParsePathItemWithFormDataPathParameterShouldSucceed()
275
275
276
276
// Assert
277
277
// FormData parameters at in the path level are pushed into Operation request bodies.
278
- Assert . True ( pathItem . Operations . All ( o => o . Value . RequestBody != null ) ) ;
278
+ Assert . True ( pathItem . Operations [ OperationType . Put ] . RequestBody != null ) ;
279
+ Assert . True ( pathItem . Operations [ OperationType . Post ] . RequestBody != null ) ;
280
+ Assert . Equal ( 2 , pathItem . Operations . Count ( o => o . Value . RequestBody != null ) ) ;
279
281
}
282
+ [ Fact ]
283
+ public void ParsePathItemBodyDataPathParameterShouldSucceed ( )
284
+ {
285
+ // Arrange
286
+ MapNode node ;
287
+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "pathItemWithBodyPathParameter.yaml" ) ) )
288
+ {
289
+ node = TestHelper . CreateYamlMapNode ( stream ) ;
290
+ }
291
+
292
+ // Act
293
+ var pathItem = OpenApiV2Deserializer . LoadPathItem ( node ) ;
294
+
295
+ // Assert
296
+ // FormData parameters at in the path level are pushed into Operation request bodies.
297
+ Assert . True ( pathItem . Operations [ OperationType . Put ] . RequestBody != null ) ;
298
+ Assert . True ( pathItem . Operations [ OperationType . Post ] . RequestBody != null ) ;
299
+ Assert . Equal ( 2 , pathItem . Operations . Count ( o => o . Value . RequestBody != null ) ) ;
300
+ }
301
+
280
302
}
281
303
}
Original file line number Diff line number Diff line change
1
+ put :
2
+ summary : Puts a pet in the store with form data
3
+ description : " "
4
+ responses :
5
+ ' 200 ' :
6
+ description : Pet updated.
7
+ ' 405 ' :
8
+ description : Invalid input
9
+ post :
10
+ summary : Posts a pet in the store with form data
11
+ description : " "
12
+ responses :
13
+ ' 200 ' :
14
+ description : Pet updated.
15
+ parameters :
16
+ - name : petId
17
+ in : path
18
+ description : ID of pet that needs to be updated
19
+ required : true
20
+ schema :
21
+ type : string
22
+ - name : name
23
+ in : body
24
+ description : Updated pet body
25
+ required : true
26
+ type : object
27
+ properties :
28
+ name :
29
+ type : string
30
+ status :
31
+ type : string
You can’t perform that action at this time.
0 commit comments