我正在使用 OpenAPI / Swagger 来指定我的 API。
我不知道的一件事是如何指定一个集合。
我正在使用https://editor.swagger.io/并输入了整个 API。对于我想指定为 Set 的属性,我编写了以下内容:
myProperty:
uniqueItems: true
type: array
description: some description
items:
type: string
Run Code Online (Sandbox Code Playgroud)
我猜想uniqueItems可以解决问题并生成一个 Set,但事实并非如此。相反,会生成以下代码:
@JsonProperty("myProperty")
private List<String> myProperty = null;
Run Code Online (Sandbox Code Playgroud)
有没有办法生成类似的东西
@JsonProperty("myProperty")
private Set<String> myProperty = null;
Run Code Online (Sandbox Code Playgroud)
反而?
我在 SO 中找到了一个可能的解决方案,但这需要在 pom.xml 中进行一些配置。然而,我使用的在线编辑器只提供了为不同平台生成代码的选项,但不接受 pom 文件。