public abstract class AbstractFieldsSnippet extends TemplatedSnippet
TemplatedSnippet
subclass that provides a base for snippets that
document a RESTful resource's request or response fields.Modifier | Constructor and Description |
---|---|
protected |
AbstractFieldsSnippet(String type,
List<FieldDescriptor> descriptors,
Map<String,Object> attributes,
boolean ignoreUndocumentedFields)
Creates a new
AbstractFieldsSnippet that will produce a snippet named
<type>-fields using a template named <type>-fields . |
protected |
AbstractFieldsSnippet(String type,
List<FieldDescriptor> descriptors,
Map<String,Object> attributes,
boolean ignoreUndocumentedFields,
PayloadSubsectionExtractor<?> subsectionExtractor)
Creates a new
AbstractFieldsSnippet that will produce a snippet named
<type>-fields using a template named <type>-fields . |
protected |
AbstractFieldsSnippet(String name,
String type,
List<FieldDescriptor> descriptors,
Map<String,Object> attributes,
boolean ignoreUndocumentedFields)
Creates a new
AbstractFieldsSnippet that will produce a snippet named
<name>-fields using a template named <type>-fields . |
protected |
AbstractFieldsSnippet(String name,
String type,
List<FieldDescriptor> descriptors,
Map<String,Object> attributes,
boolean ignoreUndocumentedFields,
PayloadSubsectionExtractor<?> subsectionExtractor)
Creates a new
AbstractFieldsSnippet that will produce a snippet named
<name>-fields using a template named <type>-fields . |
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
createModel(Operation operation)
Create the model that should be used during template rendering to document the
given
operation . |
protected Map<String,Object> |
createModelForDescriptor(FieldDescriptor descriptor)
Returns a model for the given
descriptor . |
protected abstract byte[] |
getContent(Operation operation)
Returns the content of the request or response extracted form the given
operation . |
protected abstract MediaType |
getContentType(Operation operation)
Returns the content type of the request or response extracted from the given
operation . |
protected List<FieldDescriptor> |
getFieldDescriptors()
Returns the list of
FieldDescriptors that will be used to
generate the documentation. |
protected PayloadSubsectionExtractor<?> |
getSubsectionExtractor()
Returns the
PayloadSubsectionExtractor , if any, used by this snippet. |
protected boolean |
isIgnoredUndocumentedFields()
Returns whether or not this snippet ignores undocumented fields.
|
document, getAttributes, getSnippetName
protected AbstractFieldsSnippet(String type, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields)
AbstractFieldsSnippet
that will produce a snippet named
<type>-fields
using a template named <type>-fields
. The fields will
be documented using the given descriptors
and the given attributes
will be included in the model during template rendering. If
ignoreUndocumentedFields
is true
, undocumented fields will be
ignored and will not trigger a failure.type
- the type of the fieldsdescriptors
- the field descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignoredprotected AbstractFieldsSnippet(String type, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields, PayloadSubsectionExtractor<?> subsectionExtractor)
AbstractFieldsSnippet
that will produce a snippet named
<type>-fields
using a template named <type>-fields
. The fields in
the subsection of the payload extracted by the given subsectionExtractor
will be documented using the given descriptors
and the given
attributes
will be included in the model during template rendering. If
ignoreUndocumentedFields
is true
, undocumented fields will be
ignored and will not trigger a failure.type
- the type of the fieldsdescriptors
- the field descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignoredsubsectionExtractor
- the subsection extractorprotected AbstractFieldsSnippet(String name, String type, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields)
AbstractFieldsSnippet
that will produce a snippet named
<name>-fields
using a template named <type>-fields
. The fields will
be documented using the given descriptors
and the given attributes
will be included in the model during template rendering. If
ignoreUndocumentedFields
is true
, undocumented fields will be
ignored and will not trigger a failure.name
- the name of the snippettype
- the type of the fieldsdescriptors
- the field descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignoredprotected AbstractFieldsSnippet(String name, String type, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields, PayloadSubsectionExtractor<?> subsectionExtractor)
AbstractFieldsSnippet
that will produce a snippet named
<name>-fields
using a template named <type>-fields
. The fields in
the subsection of the payload identified by subsectionPath
will be
documented using the given descriptors
and the given attributes
will be included in the model during template rendering. If
ignoreUndocumentedFields
is true
, undocumented fields will be
ignored and will not trigger a failure.name
- the name of the snippettype
- the type of the fieldsdescriptors
- the field descriptorsattributes
- the additional attributesignoreUndocumentedFields
- whether undocumented fields should be ignoredsubsectionExtractor
- the subsection extractor documented. null
or an
empty string can be used to indicate that the entire payload should be documented.protected Map<String,Object> createModel(Operation operation)
TemplatedSnippet
operation
. Any additional attributes that were supplied when this
TemplatedSnippet
were created will be automatically added to the model
prior to rendering.createModel
in class TemplatedSnippet
operation
- the operationprotected abstract MediaType getContentType(Operation operation)
operation
.operation
- the operationprotected abstract byte[] getContent(Operation operation) throws IOException
operation
.operation
- the operationIOException
- if the content cannot be extractedprotected final List<FieldDescriptor> getFieldDescriptors()
FieldDescriptors
that will be used to
generate the documentation.protected final boolean isIgnoredUndocumentedFields()
true
if undocumented fields are ignored, otherwise false
protected final PayloadSubsectionExtractor<?> getSubsectionExtractor()
PayloadSubsectionExtractor
, if any, used by this snippet.null
protected Map<String,Object> createModelForDescriptor(FieldDescriptor descriptor)
descriptor
.descriptor
- the descriptor