@@ -11,6 +11,7 @@ type ComponentInfo = {
1111
1212export const NoUnusedComponents : Oas3Rule = ( ) => {
1313 const components = new Map < string , ComponentInfo > ( ) ;
14+ const securitySchemeLocations = new Map < string , Location > ( ) ;
1415 const usedSecuritySchemeComponents = new Set < string > ( ) ;
1516
1617 function registerComponent (
@@ -59,6 +60,15 @@ export const NoUnusedComponents: Oas3Rule = () => {
5960 } ) ;
6061 }
6162 } ) ;
63+ securitySchemeLocations . forEach ( ( location , name ) => {
64+ if ( ! usedSecuritySchemeComponents . has ( name ) ) {
65+ report ( {
66+ message : `Security scheme: "${ name } " is never used.` ,
67+ location : location . key ( ) ,
68+ reference : 'https://redocly.com/docs/cli/rules/oas/no-unused-components' ,
69+ } ) ;
70+ }
71+ } ) ;
6272 } ,
6373 } ,
6474 NamedSchemas : {
@@ -100,15 +110,8 @@ export const NoUnusedComponents: Oas3Rule = () => {
100110 } ,
101111 } ,
102112 NamedSecuritySchemes : {
103- SecurityScheme ( _securityScheme , { location, key, report } ) {
104- const name = key . toString ( ) ;
105- if ( ! usedSecuritySchemeComponents . has ( name ) ) {
106- report ( {
107- message : `Security scheme: "${ name } " is never used.` ,
108- location : location . key ( ) ,
109- reference : 'https://redocly.com/docs/cli/rules/oas/no-unused-components' ,
110- } ) ;
111- }
113+ SecurityScheme ( _securityScheme , { location, key } ) {
114+ securitySchemeLocations . set ( key . toString ( ) , location ) ;
112115 } ,
113116 } ,
114117 SecurityRequirement ( requirements ) {
0 commit comments