Tho*_*ais 5 java jackson swagger swagger-ui swagger-2.0
我们正在尝试拥有 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
}
Run Code Online (Sandbox Code Playgroud)
产生 Swagger 模式输出:
{
"id": 0,
"sourceDefinitionName": {
"configuration": {},
"driver": "string",
"id": "string",
"name": "string",
"sourceType": "QUERY",
"title": "string"
}
}
Run Code Online (Sandbox Code Playgroud)
您可以看到它确实读取了 @JsonProperty 注释,将“sourceDefinition”重命名为“sourceDefinitionName”,但该值应该只是一个字符串。
有谁对这种集成的此类问题有任何见解吗?
@ManyToOne(targetEntity = Source.class, optional = false)
@JoinColumn(name = "SOURCE_DEF_NAME", referencedColumnName = "name", nullable = false,
foreignKey = @ForeignKey(name = "FK_sourceDefName"))
private SourceDefinition sourceDefinition;
@Column(name = "SOURCE_DEF_NAME", insertable = false, updatable = false)
private String sourceDefinitionName;
Run Code Online (Sandbox Code Playgroud)
Json 身份也不适合我。我喜欢以下解决方法。请参阅工作示例json-sample
| 归档时间: |
|
| 查看次数: |
431 次 |
| 最近记录: |