Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To transform a List of Long in Swagger V3 to look like a List of String, you can use the @Schema annotation with the type parameter set to string. Here's an example:

import io.swagger.v3.oas.annotations.media.Schema;

public class ExampleModel {

  @Schema(type = "array", items = @Schema(type = "string"))
  private List<Long> numbers;

  // getters and setters

}

In this example, the @Schema annotation is applied to the numbers field of the ExampleModel class. The type parameter is set to "array", indicating that this field is an array or list. The items parameter is also set to a nested @Schema annotation with the type parameter set to "string", which indicates that each item in this array should be represented as a string.

This will cause the Swagger documentation to display the numbers field as an array of strings, even though it is actually a list of longs in the code.