1 package io.swagger.v3.oas.annotations.media;
2
3 import io.swagger.v3.oas.annotations.OpenAPI31;
4
5 import java.lang.annotation.Inherited;
6 import java.lang.annotation.Repeatable;
7 import java.lang.annotation.Retention;
8 import java.lang.annotation.RetentionPolicy;
9 import java.lang.annotation.Target;
10
11 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
12 import static java.lang.annotation.ElementType.FIELD;
13 import static java.lang.annotation.ElementType.METHOD;
14 import static java.lang.annotation.ElementType.PARAMETER;
15 import static java.lang.annotation.ElementType.TYPE;
16
17 /**
18  * The annotation may be used to define dependent schemas for an Object Schema
19  *
20  * @see Schema
21  *
22  * @since 2.2.12 / OpenAPI 3.1
23  **/

24 @Target({FIELD, METHOD, PARAMETER, TYPE, ANNOTATION_TYPE})
25 @Retention(RetentionPolicy.RUNTIME)
26 @Inherited
27 @Repeatable(DependentSchemas.class)
28 @OpenAPI31
29 public @interface DependentSchema {
30     /**
31      * The name.
32      *
33      * @return the key of the dependent schema map item
34      **/

35     String name() default "";
36
37     /**
38      * The value (Schema) of the dependent schema map item.
39      * Alternative to `array()`. Applied when the schema is not of type "array".
40      * Use `array()` when schema is of type "array"
41      *
42      * @return the schema
43      **/

44     Schema schema() default @Schema();
45
46     /**
47      * The value (ArraySchema) of the dependent schema map item.
48      * Alternative to `schema()`. Applied when the schema is of type "array".
49      * Use `schema()` when schema is not of type "array"
50      *
51      * @return the value of the array schema
52      */

53     ArraySchema array() default @ArraySchema();
54
55 }
56