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
ConstructorsModifierConstructorDescriptionprotectedFieldDescriptor(String path) Creates a newFieldDescriptordescribing the field with the givenpath. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetPath()Returns the path of the field described by this descriptor.final ObjectgetType()Returns the type of the field described by this descriptor.final booleanReturnstrueif the described field is optional, otherwisefalse.final FieldDescriptoroptional()Marks the field as optional.final FieldDescriptorSpecifies the type of the field.Methods inherited from class org.springframework.restdocs.snippet.IgnorableDescriptor
ignored, isIgnoredMethods inherited from class org.springframework.restdocs.snippet.AbstractDescriptor
attributes, description, getAttributes, getDescription
-
Constructor Details
-
FieldDescriptor
Creates a newFieldDescriptordescribing the field with the givenpath.- Parameters:
path- the path
-
-
Method Details
-
type
Specifies the type of the field. When documenting a JSON payload, theJsonFieldTypeenumeration 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()Returnstrueif the described field is optional, otherwisefalse.- Returns:
trueif the described field is optional, otherwisefalse
-