1 package io.swagger.v3.oas.annotations.security;
2
3 import java.lang.annotation.Inherited;
4 import java.lang.annotation.Repeatable;
5 import java.lang.annotation.Retention;
6 import java.lang.annotation.RetentionPolicy;
7 import java.lang.annotation.Target;
8
9 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
10 import static java.lang.annotation.ElementType.TYPE;
11 import static java.lang.annotation.ElementType.METHOD;
12
13 /**
14  * The annotation may be applied at class or method level, or in {@link io.swagger.v3.oas.annotations.Operation#security()} ()} to define security requirements for the
15  * single operation (when applied at method level) or for all operations of a class (when applied at class level).
16  * <p>It can also be used in {@link io.swagger.v3.oas.annotations.OpenAPIDefinition#security()} to define spec level security.</p>
17  *
18  * @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#securityRequirementObject">Security Requirement (OpenAPI specification)</a>
19  * @see io.swagger.v3.oas.annotations.OpenAPIDefinition
20  * @see io.swagger.v3.oas.annotations.Operation
21  **/

22 @Target({METHOD, TYPE, ANNOTATION_TYPE})
23 @Retention(RetentionPolicy.RUNTIME)
24 @Repeatable(SecurityRequirements.class)
25 @Inherited
26 public @interface SecurityRequirement {
27     /**
28      * This name must correspond to a declared SecurityRequirement.
29      *
30      * @return String name
31      */

32     String name();
33
34     /**
35      * If the security scheme is of type "oauth2" or "openIdConnect", then the value is a list of scope names required for the execution.
36      * For other security scheme types, the array must be empty.
37      *
38      * @return String array of scopes
39      */

40     String[] scopes() default {};
41 }
42