可以为此使用注释吗?我不明白如何使用 Yaml。
例子:
@Operation(summary = "Get page of top by rating articles by title")
@ApiResponses(value = {
@ApiResponse(responseCode = "200 successful operation",
content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(???)))
})
@GetMapping(value = {"/articles/topByRating"})
@JsonView({JsonViews.Short.class})
@ResponseStatus(HttpStatus.OK)
public ItemsDto<Article> getArticlesTopByRating(@RequestParam int numberPage, @RequestParam int sizePage) {
return articleCrud.getTopByRating(numberPage, sizePage);
}
ItemsDto:
public class ItemsDto<E> {
Long total = 0L;
List<E> items;
}
文章:
public class Article{
private Author author;
private String title;
private String body;
}
https://swagger.io/docs/specification/data-models/dictionaries/ 自由格式对象“如果字典值可以是任何类型(又名自由格式对象),请使用附加属性:真:”
1. type: object
2. additionalProperties: true
我将尝试在 @Schema 注释中使用 'ref = myfile.yaml' 属性