File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { DiagnosticSeverity } from "@stoplight/types" ;
2
+ import testRule from "./__helpers__/helper" ;
3
+
4
+ testRule ( "adv-security-schemes-defined" , [
5
+ {
6
+ name : "valid case" ,
7
+ document : {
8
+ openapi : "3.1.0" ,
9
+ info : { version : "1.0" } ,
10
+ components : {
11
+ securitySchemes : {
12
+ "oAuth2" : {
13
+ type : "oauth2" ,
14
+ flow : { } ,
15
+ } ,
16
+ } ,
17
+ } ,
18
+ } ,
19
+ errors : [ ] ,
20
+ } ,
21
+
22
+ {
23
+ name : "invalid case" ,
24
+ document : {
25
+ openapi : "3.1.0" ,
26
+ info : { version : "1.0" } ,
27
+ components : { } ,
28
+ } ,
29
+ errors : [
30
+ {
31
+ message : "This API definition does not have any security scheme defined." ,
32
+ path : [ "components" ] ,
33
+ severity : DiagnosticSeverity . Error ,
34
+ } ,
35
+ ] ,
36
+ } ,
37
+ ] ) ;
Original file line number Diff line number Diff line change @@ -278,5 +278,18 @@ export default {
278
278
formats : [ oas3 ] ,
279
279
severity : DiagnosticSeverity . Warning ,
280
280
} ,
281
+
282
+ // Author: Advanced API & Integrations Team (https://www.oneadvanced.com/)
283
+ "adv-security-schemes-defined" : {
284
+ description : "All APIs MUST have a security scheme defined." ,
285
+ message : "This API definition does not have any security scheme defined." ,
286
+ given : "$..components" ,
287
+ then : {
288
+ field : "securitySchemes" ,
289
+ function : truthy
290
+ } ,
291
+ formats : [ oas3 ] ,
292
+ severity : DiagnosticSeverity . Error ,
293
+ } ,
281
294
} ,
282
295
} ;
You can’t perform that action at this time.
0 commit comments