protected void registerSecurity ( Swagger swagger , Operation operation , Method method ) { RequireToken requireToken = ClassUtil . getAnnotation ( method , RequireToken . class ) ; if ( requireToken != null ) { String apiKeyName = requireToken . value ( ) ; if ( swagger . getSecurityDefinitions ( ) == null || ! swagger . getSecurityDefinitions ( ) . containsKey ( apiKeyName ) ) { ApiKeyAuthDefinition security = new ApiKeyAuthDefinition ( ) ; security . setName ( apiKeyName ) ; security . setIn ( In . HEADER ) ; security . setType ( "apiKey" ) ; swagger . addSecurityDefinition ( apiKeyName , security ) ; } operation . addSecurity ( apiKeyName , Collections . emptyList ( ) ) ; } BasicAuth basicAuth = ClassUtil . getAnnotation ( method , BasicAuth . class ) ; if ( basicAuth != null ) { if ( swagger . getSecurityDefinitions ( ) == null || ! swagger . getSecurityDefinitions ( ) . containsKey ( "basic" ) ) { BasicAuthDefinition security = new BasicAuthDefinition ( ) ; swagger . addSecurityDefinition ( "basic" , security ) ; } operation . addSecurity ( "basic" , Collections . emptyList ( ) ) ; } }
Register authentication security .