Skip to content

Commit 5dffecb

Browse files
committed
Comment additionalProperties handling
1 parent d952908 commit 5dffecb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/util/gobConfig.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct
182182
begin
183183
try get_value (List.assoc key m) pth
184184
with Not_found ->
185-
try get_value (List.assoc Options.defaults_additional_field m) pth
185+
try get_value (List.assoc Options.defaults_additional_field m) pth (* if schema specifies additionalProperties, then use the default from that *)
186186
with Not_found -> raise ConfTypeError
187187
end
188188
| `List a, Index (Int i, pth) ->
@@ -227,7 +227,8 @@ struct
227227
match o, pth with
228228
| `Assoc m, Select (key,pth) ->
229229
let rec modify = function
230-
| [] -> [(key, create_new v pth)]
230+
| [] ->
231+
[(key, create_new v pth)] (* create new key, validated by schema *)
231232
| (key', v') :: kvs when key' = key ->
232233
(key, set_value v v' pth) :: kvs
233234
| (key', v') :: kvs ->

src/util/jsonSchema.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ let rec element_defaults ?additional_field (element: element): Yojson.Safe.t =
9595
| Object object_specs ->
9696
let additional = match additional_field, object_specs.additional_properties with
9797
| Some additional_field, Some additional_properties ->
98+
(* create additional field with the additionalProperties default value for lookup in GobConfig *)
9899
[(additional_field, element_defaults ~additional_field additional_properties)]
99100
| _, _ ->
100101
[]

src/util/options.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let schema =
2828

2929
let require_all = JsonSchema.schema_require_all schema
3030

31-
let defaults_additional_field = "__additional__"
31+
let defaults_additional_field = "__additional__" (* tihs shouldn't conflict with any actual field *)
3232
let defaults = JsonSchema.schema_defaults ~additional_field:defaults_additional_field schema
3333

3434
let () =

0 commit comments

Comments
 (0)