@Documented @Target(value={PARAMETER,METHOD,TYPE}) @Retention(value=RUNTIME) @Inherited public @interface ResponseHeader
Annotation used to denote an HTTP response header.
Can be used in the following locations:
On server-side REST, this annotation can be applied to method parameters to identify them as an HTTP response header.
In this case, the annotation can only be applied to subclasses of type Value
.
The following examples show 3 different ways of accomplishing the same task of setting an HTTP header on a response:
On server-side REST, this annotation can also be applied to public methods of Response
-annotated methods.
Modifier and Type | Optional Element and Description |
---|---|
String[] |
_default
|
String[] |
_enum
|
String |
$ref
|
String[] |
api
Free-form value for the Swagger Header Object.
|
int[] |
code
The HTTP status (or statuses) of the response.
|
String |
collectionFormat
|
String[] |
description
|
String[] |
example
A serialized example of the parameter.
|
boolean |
exclusiveMaximum
|
boolean |
exclusiveMinimum
|
String |
format
|
Items |
items
|
String |
maximum
|
long |
maxItems
|
long |
maxLength
|
String |
minimum
|
long |
minItems
|
long |
minLength
|
String |
multipleOf
|
String |
name
The HTTP header name.
|
String |
pattern
|
Class<? extends HttpPartSerializer> |
serializer
Specifies the
HttpPartSerializer class used for serializing values to strings. |
String |
type
|
boolean |
uniqueItems
|
String |
value
A synonym for
name() . |
public abstract int[] code
public abstract String value
name()
.
Allows you to use shortened notation if you're only specifying the name.
The following are completely equivalent ways of defining a response header:
public abstract Class<? extends HttpPartSerializer> serializer
HttpPartSerializer
class used for serializing values to strings.
Overrides for this part the part serializer defined on the REST resource which by default is OpenApiSerializer
.
public abstract String[] description
public abstract String type
The type of the parameter.
The possible values are:
Static strings are defined in ParameterType
.
public abstract String format
The possible values are:
Static strings are defined in FormatType
.
public abstract String collectionFormat
Determines the format of the array if
Can only be used if
Possible values are:
Static strings are defined in CollectionFormatType
.
Note that for collections/arrays parameters with POJO element types, the input is broken into a string array before being converted into POJO elements.
public abstract String $ref
Denotes a reference to a definition object.
public abstract String multipleOf
public abstract long maxLength
public abstract long minLength
public abstract String pattern
A string value is valid if it matches the specified regular expression pattern.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
Only allowed for the following types:
public abstract long maxItems
public abstract long minItems
public abstract boolean exclusiveMaximum
public abstract boolean exclusiveMinimum
public abstract boolean uniqueItems
public abstract String[] example
This attribute defines a representation of the value that is used by
public abstract String[] api
This is a Simple JSON object that makes up the swagger information for this field.
The following are completely equivalent ways of defining the swagger description of the Header object:
The reasons why you may want to use this field include:
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.