如何避免在数组类型的模式中创建新的 Swagger 模式定义?

问题描述 投票:0回答:0

我有以下Java类:

State.java

@ArraySchema(schema = @Schema(name = "State"))
public class State extends ArrayList<Operation>
{}

Operation.java

@Builder(toBuilder = true)
@Data
@Jacksonized
public class Operation
{
   @Schema(required = true)
   @JsonProperty("op")
   private String op;
}

这会为

State
生成以下架构,并为
Operation
生成一个额外的架构:

"State":{"type":"array","items":{"$ref":"#/components/schemas/Operation"}}

现在,我不想为

Operation
生成额外的模式,而是在
items
下包含它的属性。所以,最后我想生成以下内容:

"State":{"type":"array","items":{{"type":"object","properties":{"op": string}}}}

有办法做到这一点吗?

我正在使用 Springdoc

io.swagger.core.v3:swagger-annotations:jar:2.2.8

java swagger swagger-ui springdoc
© www.soinside.com 2019 - 2024. All rights reserved.