@Documented @Target(value={PARAMETER,TYPE,METHOD}) @Retention(value=RUNTIME) @Inherited public @interface Response
Identifies an interface to use to interact with HTTP parts of an HTTP response through a bean.
Can be used in the following locations:
Modifier and Type | Optional Element and Description |
---|---|
String[] |
api
Free-form value for the Swagger Response Object.
|
int[] |
code
The HTTP response code.
|
String[] |
d
Synonym for
description() . |
String[] |
description
|
String[] |
ex
Synonym for
example() . |
String[] |
example
A serialized example of the body of a response.
|
String[] |
examples
Serialized examples of the body of a response.
|
String[] |
exs
Synonym for
examples() . |
ResponseHeader[] |
headers
|
Class<? extends HttpPartParser> |
parser
Specifies the
HttpPartParser class used for parsing strings to values. |
Schema |
schema
|
Class<? extends HttpPartSerializer> |
serializer
Specifies the
HttpPartSerializer class used for serializing values to strings. |
int[] |
value
A synonym for
code() . |
public abstract Class<? extends HttpPartParser> parser
HttpPartParser
class used for parsing strings to values.
Overrides for this part the part parser defined on the REST resource which by default is OpenApiParser
.
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 int[] code
public abstract int[] value
code()
.
Allows you to use shortened notation if you're only specifying the code.
The following are completely equivalent ways of defining the response code:
public abstract String[] description
public abstract String[] d
description()
.public abstract Schema schema
public abstract ResponseHeader[] headers
public abstract String[] example
This is the Overview > juneau-marshall > JSON Details > Simplified JSON of an example of the body.
This value is converted to a POJO and then serialized to all the registered serializers on the REST method to produce examples for all
supported language types.
These values are then used to automatically populate the examples()
field.
There are several other options for defining this example:
@ResourceSwagger (value)
/@MethodSwagger (value)
).
The latter is important because Juneau also supports auto-generation of JSON-Schema from POJO classes using JsonSchemaSerializer
which has several of it's own
options for auto-detecting and calculation POJO examples.
In particular, examples can be defined via static methods, fields, and annotations on the classes themselves.
Examples can also be specified via generic properties as well using the BeanContext.BEAN_examples
property at either the class or method level.
JsonParser.DEFAULT
or a simple String if the object
has a schema associated with it meancan be converted from a String.
public abstract String[] examples
This is a Overview > juneau-marshall > JSON Details > Simplified JSON object whose keys are media types and values are string representations of that value.
In general you won't need to populate this value directly since it will automatically be calculated based on the value provided in the example()
field.
However, this field allows you to override the behavior and show examples for only specified media types or different examples for different media types.
public abstract String[] exs
examples()
.public abstract String[] api
This is a Overview > juneau-marshall > JSON Details > Simplified JSON object that makes up the swagger information for this field.
The following are completely equivalent ways of defining the swagger description of the Response object:
The reasons why you may want to use this field include:
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.