File tree Expand file tree Collapse file tree 5 files changed +31
-0
lines changed
src/Microsoft.OpenApi/Services
test/Microsoft.OpenApi.Readers.Tests Expand file tree Collapse file tree 5 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public void Walk(OpenApiDocument doc)
44
44
Walk ( OpenApiConstants . Servers , ( ) => Walk ( doc . Servers ) ) ;
45
45
Walk ( OpenApiConstants . Paths , ( ) => Walk ( doc . Paths ) ) ;
46
46
Walk ( OpenApiConstants . Components , ( ) => Walk ( doc . Components ) ) ;
47
+ Walk ( OpenApiConstants . Security , ( ) => Walk ( doc . SecurityRequirements ) ) ;
47
48
Walk ( OpenApiConstants . ExternalDocs , ( ) => Walk ( doc . ExternalDocs ) ) ;
48
49
Walk ( OpenApiConstants . Tags , ( ) => Walk ( doc . Tags ) ) ;
49
50
Walk ( doc as IOpenApiExtensible ) ;
Original file line number Diff line number Diff line change 13
13
<AssemblyOriginatorKeyFile >..\..\src\Microsoft.OpenApi.snk</AssemblyOriginatorKeyFile >
14
14
</PropertyGroup >
15
15
<ItemGroup >
16
+ <None Remove =" V3Tests\Samples\OpenApiDocument\securedApi.yaml" />
16
17
<None Remove =" V3Tests\Samples\OpenApiOperation\securedOperation.yaml" />
17
18
</ItemGroup >
18
19
<ItemGroup >
97
98
<EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\petStoreWithTagAndSecurity.yaml" >
98
99
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
99
100
</EmbeddedResource >
101
+ <EmbeddedResource Include =" V3Tests\Samples\OpenApiDocument\securedApi.yaml" />
100
102
<EmbeddedResource Include =" V3Tests\Samples\OpenApiEncoding\advancedEncoding.yaml" >
101
103
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
102
104
</EmbeddedResource >
Original file line number Diff line number Diff line change 4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . IO ;
7
+ using System . Linq ;
7
8
using FluentAssertions ;
8
9
using Microsoft . OpenApi . Models ;
9
10
using Newtonsoft . Json ;
@@ -1110,5 +1111,18 @@ public void ParsePetStoreExpandedShouldSucceed()
1110
1111
context . ShouldBeEquivalentTo (
1111
1112
new OpenApiDiagnostic ( ) { SpecificationVersion = OpenApiSpecVersion . OpenApi3_0 } ) ;
1112
1113
}
1114
+
1115
+ [ Fact ]
1116
+ public void GlobalSecurityRequirementShouldReferenceSecurityScheme ( )
1117
+ {
1118
+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "securedApi.yaml" ) ) )
1119
+ {
1120
+ var openApiDoc = new OpenApiStreamReader ( ) . Read ( stream , out var diagnostic ) ;
1121
+
1122
+ var securityRequirement = openApiDoc . SecurityRequirements . First ( ) ;
1123
+
1124
+ Assert . Same ( securityRequirement . Keys . First ( ) , openApiDoc . Components . SecuritySchemes . First ( ) . Value ) ;
1125
+ }
1126
+ }
1113
1127
}
1114
1128
}
Original file line number Diff line number Diff line change @@ -23,5 +23,7 @@ public void OperationWithSecurityRequirementShouldReferenceSecurityScheme()
23
23
Assert . Same ( securityRequirement . Keys . First ( ) , openApiDoc . Components . SecuritySchemes . First ( ) . Value ) ;
24
24
}
25
25
}
26
+
27
+
26
28
}
27
29
}
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
+ security :
7
+ - basicAuth : []
8
+ components :
9
+ securitySchemes :
10
+ basicAuth :
11
+ type : http
12
+ scheme : basic
You can’t perform that action at this time.
0 commit comments