4

我们正在尝试拥有 Swagger 2.0。基本上,它很好,只是它忽略了 @JsonIdentityInfo 和 @JsonIdentityReference 注释。

public class Source {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JsonIdentityReference(alwaysAsId=true)
    @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name")
    @JsonProperty("sourceDefinitionName")
    private SourceDefinition sourceDefinition;

    ... getters and setters
}

导致 Swagger 模式输出:

{
     "id": 0,
     "sourceDefinitionName": {
          "configuration": {},
          "driver": "string",
          "id": "string",
          "name": "string",
          "sourceType": "QUERY",
          "title": "string"
     }
}

您可以看到它确实读取了 @JsonProperty 注释,将“sourceDefinition”重命名为“sourceDefinitionName”,但该值应该只是一个字符串。

有人对这种集成的此类问题有任何见解吗?

4

0 回答 0