File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,29 @@ class DefinitionGenerator {
312312 obj . security = documentation . security
313313 }
314314
315+ if ( this . currentEvent ?. private && this . currentEvent . private === true ) {
316+ let apiKeyName = 'x-api-key'
317+ let hasXAPIKey = false
318+ if ( this . openAPI ?. components ?. [ this . componentTypes . securitySchemes ] ) {
319+ for ( const [ schemeName , schemeValue ] of Object . entries ( this . openAPI . components [ this . componentTypes . securitySchemes ] ) ) {
320+ if ( schemeValue . type === 'apiKey' && schemeValue . name === 'x-api-key' ) {
321+ apiKeyName = schemeName
322+ hasXAPIKey = true
323+ }
324+ }
325+ }
326+
327+ if ( hasXAPIKey === false ) {
328+ this . createSecuritySchemes ( { [ apiKeyName ] : { type : 'apiKey' , name : apiKeyName , in : 'header' } } )
329+ }
330+
331+ if ( obj . security ) {
332+ obj . security . push ( { [ apiKeyName ] : [ ] } )
333+ } else {
334+ obj . security = [ { [ apiKeyName ] : [ ] } ]
335+ }
336+ }
337+
315338 if ( Object . keys ( documentation ) . includes ( 'deprecated' ) )
316339 obj . deprecated = documentation . deprecated
317340
You can’t perform that action at this time.
0 commit comments