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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-01-14 11:00:00 +0000
Seen: 14 times
Last updated: Feb 11 '22
How can one generate a list by using a portion of another list?
How can I modify the width of the column filter in an R shiny datatable?
How can dote be eliminated from the menu items in HTML?
How can an EditForm validate a list object in MudBlazor?
How do you update a dataframe within a for loop in R after passing a list?
How can resetting a list be avoided during a loop?
What is the LINQ query to retrieve the employee with the second highest salary?
What is the method to sort CorrelationIDs that are linked with a specific OperationName?