Class RequestPartFieldsSnippet

All Implemented Interfaces:
Snippet

public class RequestPartFieldsSnippet extends AbstractFieldsSnippet
A Snippet that documents the fields in a request part.
Since:
1.2.0
Author:
Mathieu Pousse, Andy Wilkinson
See Also:
  • Constructor Details

    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors)
      Creates a new RequestPartFieldsSnippet that will document the fields in the request part using the given descriptors. Undocumented fields will trigger a failure.
      Parameters:
      partName - the part name
      descriptors - the descriptors
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields)
      Creates a new RequestPartFieldsSnippet that will document the fields in the request part using the given descriptors. If ignoreUndocumentedFields is true, undocumented fields will be ignored and will not trigger a failure.
      Parameters:
      partName - the part name
      descriptors - the descriptors
      ignoreUndocumentedFields - whether undocumented fields should be ignored
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, Map<String,Object> attributes)
      Creates a new RequestFieldsSnippet that will document the fields in the request using the given descriptors. The given attributes will be included in the model during template rendering. Undocumented fields will trigger a failure.
      Parameters:
      partName - the part name
      descriptors - the descriptors
      attributes - the additional attributes
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields)
      Creates a new RequestFieldsSnippet that will document the fields in the request using the given descriptors. 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.
      Parameters:
      partName - the part name
      descriptors - the descriptors
      attributes - the additional attributes
      ignoreUndocumentedFields - whether undocumented fields should be ignored
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors)
      Creates a new RequestPartFieldsSnippet that will document the fields in a subsection of the request part using the given descriptors. The subsection will be extracted using the given subsectionExtractor. Undocumented fields will trigger a failure.
      Parameters:
      partName - the part name
      subsectionExtractor - the subsection extractor
      descriptors - the descriptors
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, boolean ignoreUndocumentedFields)
      Creates a new RequestPartFieldsSnippet that will document the fields in a subsection the request part using the given descriptors. The subsection will be extracted using the given subsectionExtractor. If ignoreUndocumentedFields is true, undocumented fields will be ignored and will not trigger a failure.
      Parameters:
      partName - the part name
      subsectionExtractor - the subsection extractor
      descriptors - the descriptors
      ignoreUndocumentedFields - whether undocumented fields should be ignored
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String,Object> attributes)
      Creates a new RequestPartFieldsSnippet that will document the fields in a subsection of the request part using the given descriptors. The subsection will be extracted using the given subsectionExtractor. The given attributes will be included in the model during template rendering. Undocumented fields will trigger a failure.
      Parameters:
      partName - the part name
      subsectionExtractor - the subsection extractor
      descriptors - the descriptors
      attributes - the additional attributes
    • RequestPartFieldsSnippet

      protected RequestPartFieldsSnippet(String partName, PayloadSubsectionExtractor<?> subsectionExtractor, List<FieldDescriptor> descriptors, Map<String,Object> attributes, boolean ignoreUndocumentedFields)
      Creates a new RequestPartFieldsSnippet that will document the fields in a subsection of the request part using the given descriptors. The subsection will be extracted using the given subsectionExtractor. 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.
      Parameters:
      partName - the part name
      subsectionExtractor - the subsection extractor
      descriptors - the descriptors
      attributes - the additional attributes
      ignoreUndocumentedFields - whether undocumented fields should be ignored
  • Method Details

    • getContentType

      protected org.springframework.http.MediaType getContentType(Operation operation)
      Description copied from class: AbstractFieldsSnippet
      Returns the content type of the request or response extracted from the given operation.
      Specified by:
      getContentType in class AbstractFieldsSnippet
      Parameters:
      operation - the operation
      Returns:
      the content type
    • getContent

      protected byte[] getContent(Operation operation) throws IOException
      Description copied from class: AbstractFieldsSnippet
      Returns the content of the request or response extracted form the given operation.
      Specified by:
      getContent in class AbstractFieldsSnippet
      Parameters:
      operation - the operation
      Returns:
      the content
      Throws:
      IOException - if the content cannot be extracted
    • and

      public final RequestPartFieldsSnippet and(FieldDescriptor... additionalDescriptors)
      Returns a new RequestPartFieldsSnippet configured with this snippet's attributes and its descriptors combined with the given additionalDescriptors.
      Parameters:
      additionalDescriptors - the additional descriptors
      Returns:
      the new snippet
    • and

      public final RequestPartFieldsSnippet and(List<FieldDescriptor> additionalDescriptors)
      Returns a new RequestPartFieldsSnippet configured with this snippet's attributes and its descriptors combined with the given additionalDescriptors.
      Parameters:
      additionalDescriptors - the additional descriptors
      Returns:
      the new snippet
    • andWithPrefix

      public final RequestPartFieldsSnippet andWithPrefix(String pathPrefix, FieldDescriptor... additionalDescriptors)
      Returns a new RequestFieldsSnippet configured with this snippet's attributes and its descriptors combined with the given additionalDescriptors. The given pathPrefix is applied to the path of each additional descriptor.
      Parameters:
      pathPrefix - the prefix to apply to the additional descriptors
      additionalDescriptors - the additional descriptors
      Returns:
      the new snippet
    • andWithPrefix

      public final RequestPartFieldsSnippet andWithPrefix(String pathPrefix, List<FieldDescriptor> additionalDescriptors)
      Returns a new RequestFieldsSnippet configured with this snippet's attributes and its descriptors combined with the given additionalDescriptors. The given pathPrefix is applied to the path of each additional descriptor.
      Parameters:
      pathPrefix - the prefix to apply to the additional descriptors
      additionalDescriptors - the additional descriptors
      Returns:
      the new snippet