FasterXML / FasterXML/jackson-module-jsonSchema

Invalid serialisation of UnionTypeSchema

未關閉
#90 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Java
星號
387
分支
136
PR 合併指標
30 天內沒有已合併 PR

描述

UnionTypeSchema currently cannot be serialised because it returns a null type which is not welcomed by JsonSchemaIdResolver.idFromValue. If you extend UnionTypeSchema and return a type then it serialises this as "type" and serialises the types as "elements". This is not valid JSON Schema. It should serialize the union as a "type" array. See https://tools.ietf.org/html/draft-zyp-json-schema-03#page-8

If I then attempt to further patch UnionTypeSchema to change "elements" into "type" then it serialises with TWO "type" properties which isn't even valid JSON!

If I attempt to annotate UnionTypeSchema to not include type info with @JsonTypeInfo(use = JsonTypeInfo.Id.NONE, property = "type") then it has no effect except when the union type schema is passed directly to ObjectMapper.

A test case is attached.

[JacksonUnionTypeSerializationBugTest.java.txt](https://github.com/FasterXML/jackson-module-jsonSchema/files/62387/JacksonUnionTypeSerializationBugTest.java.txt)

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。