Annotation Type Schema
-
@Target({FIELD,METHOD,PARAMETER,TYPE,ANNOTATION_TYPE}) @Retention(RUNTIME) @Inherited public @interface Schema
The annotation may be used to define a Schema for a set of elements of the OpenAPI spec, and/or to define additional properties for the schema. It is applicable e.g. to parameters, schema classes (aka "models"), properties of such models, request and response content, header.swagger-core resolver and swagger-jaxrs2 reader engine consider this annotation along with JAX-RS annotations, element type and context as input to resolve the annotated element into an OpenAPI schema definition for such element.
The annotation may be used also to override partly (e.g. the name) or fully (e.g providing a completely different representation) the schema of an element; for example if a specific class is provided as value of
implementation(), it will override the element typeThe annotation
ArraySchemashall be used for array elements;ArraySchemaandSchemacannot coexist- See Also:
- Schema (OpenAPI specification),
ArraySchema
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Schema.AccessModeaccessModeAllows to specify the access mode (AccessMode.READ_ONLY, READ_WRITE) AccessMode.READ_ONLY: value will not be written to during a request but may be returned during a response.Schema.AdditionalPropertiesValueadditionalPropertiesAllows to specify the additionalProperties value AdditionalPropertiesValue.TRUE: set to TRUE AdditionalPropertiesValue.FALSE: set to FALSE AdditionalPropertiesValue.USE_ADDITIONAL_PROPERTIES_ANNOTATION: resolve from @Content.additionalPropertiesSchemaClass<?>[]allOfProvides an array of java class implementations which can be used to describe multiple acceptable schemas.String[]allowableValuesProvides a list of allowable values.Class<?>[]anyOfProvides an array of java class implementations which can be used to describe multiple acceptable schemas.StringdefaultValueProvides a default value.booleandeprecatedSpecifies that a schema is deprecated and should be transitioned out of usage.StringdescriptionA description of the schema.DiscriminatorMapping[]discriminatorMappingProvides discriminator mapping values.StringdiscriminatorPropertyProvides a discriminator property value.booleanenumAsRefAllows enums to be resolved as a reference to a scheme added to components section.StringexampleProvides an example of the schema.booleanexclusiveMaximumif true, makes the maximum value exclusive, or a less-than criteria.booleanexclusiveMinimumIf true, makes the minimum value exclusive, or a greater-than criteria.Extension[]extensionsThe list of optional extensionsExternalDocumentationexternalDocsAdditional external documentation for this schema.StringformatProvides an optional override for the format.booleanhiddenAllows schema to be marked as hidden.Class<?>implementationProvides a java class as implementation for this schema.StringmaximumSets the maximum numeric value for a property.intmaxLengthSets the maximum length of a string value.intmaxPropertiesConstrains the number of arbitrary properties when additionalProperties is defined.StringminimumSets the minimum numeric value for a property.intminLengthSets the minimum length of a string value.intminPropertiesConstrains the number of arbitrary properties when additionalProperties is defined.doublemultipleOfConstrains a value such that when divided by the multipleOf, the remainder must be an integer.StringnameThe name of the schema or property.Class<?>notProvides a java class to be used to disallow matching properties.booleannullableIf true, designates a value as possibly null.Class<?>[]oneOfProvides an array of java class implementations which can be used to describe multiple acceptable schemas.StringpatternA pattern that the value must satisfy.booleanreadOnlyDeprecated.As of 2.0.0, replaced byaccessMode()StringrefReferences a schema definition in an external OpenAPI document.booleanrequiredDeprecated.since 2.2.5, replaced byrequiredMode()Schema.RequiredModerequiredModeAllows to specify the required mode (RequiredMode.AUTO, REQUIRED, NOT_REQUIRED) RequiredMode.AUTO: will let the library decide based on its heuristics.String[]requiredPropertiesAllows multiple properties in an object to be marked as required.Class<?>[]subTypesAn array of the sub types inheriting from this model.StringtitleA title to explain the purpose of the schema.StringtypeProvides an override for the basic type of the schema.booleanwriteOnlyDeprecated.As of 2.0.0, replaced byaccessMode()
-
-
-
Element Detail
-
implementation
Class<?> implementation
Provides a java class as implementation for this schema. When provided, additional information in the Schema annotation (except for type information) will augment the java class after introspection.- Returns:
- a class that implements this schema
- Default:
- java.lang.Void.class
-
-
-
not
Class<?> not
Provides a java class to be used to disallow matching properties.- Returns:
- a class with disallowed properties
- Default:
- java.lang.Void.class
-
-
-
oneOf
Class<?>[] oneOf
Provides an array of java class implementations which can be used to describe multiple acceptable schemas. If more than one match the derived schemas, a validation error will occur.- Returns:
- the list of possible classes for a single match
- Default:
- {}
-
-
-
anyOf
Class<?>[] anyOf
Provides an array of java class implementations which can be used to describe multiple acceptable schemas. If any match, the schema will be considered valid.- Returns:
- the list of possible class matches
- Default:
- {}
-
-
-
allOf
Class<?>[] allOf
Provides an array of java class implementations which can be used to describe multiple acceptable schemas. If all match, the schema will be considered valid- Returns:
- the list of classes to match
- Default:
- {}
-
-
-
name
String name
The name of the schema or property.- Returns:
- the name of the schema
- Default:
- ""
-
-
-
title
String title
A title to explain the purpose of the schema.- Returns:
- the title of the schema
- Default:
- ""
-
-
-
maximum
String maximum
Sets the maximum numeric value for a property. Ignored if the value is an empty string.- Returns:
- the maximum value for this schema
- Default:
- ""
-
-
-
minimum
String minimum
Sets the minimum numeric value for a property. Ignored if the value is an empty string or not a number.- Returns:
- the minimum value for this schema
- Default:
- ""
-
-
-
pattern
String pattern
A pattern that the value must satisfy. Ignored if the value is an empty string.- Returns:
- the pattern of this schema
- Default:
- ""
-
-
-
requiredProperties
String[] requiredProperties
Allows multiple properties in an object to be marked as required.- Returns:
- the list of required schema properties
- Default:
- {}
-
-
-
required
@Deprecated boolean required
Deprecated.since 2.2.5, replaced byrequiredMode()Mandates that the annotated item is required or not.- Returns:
- whether this schema is required
- Default:
- false
-
-
-
requiredMode
Schema.RequiredMode requiredMode
Allows to specify the required mode (RequiredMode.AUTO, REQUIRED, NOT_REQUIRED) RequiredMode.AUTO: will let the library decide based on its heuristics. RequiredMode.REQUIRED: will force the item to be considered as required regardless of heuristics. RequiredMode.NOT_REQUIRED: will force the item to be considered as not required regardless of heuristics.- Returns:
- the requiredMode for this schema (property)
- Since:
- 2.2.5
- Default:
- io.swagger.v3.oas.annotations.media.Schema.RequiredMode.AUTO
-
-
-
description
String description
A description of the schema.- Returns:
- the schema's description
- Default:
- ""
-
-
-
format
String format
Provides an optional override for the format. If a consumer is unaware of the meaning of the format, they shall fall back to using the basic type without format. For example, if \"type: integer, format: int128\" were used to designate a very large integer, most consumers will not understand how to handle it, and fall back to simply \"type: integer\"- Returns:
- the schema's format
- Default:
- ""
-
-
-
ref
String ref
References a schema definition in an external OpenAPI document.- Returns:
- a reference to this schema
- Default:
- ""
-
-
-
readOnly
@Deprecated boolean readOnly
Deprecated.As of 2.0.0, replaced byaccessMode()Sets whether the value should only be read during a response but not read to during a request.- Returns:
- whether or not this schema is read only
- Default:
- false
-
-
-
writeOnly
@Deprecated boolean writeOnly
Deprecated.As of 2.0.0, replaced byaccessMode()Sets whether a value should only be written to during a request but not returned during a response.- Returns:
- whether or not this schema is write only
- Default:
- false
-
-
-
accessMode
Schema.AccessMode accessMode
Allows to specify the access mode (AccessMode.READ_ONLY, READ_WRITE) AccessMode.READ_ONLY: value will not be written to during a request but may be returned during a response. AccessMode.WRITE_ONLY: value will only be written to during a request but not returned during a response. AccessMode.READ_WRITE: value will be written to during a request and returned during a response.- Returns:
- the accessMode for this schema (property)
- Default:
- io.swagger.v3.oas.annotations.media.Schema.AccessMode.AUTO
-
-
-
example
String example
Provides an example of the schema. When associated with a specific media type, the example string shall be parsed by the consumer to be treated as an object or an array.- Returns:
- an example of this schema
- Default:
- ""
-
-
-
externalDocs
ExternalDocumentation externalDocs
Additional external documentation for this schema.- Returns:
- additional schema documentation
- Default:
- @io.swagger.v3.oas.annotations.ExternalDocumentation
-
-
-
type
String type
Provides an override for the basic type of the schema. Must be a valid type per the OpenAPI Specification.- Returns:
- the type of this schema
- Default:
- ""
-
-
-
allowableValues
String[] allowableValues
Provides a list of allowable values. This field map to the enum property in the OAS schema.- Returns:
- a list of allowed schema values
- Default:
- {}
-
-
-
defaultValue
String defaultValue
Provides a default value.- Returns:
- the default value of this schema
- Default:
- ""
-
-
-
discriminatorProperty
String discriminatorProperty
Provides a discriminator property value.- Returns:
- the discriminator property
- Default:
- ""
-
-
-
discriminatorMapping
DiscriminatorMapping[] discriminatorMapping
Provides discriminator mapping values.- Returns:
- the discriminator mappings
- Default:
- {}
-
-
-
hidden
boolean hidden
Allows schema to be marked as hidden.- Returns:
- whether or not this schema is hidden
- Default:
- false
-
-
-
subTypes
Class<?>[] subTypes
An array of the sub types inheriting from this model.- Default:
- {}
-
-
-
extensions
Extension[] extensions
The list of optional extensions- Returns:
- an optional array of extensions
- Default:
- {}
-
-
-
additionalProperties
Schema.AdditionalPropertiesValue additionalProperties
Allows to specify the additionalProperties value AdditionalPropertiesValue.TRUE: set to TRUE AdditionalPropertiesValue.FALSE: set to FALSE AdditionalPropertiesValue.USE_ADDITIONAL_PROPERTIES_ANNOTATION: resolve from @Content.additionalPropertiesSchema- Returns:
- the accessMode for this schema (property)
- Since:
- 2.2.0
- Default:
- io.swagger.v3.oas.annotations.media.Schema.AdditionalPropertiesValue.USE_ADDITIONAL_PROPERTIES_ANNOTATION
-
-