File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 12
12
<SignAssembly >true</SignAssembly >
13
13
<AssemblyOriginatorKeyFile >..\..\src\Microsoft.OpenApi.snk</AssemblyOriginatorKeyFile >
14
14
</PropertyGroup >
15
+ <ItemGroup >
16
+ <None Remove =" V3Tests\Samples\OpenApiOperation\securedOperation.yaml" />
17
+ </ItemGroup >
15
18
<ItemGroup >
16
19
<EmbeddedResource Include =" OpenApiReaderTests\Samples\unsupported.v1.yaml" >
17
20
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
109
112
<EmbeddedResource Include =" V3Tests\Samples\OpenApiInfo\minimalInfo.yaml" >
110
113
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
111
114
</EmbeddedResource >
115
+ <EmbeddedResource Include =" V3Tests\Samples\OpenApiOperation\securedOperation.yaml" />
112
116
<EmbeddedResource Include =" V3Tests\Samples\OpenApiSchema\advancedSchemaWithReference.yaml" >
113
117
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
114
118
</EmbeddedResource >
Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT license.
3
+
4
+ using System . IO ;
5
+ using System . Linq ;
6
+ using Xunit ;
7
+
8
+ namespace Microsoft . OpenApi . Readers . Tests . V3Tests
9
+ {
10
+ public class OpenApiOperationTests
11
+ {
12
+ private const string SampleFolderPath = "V3Tests/Samples/OpenApiOperation/" ;
13
+
14
+ [ Fact ]
15
+ public void OperationWithSecurityRequirementShouldReferenceSecurityScheme ( )
16
+ {
17
+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "securedOperation.yaml" ) ) )
18
+ {
19
+ var openApiDoc = new OpenApiStreamReader ( ) . Read ( stream , out var diagnostic ) ;
20
+
21
+ var securityRequirement = openApiDoc . Paths [ "/" ] . Operations [ Models . OperationType . Get ] . Security . First ( ) ;
22
+
23
+ Assert . Same ( securityRequirement . Keys . First ( ) , openApiDoc . Components . SecuritySchemes . First ( ) . Value ) ;
24
+ }
25
+ }
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.0
2
+ info :
3
+ title : Example of Security Requirement referencing a security scheme
4
+ version : 1.0.0
5
+ paths :
6
+ ' / ' :
7
+ get :
8
+ security :
9
+ - basicAuth : []
10
+ responses :
11
+ ' 200 ' :
12
+ description : OK
13
+ components :
14
+ securitySchemes :
15
+ basicAuth :
16
+ type : http
17
+ scheme : basic
You can’t perform that action at this time.
0 commit comments