@@ -257,7 +257,7 @@ test("Schema of record struct with one string field", t => {
257257 " type" : " object" ,
258258 " properties" : {" field" : {" type" : " string" }},
259259 " required" : [" field" ],
260- " additionalProperties" : false ,
260+ " additionalProperties" : true ,
261261 }` ) ,
262262 ),
263263 (),
@@ -282,6 +282,27 @@ test("Schema of record struct with Strip unknownKeys strategy allows additionalP
282282 )
283283})
284284
285+ test (
286+ "Schema of record struct with Strict unknownKeys strategy disallows additionalProperties" ,
287+ t => {
288+ let struct = S .record1 (. ("field" , S .string ()))-> S .Record .strict
289+
290+ t -> Assert .deepEqual (
291+ JsonSchema .make (struct ),
292+ Ok (
293+ %raw (` {
294+ " $schema" : " http://json-schema.org/draft-07/schema#" ,
295+ " type" : " object" ,
296+ " properties" : {" field" : {" type" : " string" }},
297+ " required" : [" field" ],
298+ " additionalProperties" : false ,
299+ }` ) ,
300+ ),
301+ (),
302+ )
303+ },
304+ )
305+
285306test ("Schema of record struct with one optional string field" , t => {
286307 let struct = S .record1 (. ("optionalField" , S .option (S .string ())))
287308
@@ -292,7 +313,7 @@ test("Schema of record struct with one optional string field", t => {
292313 " $schema" : " http://json-schema.org/draft-07/schema#" ,
293314 " type" : " object" ,
294315 " properties" : {" optionalField" : {" type" : " string" }},
295- " additionalProperties" : false ,
316+ " additionalProperties" : true ,
296317 }` ) ,
297318 ),
298319 (),
@@ -309,7 +330,7 @@ test("Schema of record struct with one deprecated string field", t => {
309330 " $schema" : " http://json-schema.org/draft-07/schema#" ,
310331 " type" : " object" ,
311332 " properties" : {" optionalField" : {" type" : " string" , " deprecated" : true }},
312- " additionalProperties" : false ,
333+ " additionalProperties" : true ,
313334 }` ) ,
314335 ),
315336 (),
@@ -331,7 +352,7 @@ test("Schema of record struct with one deprecated string field and message", t =
331352 " properties" : {
332353 " optionalField" : {" type" : " string" , " deprecated" : true , " description" : " Use another field" },
333354 },
334- " additionalProperties" : false ,
355+ " additionalProperties" : true ,
335356 }` ) ,
336357 ),
337358 (),
@@ -356,7 +377,7 @@ test("Deprecated message overrides previous description", t => {
356377 " properties" : {
357378 " optionalField" : {" type" : " string" , " deprecated" : true , " description" : " Use another field" },
358379 },
359- " additionalProperties" : false ,
380+ " additionalProperties" : true ,
360381 }` ) ,
361382 ),
362383 (),
@@ -377,11 +398,11 @@ test("Schema of record struct with nested record", t => {
377398 " type" : " object" ,
378399 " properties" : {" Field" : {" type" : " string" }},
379400 " required" : [" Field" ],
380- " additionalProperties" : false ,
401+ " additionalProperties" : true ,
381402 },
382403 },
383404 " required" : [" recordWithOneStringField" ],
384- " additionalProperties" : false ,
405+ " additionalProperties" : true ,
385406 }` ) ,
386407 ),
387408 (),
@@ -404,7 +425,7 @@ test("Schema of record struct with one optional and one required string field",
404425 " optionalField" : {" type" : " string" },
405426 },
406427 " required" : [" field" ],
407- " additionalProperties" : false ,
428+ " additionalProperties" : true ,
408429 }` ) ,
409430 ),
410431 (),
@@ -454,7 +475,7 @@ test("Transformed struct schema with default fails when destruction failed", t =
454475 switch bool {
455476 | true => "true"
456477 | false => ""
457- }-> Ok
478+ }
458479 }, ()))-> S .default ("true" )))
459480
460481 t -> Assert .deepEqual (
@@ -473,13 +494,13 @@ test("Transformed struct schema uses default with correct type", t => {
473494 switch bool {
474495 | true => "true"
475496 | false => ""
476- }-> Ok
497+ }
477498 },
478499 ~serializer = string => {
479500 switch string {
480501 | "true" => true
481502 | _ => false
482- }-> Ok
503+ }
483504 },
484505 (),
485506 ),
@@ -491,7 +512,7 @@ test("Transformed struct schema uses default with correct type", t => {
491512 Ok (
492513 %raw (` {
493514 " $schema" : " http://json-schema.org/draft-07/schema#" ,
494- " additionalProperties" : false ,
515+ " additionalProperties" : true ,
495516 " properties" : {" field" : {" default" : true , " type" : " boolean" }},
496517 " type" : " object" ,
497518 }` ) ,
@@ -548,7 +569,7 @@ test("Additional raw schema works with optional fields", t => {
548569 " properties" : {
549570 " optionalField" : {" nullable" : true , " type" : " string" },
550571 },
551- " additionalProperties" : false ,
572+ " additionalProperties" : true ,
552573 }` ) ,
553574 ),
554575 (),
@@ -586,7 +607,7 @@ module Example = {
586607 Ok (
587608 %raw (` {
588609 ' $schema' : ' http://json-schema.org/draft-07/schema#' ,
589- additionalProperties: false ,
610+ additionalProperties: true ,
590611 properties: {
591612 Age: {
592613 deprecated: true ,
0 commit comments