Class HttpPartSchema
The schema definition can be applied to any HTTP parts such as bodies, headers, query/form parameters, and URL path parts.
The API is generic enough to apply to any path part although some attributes may only applicable for certain parts.
Schema objects are created via builders instantiated through the create() method.
Jakarta Bean Validation Support:
As of 9.2.0, this class supports Jakarta Bean Validation constraint annotations (e.g.,
@NotNull →required(true) @Size(min=x, max=y) →minLength/maxLength andminItems/maxItems @Min(value) →minimum(value) @Max(value) →maximum(value) @Pattern(regexp) →pattern(regexp) @Email →format("email") @Positive/@PositiveOrZero/@Negative/@NegativeOrZero → Corresponding min/max constraints@NotEmpty →required(true) + minLength(1)/minItems(1) @NotBlank →required(true) + minLength(1) + pattern @DecimalMin/@DecimalMax →minimum/maximum with optionalexclusiveMinimum/exclusiveMaximum
This integration uses pure reflection and does not require
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpPartSchemaReusable instance of this object, all default settings.static final HttpPartSchemaArray typestatic final HttpPartSchemaComma-delimited array typestatic final HttpPartSchemaMulti-part array typestatic final HttpPartSchemaPipe-delimited array typestatic final HttpPartSchemaSpace-delimited array typestatic final HttpPartSchemaTab-delimited array typestatic final HttpPartSchemaUON-formatted array typestatic final HttpPartSchemaBinary typestatic final HttpPartSchemaSpaced binary typestatic final HttpPartSchemaBoolean typestatic final HttpPartSchemaByte typestatic final HttpPartSchemaDate typestatic final HttpPartSchemaDate-time typestatic final HttpPartSchemaDouble typestatic final HttpPartSchemaFile typestatic final HttpPartSchemaFloat typestatic final HttpPartSchemaInt32 typestatic final HttpPartSchemaInt64 typestatic final HttpPartSchemaInteger typestatic final HttpPartSchemaNo typestatic final HttpPartSchemaNumber typestatic final HttpPartSchemaObject typestatic final HttpPartSchemaComma-delimited object typestatic final HttpPartSchemaPipe-delimited object typestatic final HttpPartSchemaSpace-delimited object typestatic final HttpPartSchemaTab-delimited object typestatic final HttpPartSchemaUON-formated object typestatic final HttpPartSchemaString typestatic final HttpPartSchemaUON-formated simple type -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpPartSchema.Buildercreate()Instantiates a new builder for this object.static HttpPartSchemacreate(Annotation a) Finds the schema information on the specified annotation.static HttpPartSchemacreate(Annotation a, String defaultName) Finds the schema information on the specified annotation.static HttpPartSchemacreate(Class<? extends Annotation> c, Method m) Finds the schema information for the specified method return.static HttpPartSchemacreate(Class<? extends Annotation> c, Type t) Finds the schema information for the specified class.static HttpPartSchemacreate(Class<? extends Annotation> c, ParameterInfo mpi) Finds the schema information for the specified method parameter.static HttpPartSchema.BuilderShortcut for callingcreate().type(type); static HttpPartSchema.BuilderShortcut for callingcreate().type(type).format(format); Returns thecollectionFormat field of this schema.Returns thedefault field of this schema.getEnum()Returns theenum field of this schema.Returns theformat field of this schema.Returns theformat field of this schema.getItems()Returns themaximum field of this schema.Returns themaximum field of this schema.Returns thexxx field of this schema.Returns thexxx field of this schema.Returns thexxx field of this schema.Returns theminimum field of this schema.Returns thexxx field of this schema.Returns thexxx field of this schema.Returns thexxx field of this schema.Returns thexxx field of this schema.getName()Returns the name of the object described by this schema, for example the query or form parameter name.ClassMeta<?>Returns the default parsed type for this schema.Class<? extends HttpPartParser>Returns theparser field of this schema.Returns thexxx field of this schema.getProperty(String name) Returns the schema information for the specified property.Class<? extends HttpPartSerializer>Returns theserializer field of this schema.getType()Returns thetype field of this schema.Returns thetype field of this schema.booleanReturnstrue if this schema has properties associated with it.booleanReturns theallowEmptyValue field of this schema.booleanReturns theexclusiveMaximum field of this schema.booleanReturns theexclusiveMinimum field of this schema.booleanReturns therequired field of this schema.booleanReturns theskipIfEmpty field of this schema.booleanReturns theuniqueItems field of this schema.static HttpPartSchema.BuildertArray()Shortcut for .create ().type(HttpPartDataType.ARRAY )static HttpPartSchema.BuildertArray(HttpPartSchema.Builder items) Shortcut for .create ().type(HttpPartDataType.ARRAY ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.CSV )static HttpPartSchema.BuildertArrayCsv(HttpPartSchema.Builder items) Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.CSV ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.MULTI )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.MULTI ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.PIPES )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.PIPES ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.SSV )static HttpPartSchema.BuildertArraySsv(HttpPartSchema.Builder items) Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.SSV ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.TSV )static HttpPartSchema.BuildertArrayTsv(HttpPartSchema.Builder items) Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.TSV ).items(items)static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.UONC )static HttpPartSchema.BuildertArrayUon(HttpPartSchema.Builder items) Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.UONC ).items(items)static HttpPartSchema.BuildertBinary()Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BINARY )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BINARY_SPACED )static HttpPartSchema.BuildertBoolean()Shortcut for .create ().type(HttpPartDataType.BOOLEAN )static HttpPartSchema.BuildertByte()Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BYTE )static HttpPartSchema.BuildertDate()Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.DATE )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.DATE_TIME )static HttpPartSchema.BuildertDouble()Shortcut for .create ().type(HttpPartDataType.NUMBER ).format(HttpPartFormat.DOUBLE )static HttpPartSchema.BuildertFile()Shortcut for .create ().type(HttpPartDataType.FILE )static HttpPartSchema.BuildertFloat()Shortcut for .create ().type(HttpPartDataType.NUMBER ).format(HttpPartFormat.FLOAT )static HttpPartSchema.BuildertInt32()Shortcut for .create ().type(HttpPartDataType.INTEGER ).format(HttpPartFormat.INT32 )static HttpPartSchema.BuildertInt64()Shortcut for .create ().type(HttpPartDataType.INTEGER ).format(HttpPartFormat.INT64 )static HttpPartSchema.BuildertInteger()Shortcut for .create ().type(HttpPartDataType.INTEGER )static HttpPartSchema.BuildertNone()Shortcut for .create ().type(HttpPartDataType.NONE )static HttpPartSchema.BuildertNumber()Shortcut for .create ().type(HttpPartDataType.NUMBER )static HttpPartSchema.BuildertObject()Shortcut for .create ().type(HttpPartDataType.OBJECT )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.CSV )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.PIPES )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.SSV )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.TSV )static HttpPartSchema.BuilderShortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.UON )toString()static HttpPartSchema.BuildertString()Shortcut for .create ().type(HttpPartDataType.STRING )static HttpPartSchema.BuildertUon()Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.UON )validateInput(String in) Throws aParseExceptionif the specified pre-parsed input does not validate against this schema.<T> TvalidateOutput(T o, BeanContext bc) Throws aParseExceptionif the specified parsed output does not validate against this schema.
-
Field Details
-
DEFAULT
Reusable instance of this object, all default settings. -
T_BOOLEAN
Boolean type -
T_FILE
File type -
T_INTEGER
Integer type -
T_INT32
Int32 type -
T_INT64
Int64 type -
T_NONE
No type -
T_NUMBER
Number type -
T_FLOAT
Float type -
T_DOUBLE
Double type -
T_STRING
String type -
T_BYTE
Byte type -
T_BINARY
Binary type -
T_BINARY_SPACED
Spaced binary type -
T_DATE
Date type -
T_DATETIME
Date-time type -
T_UON
UON-formated simple type -
T_ARRAY
Array type -
T_ARRAY_CSV
Comma-delimited array type -
T_ARRAY_PIPES
Pipe-delimited array type -
T_ARRAY_SSV
Space-delimited array type -
T_ARRAY_TSV
Tab-delimited array type -
T_ARRAY_UON
UON-formatted array type -
T_ARRAY_MULTI
Multi-part array type -
T_OBJECT
Object type -
T_OBJECT_CSV
Comma-delimited object type -
T_OBJECT_PIPES
Pipe-delimited object type -
T_OBJECT_SSV
Space-delimited object type -
T_OBJECT_TSV
Tab-delimited object type -
T_OBJECT_UON
UON-formated object type
-
-
Method Details
-
create
Instantiates a new builder for this object.- Returns:
- A new builder for this object.
-
create
Finds the schema information on the specified annotation.- Parameters:
a- The annotation to find the schema information on..- Returns:
- The schema information found on the annotation.
-
create
Finds the schema information on the specified annotation.- Parameters:
a- The annotation to find the schema information on..defaultName- The default part name if not specified on the annotation.- Returns:
- The schema information found on the annotation.
-
create
Finds the schema information for the specified class.This method will gather all the schema information from the annotations on the class and all parent classes/interfaces.
-
create
Finds the schema information for the specified method return.This method will gather all the schema information from the annotations at the following locations:
- The method.
- The method return class.
- The method return parent classes and interfaces.
-
create
Finds the schema information for the specified method parameter.This method will gather all the schema information from the annotations at the following locations:
- The method parameter.
- The method parameter class.
- The method parameter parent classes and interfaces.
-
create
Shortcut for callingcreate().type(type); - Parameters:
type- The schema type value.- Returns:
- A new builder.
-
create
Shortcut for callingcreate().type(type).format(format); - Parameters:
type- The schema type value.format- The schema format value.- Returns:
- A new builder.
-
tArray
Shortcut for .create ().type(HttpPartDataType.ARRAY )- Returns:
- A new builder for this object.
-
tArray
Shortcut for .create ().type(HttpPartDataType.ARRAY ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArrayCsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.CSV )- Returns:
- A new builder for this object.
-
tArrayCsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.CSV ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArrayMulti
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.MULTI )- Returns:
- A new builder for this object.
-
tArrayMulti
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.MULTI ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArrayPipes
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.PIPES )- Returns:
- A new builder for this object.
-
tArrayPipes
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.PIPES ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArraySsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.SSV )- Returns:
- A new builder for this object.
-
tArraySsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.SSV ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArrayTsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.TSV )- Returns:
- A new builder for this object.
-
tArrayTsv
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.TSV ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tArrayUon
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.UONC )- Returns:
- A new builder for this object.
-
tArrayUon
Shortcut for .create ().type(HttpPartDataType.ARRAY ).collectionFormat(HttpPartCollectionFormat.UONC ).items(items)- Parameters:
items- The schema of the array items.- Returns:
- A new builder for this object.
-
tBinary
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BINARY )- Returns:
- A new builder for this object.
-
tBinarySpaced
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BINARY_SPACED )- Returns:
- A new builder for this object.
-
tBoolean
Shortcut for .create ().type(HttpPartDataType.BOOLEAN )- Returns:
- A new builder for this object.
-
tByte
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.BYTE )- Returns:
- A new builder for this object.
-
tDate
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.DATE )- Returns:
- A new builder for this object.
-
tDateTime
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.DATE_TIME )- Returns:
- A new builder for this object.
-
tDouble
Shortcut for .create ().type(HttpPartDataType.NUMBER ).format(HttpPartFormat.DOUBLE )- Returns:
- A new builder for this object.
-
tFile
Shortcut for .create ().type(HttpPartDataType.FILE )- Returns:
- A new builder for this object.
-
tFloat
Shortcut for .create ().type(HttpPartDataType.NUMBER ).format(HttpPartFormat.FLOAT )- Returns:
- A new builder for this object.
-
tInt32
Shortcut for .create ().type(HttpPartDataType.INTEGER ).format(HttpPartFormat.INT32 )- Returns:
- A new builder for this object.
-
tInt64
Shortcut for .create ().type(HttpPartDataType.INTEGER ).format(HttpPartFormat.INT64 )- Returns:
- A new builder for this object.
-
tInteger
Shortcut for .create ().type(HttpPartDataType.INTEGER )- Returns:
- A new builder for this object.
-
tNone
Shortcut for .create ().type(HttpPartDataType.NONE )- Returns:
- A new builder for this object.
-
tNumber
Shortcut for .create ().type(HttpPartDataType.NUMBER )- Returns:
- A new builder for this object.
-
tObject
Shortcut for .create ().type(HttpPartDataType.OBJECT )- Returns:
- A new builder for this object.
-
tObjectCsv
Shortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.CSV )- Returns:
- A new builder for this object.
-
tObjectPipes
Shortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.PIPES )- Returns:
- A new builder for this object.
-
tObjectSsv
Shortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.SSV )- Returns:
- A new builder for this object.
-
tObjectTsv
Shortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.TSV )- Returns:
- A new builder for this object.
-
tObjectUon
Shortcut for .create ().type(HttpPartDataType.OBJECT ).collectionFormat(HttpPartCollectionFormat.UON )- Returns:
- A new builder for this object.
-
tString
Shortcut for .create ().type(HttpPartDataType.STRING )- Returns:
- A new builder for this object.
-
tUon
Shortcut for .create ().type(HttpPartDataType.STRING ).format(HttpPartFormat.UON )- Returns:
- A new builder for this object.
-
getCollectionFormat
Returns thecollectionFormat field of this schema.- Returns:
- The
collectionFormat field of this schema, ornull if not specified. - See Also:
-
getDefault
Returns thedefault field of this schema.- Returns:
- The default value for this schema, or
null if not specified. - See Also:
-
getEnum
Returns theenum field of this schema.- Returns:
- The
enum field of this schema, ornull if not specified. - See Also:
-
getFormat
Returns theformat field of this schema.- Returns:
- The
format field of this schema, ornull if not specified. - See Also:
-
getFormat
Returns theformat field of this schema.- Parameters:
cm- The class meta of the object.
Used to auto-detect the format if the format was not specified.- Returns:
- The
format field of this schema, ornull if not specified. - See Also:
-
getItems
Returns themaximum field of this schema.- Returns:
- The schema for child items of the object represented by this schema, or
null if not defined. - See Also:
-
getMaximum
Returns themaximum field of this schema.- Returns:
- The
maximum field of this schema, ornull if not specified. - See Also:
-
getMaxItems
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMaxLength
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMaxProperties
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMinimum
Returns theminimum field of this schema.- Returns:
- The
minimum field of this schema, ornull if not specified. - See Also:
-
getMinItems
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMinLength
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMinProperties
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getMultipleOf
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getName
Returns the name of the object described by this schema, for example the query or form parameter name.- Returns:
- The name, or
null if not specified. - See Also:
-
getParsedType
Returns the default parsed type for this schema.- Returns:
- The default parsed type for this schema. Never
null .
-
getParser
Returns theparser field of this schema.- Returns:
- The
parser field of this schema, ornull if not specified. - See Also:
-
getPattern
Returns thexxx field of this schema.- Returns:
- The
xxx field of this schema, ornull if not specified. - See Also:
-
getProperty
Returns the schema information for the specified property.- Parameters:
name- The property name.- Returns:
- The schema information for the specified property, or
null if properties are not defined on this schema.
-
getSerializer
Returns theserializer field of this schema.- Returns:
- The
serializer field of this schema, ornull if not specified. - See Also:
-
getType
Returns thetype field of this schema.- Returns:
- The
type field of this schema, ornull if not specified. - See Also:
-
getType
Returns thetype field of this schema.- Parameters:
cm- The class meta of the object.
Used to auto-detect the type if the type was not specified.- Returns:
- The format field of this schema, or
null if not specified. - See Also:
-
hasProperties
Returnstrue if this schema has properties associated with it.- Returns:
true if this schema has properties associated with it.
-
isAllowEmptyValue
Returns theallowEmptyValue field of this schema.- Returns:
- The
skipIfEmpty field of this schema. - See Also:
-
isExclusiveMaximum
Returns theexclusiveMaximum field of this schema.- Returns:
- The
exclusiveMaximum field of this schema. - See Also:
-
isExclusiveMinimum
Returns theexclusiveMinimum field of this schema.- Returns:
- The
exclusiveMinimum field of this schema. - See Also:
-
isRequired
Returns therequired field of this schema.- Returns:
- The
required field of this schema. - See Also:
-
isSkipIfEmpty
Returns theskipIfEmpty field of this schema.- Returns:
- The
skipIfEmpty field of this schema. - See Also:
-
isUniqueItems
Returns theuniqueItems field of this schema.- Returns:
- The
uniqueItems field of this schema. - See Also:
-
properties
-
toString
-
validateInput
Throws aParseExceptionif the specified pre-parsed input does not validate against this schema.- Parameters:
in- The input.- Returns:
- The same object passed in.
- Throws:
SchemaValidationException- if the specified pre-parsed input does not validate against this schema.
-
validateOutput
Throws aParseExceptionif the specified parsed output does not validate against this schema.- Type Parameters:
T- The return type.- Parameters:
o- The parsed output.bc- The bean context used to detect POJO types.- Returns:
- The same object passed in.
- Throws:
SchemaValidationException- if the specified parsed output does not validate against this schema.
-