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)
Creates a new
AbstractFieldsSnippet that will produce a snippet 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. |
document, getAttributes, getSnippetName
protected AbstractFieldsSnippet(String type, List<FieldDescriptor> descriptors, Map<String,Object> attributes)
AbstractFieldsSnippet
that will produce a snippet 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.type
- the type of the fieldsdescriptors
- the field descriptorsattributes
- the additional attributesprotected 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 Map<String,Object> createModelForDescriptor(FieldDescriptor descriptor)
descriptor
descriptor
- the descriptor