Class RequestPartBodySnippet

All Implemented Interfaces:
Snippet

public class RequestPartBodySnippet extends AbstractBodySnippet
A Snippet that documents the body of a request part.
Author:
Andy Wilkinson
  • Constructor Details

    • RequestPartBodySnippet

      public RequestPartBodySnippet(String partName)
      Creates a new RequestPartBodySnippet that will document the body of the request part with the given partName.
      Parameters:
      partName - the name of the request part
    • RequestPartBodySnippet

      public RequestPartBodySnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor)
      Creates a new RequestPartBodySnippet that will document the subsection of the body of the request part with the given partName extracted by the given subsectionExtractor. If the extractor is null the entire body of the request part will be documented.
      Parameters:
      partName - the name of the request part
      subsectionExtractor - the subsection extractor or null to document the request part's entire body
    • RequestPartBodySnippet

      public RequestPartBodySnippet(String partName, @Nullable Map<String,Object> attributes)
      Creates a new RequestPartBodySnippet that will document the body of the request part with the given partName. If the extractor is null the entire body of the request part will be documented. The given additional attributes will be included in the model during template rendering.
      Parameters:
      partName - the name of the request part
      attributes - the additional attributes
    • RequestPartBodySnippet

      public RequestPartBodySnippet(String partName, @Nullable PayloadSubsectionExtractor<?> subsectionExtractor, @Nullable Map<String,Object> attributes)
      Creates a new RequestPartBodySnippet that will document the subsection of the body of the request part with the given partName extracted by the given subsectionExtractor. If the extractor is null the entire body of the request part will be documented. The given additional attributes will be included in the model during template rendering.
      Parameters:
      partName - the name of the request part
      subsectionExtractor - the subsection extractor or null to document the request part's entire body
      attributes - the additional attributes
  • Method Details

    • getContent

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

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