1
考慮這個例子:如何在JSON模式中使用allOf的additionalProperties?
"allOf": [
{"$ref": "test-address-prefix-types-base.json#"},
{
"properties": {}, "additionalProperties" : false
}
]}
當我確認這與Java架構驗證,我得到錯誤說:
"keyword":"additionalProperties","message":"object instance has properties which are not allowed by the schema: [\"attributes\",\"type\"]"}]
但同樣的JSON對象驗證對基礎架構(測試地址前綴-types-base)通過沒有錯誤。
被引用的模式(基本一)沒有設置additionalProperties。
這是JSON消息,我使用:
String message = "{\"data\":{\"attributes\":{" +
"\"notation\": \"A\"," +
"\"prefixType\": \"A\"}" +
",\"type\":\"test-address-prefix-types\"}}";
我錯過了在架構什麼? 感謝
所以問題是,這個「合併」只是一個提案,還沒有發佈呢?我檢查過http://json-schema.org/中的json模式規範,並沒有提及它。我們正在使用AJV進行驗證,但這並不支持合併。 – xbmono
是的,你不能安全地應用它。如果可能,您可以將「additionalProperties」:false添加到引用的模式中。 – jruizaranguren
你知道Json Schema Validator(https://github.com/daveclayton/json-schema-validator)是否支持$ merge?我剛剛意識到AJV增加了對$ merge的支持,但是我們正在使用Json模式驗證器,這是針對Java的,並且來自我在這裏可以看到的內容https://github.com/daveclayton/json-schema-validator/wiki/v5:-合併它支持$ merge但我不能得到它的工作?由於無法識別$ merge,它會返回錯誤 – xbmono