Class FieldDescriptor
java.lang.Object
org.springframework.restdocs.snippet.AbstractDescriptor<T>
org.springframework.restdocs.snippet.IgnorableDescriptor<FieldDescriptor>
org.springframework.restdocs.payload.FieldDescriptor
- Direct Known Subclasses:
SubsectionDescriptor
A description of a field found in a request or response payload.
- Author:
- Andreas Evers, Andy Wilkinson
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
FieldDescriptor
(String path) Creates a newFieldDescriptor
describing the field with the givenpath
. -
Method Summary
Modifier and TypeMethodDescriptionfinal String
getPath()
Returns the path of the field described by this descriptor.final Object
getType()
Returns the type of the field described by this descriptor.final boolean
Returnstrue
if the described field is optional, otherwisefalse
.final FieldDescriptor
optional()
Marks the field as optional.final FieldDescriptor
Specifies the type of the field.Methods inherited from class org.springframework.restdocs.snippet.IgnorableDescriptor
ignored, isIgnored
Methods inherited from class org.springframework.restdocs.snippet.AbstractDescriptor
attributes, description, getAttributes, getDescription
-
Constructor Details
-
FieldDescriptor
Creates a newFieldDescriptor
describing the field with the givenpath
.- Parameters:
path
- the path
-
-
Method Details
-
type
Specifies the type of the field. When documenting a JSON payload, theJsonFieldType
enumeration will typically be used.- Parameters:
type
- the type of the field- Returns:
this
- See Also:
-
optional
Marks the field as optional.- Returns:
this
-
getPath
Returns the path of the field described by this descriptor.- Returns:
- the path
-
getType
Returns the type of the field described by this descriptor.- Returns:
- the type
-
isOptional
public final boolean isOptional()Returnstrue
if the described field is optional, otherwisefalse
.- Returns:
true
if the described field is optional, otherwisefalse
-