@Documented @Target(value={PARAMETER,FIELD,METHOD,TYPE}) @Retention(value=RUNTIME) @Inherited public @interface Query
Identifies a POJO to be used as a form-data entry on an HTTP request.
Can be used in the following locations:
Unlike @FormData
, using this annotation does not result in the servlet reading the contents of
URL-encoded form posts.
Therefore, this annotation can be used in conjunction with the @Body
annotation or
This is functionally equivalent to the following code...
Modifier and Type | Optional Element and Description |
---|---|
String[] |
_default
|
String[] |
_enum
|
boolean |
allowEmptyValue
|
String[] |
api
Free-form value for the Swagger Parameter Object.
|
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
URL query parameter name.
|
Class<? extends HttpPartParser> |
parser
Specifies the
HttpPartParser class used for parsing strings to values. |
String |
pattern
|
boolean |
required
|
Class<? extends HttpPartSerializer> |
serializer
Specifies the
HttpPartSerializer class used for serializing values to strings. |
boolean |
skipIfEmpty
Skips this value during serialization if it's an empty string or empty collection/array.
|
String |
type
|
boolean |
uniqueItems
|
String |
value
A synonym for
name() . |
public abstract boolean skipIfEmpty
Note that
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 client which by default is OpenApiSerializer
.
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 String name
The value should be either a valid query parameter name, or
A blank value (the default) has the following behavior:
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 the existence of a query entry:
public abstract String[] description
A brief description of the parameter. This could contain examples of use.
public abstract boolean required
Determines whether the parameter is mandatory.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
public abstract String type
The type of the parameter.
The possible values are:
ObjectList
.
ObjectMap
.
Static strings are defined in ParameterType
.
public abstract String format
The extending format for the previously mentioned parameter type.
The possible values are:
Static strings are defined in FormatType
.
public abstract boolean allowEmptyValue
Sets the ability to pass empty-valued parameters.
This is valid only for either query or formData parameters and allows you to send a parameter with a name only or an empty value.
The default value is
public abstract Items items
Describes the type of items in the array.
Required if
Can only be used if
public abstract String collectionFormat
Determines the format of the array if
Can only be used if
Possible values are:
OpenApiSerializer
.
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[] _default
Declares the value of the parameter that the server will use if none is provided, for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
(Note: "default" has no meaning for required parameters.)
Additionally, this value is used to create instances of POJOs that are then serialized as language-specific examples in the generated Swagger documentation if the examples are not defined in some other way.
The format of this value is a string.
Multiple lines are concatenated with newlines.
public abstract String maximum
Defines the maximum value for a parameter of numeric types.
The value must be a valid JSON number.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract boolean exclusiveMaximum
Defines whether the maximum is matched exclusively.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
If
public abstract String minimum
Defines the minimum value for a parameter of numeric types.
The value must be a valid JSON number.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract boolean exclusiveMinimum
Defines whether the minimum is matched exclusively.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
If
public abstract long maxLength
A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
The length of a string instance is defined as the number of its characters as defined by RFC 4627.
The value
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract long minLength
A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
The length of a string instance is defined as the number of its characters as defined by RFC 4627.
The value
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract String pattern
A string input 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
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract long maxItems
An array or collection is valid if its size is less than, or equal to, the value of this keyword.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract long minItems
An array or collection is valid if its size is greater than, or equal to, the value of this keyword.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract boolean uniqueItems
If
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
If the parameter type is a subclass of Set
, this validation is skipped (since a set can only contain unique items anyway).
Otherwise, the collection or array is checked for duplicate items.
Only allowed for the following types:
public abstract String[] _enum
If specified, the input validates successfully if it is equal to one of the elements in this array.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
The format is a Simple JSON array or comma-delimited list.
Multiple lines are concatenated with newlines.
public abstract String multipleOf
A numeric instance is valid if the result of the division of the instance by this keyword's value is an integer.
The value must be a valid JSON number.
If validation fails during serialization or parsing, the part serializer/parser will throw a SchemaValidationException
.
On the client-side, this gets converted to a
On the server-side, this gets converted to a
Only allowed for the following types:
public abstract String[] example
This attribute defines a representation of the value that is used by
If not specified, Juneau will automatically create examples from sample POJOs serialized using the registered HttpPartSerializer
.
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 Query object:
The reasons why you may want to use this field include:
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.