Class ResponseBodyMappingModel

java.lang.Object
io.micronaut.gradle.openapi.ResponseBodyMappingModel
All Implemented Interfaces:
Serializable

public final class ResponseBodyMappingModel extends Object implements Serializable
A model that can be used to specify body mappings during OpenAPI generation.

An equivalent to Micronaut OpenAPI's ResponseBodyMapping but without using classes from that dependency so that we can isolate execution in workers.

See Also:
  • Constructor Details

    • ResponseBodyMappingModel

      public ResponseBodyMappingModel(String headerName, String mappedBodyType)
      Create a response body mapping.
      Parameters:
      headerName - The response header name that triggers the change of response type.
      mappedBodyType - The type in which will be used as the response type. The type must take a single type parameter, which will be the original body. If the value is null, the header will be removed and body not changed.
  • Method Details

    • withHeaderName

      public ResponseBodyMappingModel withHeaderName(String headerName)
      Specify the name of the response header that triggers mapping.
      Parameters:
      headerName - the name
      Returns:
      new instance with the updated header name
    • withMappedBodyType

      public ResponseBodyMappingModel withMappedBodyType(String mappedBodyType)
      Specify the fully-qualified name of the body type that will be generated as the response return type in case mapping is triggered.
      Parameters:
      mappedBodyType - the type
      Returns:
      new instance with the updated mapped body type
    • withListWrapper

      public ResponseBodyMappingModel withListWrapper(boolean isListWrapper)
      Specify whether the mapped body is a list wrapper. Then the mapped body type needs to be supplied list items as property
      Parameters:
      isListWrapper - whether it is a list wrapper
      Returns:
      new instance with the isListWrapper property specified
    • withValidated

      public ResponseBodyMappingModel withValidated(boolean isValidated)
      Specify whether the mapped response body type required validation.
      Parameters:
      isValidated - whether it should be validated
      Returns:
      new instance with validation requirement set
    • getHeaderName

      public String getHeaderName()
    • getMappedBodyType

      public String getMappedBodyType()
    • isListWrapper

      public boolean isListWrapper()
    • isValidated

      public boolean isValidated()