Class RequestBodySnippet

All Implemented Interfaces:
Snippet

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

    • RequestBodySnippet

      public RequestBodySnippet()
      Creates a new RequestBodySnippet.
    • RequestBodySnippet

      public RequestBodySnippet(PayloadSubsectionExtractor<?> subsectionExtractor)
      Creates a new RequestBodySnippet that will document the subsection of the request body extracted by the given subsectionExtractor.
      Parameters:
      subsectionExtractor - the subsection extractor
    • RequestBodySnippet

      public RequestBodySnippet(Map<String,Object> attributes)
      Creates a new RequestBodySnippet with the given additional attributes that will be included in the model during template rendering.
      Parameters:
      attributes - the additional attributes
    • RequestBodySnippet

      public RequestBodySnippet(PayloadSubsectionExtractor<?> subsectionExtractor, Map<String,Object> attributes)
      Creates a new RequestBodySnippet that will document the subsection of the request body extracted by the given subsectionExtractor. The given additional attributes that will be included in the model during template rendering.
      Parameters:
      subsectionExtractor - the subsection extractor
      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 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