1 package io.swagger.v3.oas.annotations.media;
2
3 import io.swagger.v3.oas.annotations.OpenAPI31;
4 import io.swagger.v3.oas.annotations.extensions.Extension;
5
6 import java.lang.annotation.Inherited;
7 import java.lang.annotation.Retention;
8 import java.lang.annotation.RetentionPolicy;
9 import java.lang.annotation.Target;
10
11 /**
12  * The annotation may be used in {@link Schema#discriminatorMapping()} to define an optional mapping definition
13  * in scenarios involving composition / inheritance where the value of the discriminator field does not match the schema
14  * name or implicit mapping is not possible.
15  *
16  * <p>Use {@link Schema#discriminatorProperty()} to define a discriminator property.</p>
17  *
18  * @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#discriminatorObject">Discriminator (OpenAPI specification)</a>
19  * @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#discriminatorObject">Discriminator (OpenAPI specification)</a>
20  * @see Schema
21  **/

22 @Target({})
23 @Retention(RetentionPolicy.RUNTIME)
24 @Inherited
25 public @interface DiscriminatorMapping {
26
27     /**
28      * The property value that will be mapped to a Schema
29      *
30      * @return the property value
31      **/

32     String value() default "";
33
34     /**
35      * The schema that is being mapped to a property value
36      *
37      * @return the Schema reference
38      **/

39     Class<?> schema() default Void.class;
40
41     /**
42      * The list of optional extensions
43      *
44      * @since 2.2.12 / OpenAPI 3.1
45      * @return an optional array of extensions
46      */

47     @OpenAPI31
48     Extension[] extensions() default {};
49
50 }
51