helm-schema-gen 0.0.4

Generate an accurate JSON schema for any helm chart
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
use indoc::indoc;
use test_util::prelude::sim_assert_eq;

use super::*;

#[test]
#[expect(
    clippy::too_many_lines,
    reason = "the complete fixture scenario is clearest as one contiguous test"
)]
fn grouped_selector_receiver_is_optional_but_present_scalars_fail() {
    let src = indoc! {r"
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: test
        data:
          grouped: {{ (.Values.grouped.receiver).leaf | quote }}
          {{- if .Values.strict.enabled }}
          strict: {{ .Values.strict.receiver.leaf | quote }}
          {{- end }}
    "};
    let values_yaml = indoc! {"
        grouped: {}
        strict:
          enabled: false
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));

    let grouped_receiver_present = serde_json::json!({
        "not": {
            "anyOf": [
                {
                    "not": {
                        "properties": {
                            "grouped": {
                                "properties": { "receiver": {} },
                                "required": ["receiver"],
                                "type": "object",
                            },
                        },
                        "required": ["grouped"],
                        "type": "object",
                    },
                },
                {
                    "properties": {
                        "grouped": {
                            "properties": { "receiver": { "enum": [null] } },
                            "required": ["receiver"],
                            "type": "object",
                        },
                    },
                    "required": ["grouped"],
                    "type": "object",
                },
            ],
        },
    });
    let strict_enabled = serde_json::json!({
        "properties": {
            "strict": {
                "properties": { "enabled": { "$ref": "#/$defs/helm-truthy" } },
                "required": ["enabled"],
                "type": "object",
            },
        },
        "required": ["strict"],
        "type": "object",
    });
    let mut properties = serde_json::Map::new();
    properties.insert(
        "grouped".to_string(),
        serde_json::json!({
            "additionalProperties": {},
            "properties": {
                "receiver": {
                    "additionalProperties": {},
                    "properties": { "leaf": {} },
                },
            },
            "type": "object",
        }),
    );
    properties.insert(
        "strict".to_string(),
        serde_json::json!({
            "additionalProperties": {},
            // The strict receiver's presence claim shares its `strict`
            // ancestor with the enabled gate, so the clause anchors here
            // instead of at the document root.
            "allOf": [{
                "if": { "allOf": [
                    {
                        "properties": { "enabled": { "$ref": "#/$defs/helm-truthy" } },
                        "required": ["enabled"],
                        "type": "object",
                    },
                    { "anyOf": [
                        { "not": { "properties": { "receiver": {} },
                            "required": ["receiver"], "type": "object" } },
                        { "properties": { "receiver": { "enum": [null] } },
                            "required": ["receiver"], "type": "object" },
                    ] },
                ] },
                "then": false,
            }],
            "properties": {
                "enabled": {
                    "anyOf": [
                        { "not": { "$ref": "#/$defs/helm-truthy" } },
                        { "type": "boolean" },
                    ],
                },
                "receiver": {
                    "additionalProperties": {},
                    "properties": { "leaf": {} },
                },
            },
            "type": "object",
        }),
    );
    let all_of = vec![
        serde_json::json!({
            "if": grouped_receiver_present,
            "then": root_property_schema(
                "grouped",
                serde_json::json!({
                    "additionalProperties": {},
                    "properties": {
                        "receiver": { "anyOf": [{ "type": "object" }] },
                    },
                }),
            ),
        }),
        serde_json::json!({
            "if": strict_enabled,
            "then": root_property_schema(
                "strict",
                serde_json::json!({
                    "additionalProperties": {},
                    "properties": {
                        "receiver": { "anyOf": [{ "type": "object" }] },
                    },
                }),
            ),
        }),
        // The chains' own receivers are navigated unconditionally: the inner
        // `.Values.grouped.receiver` read and the `strict.enabled` header
        // both abort on a deleted host.
        navigated_host_clause(&["grouped"]),
        navigated_host_clause(&["strict"]),
    ];
    for instance in [
        serde_json::json!({ "grouped": {}, "strict": { "enabled": false } }),
        serde_json::json!({ "grouped": { "receiver": null }, "strict": { "enabled": false } }),
        serde_json::json!({ "grouped": { "receiver": {} }, "strict": { "enabled": false } }),
        serde_json::json!({ "grouped": {}, "strict": { "enabled": false, "receiver": "skipped" } }),
        serde_json::json!({
            "grouped": {},
            "strict": { "enabled": true, "receiver": {} }
        }),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance),
            "absent/null grouped receivers and object receivers render: instance={instance}; schema={schema}"
        );
    }
    for instance in [
        serde_json::json!({
            "grouped": { "receiver": "not-an-object" },
            "strict": { "enabled": false }
        }),
        serde_json::json!({ "grouped": {}, "strict": { "enabled": true } }),
    ] {
        assert!(
            !schema_accepts_instance(&schema, &instance),
            "present scalar grouped receivers and missing strict receivers fail: instance={instance}; schema={schema}"
        );
    }
    sim_assert_eq!(
        have: &schema,
        want: &expected_values_schema(properties, all_of, true)
    );
}

/// A `hasKey` guard on the rendered leaf is already enforced by property
/// presence. Its provider schema must therefore occupy the empty leaf slot
/// directly instead of turning that scalar slot into an object host.
#[test]
fn present_key_guard_keeps_scalar_provider_schema_at_leaf() {
    let src = indoc! {r#"
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: test
        spec:
          selector:
            matchLabels:
              app: test
          template:
            metadata:
              labels:
                app: test
            spec:
              {{- if hasKey .Values.global "hostUsers" }}
              hostUsers: {{ .Values.global.hostUsers }}
              {{- end }}
              containers:
                - name: test
                  image: test
    "#};
    let schema = schema_for_values_yaml(parse_ir(src), Some("global: {}\n"));

    for instance in [
        serde_json::json!({ "global": {} }),
        serde_json::json!({ "global": { "hostUsers": true } }),
        serde_json::json!({ "global": { "hostUsers": false } }),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance),
            "absent and boolean hostUsers values render: instance={instance}; schema={schema}"
        );
    }
    assert!(
        schema_accepts_instance(
            &schema,
            &serde_json::json!({ "global": { "hostUsers": "false" } })
        ),
        "an unquoted Boolean string reparses to the provider's Boolean field: {schema}"
    );
    assert!(
        !schema_accepts_instance(
            &schema,
            &serde_json::json!({ "global": { "hostUsers": "audit" } })
        ),
        "a non-Boolean string cannot satisfy the provider field: {schema}"
    );
}

/// A parent synthesized only to carry a member-host implication must not
/// import unrelated declared siblings into a per-template schema.
#[test]
fn synthetic_member_parent_does_not_seed_unreferenced_values_siblings() {
    let src = indoc! {r"
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: test
        data:
          port: {{ .Values.master.containerPorts.redis | quote }}
    "};
    let values_yaml = indoc! {"
        master:
          containerPorts:
            redis: 6379
          unrelated:
            imported: false
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));

    assert!(
        schema
            .pointer("/properties/master/properties/unrelated")
            .is_none(),
        "a requirement-only parent must not seed an unconsumed sibling: {schema}"
    );
    assert!(
        schema
            .pointer("/properties/master/properties/containerPorts/properties/redis")
            .is_some(),
        "the genuinely consumed descendant must remain represented: {schema}"
    );
}

/// A member-local predicate cannot be represented as a root Draft 7 guard.
/// Its body contract must therefore abstain instead of becoming an
/// unconditional item/value constraint.
#[test]
fn member_local_guard_does_not_leak_its_string_contract() {
    let src = indoc! {r"
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: test
        data:
          output: |-
            {{- range $item := .Values.items }}
            {{- if $item.enabled }}
            {{ tpl $item.template $ }}
            {{- end }}
            {{- end }}
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some("items: []\n"));
    // The member-local predicate cannot lower as a document guard, but its
    // `enabled` lookup still proves the structural member host in every
    // array/map lane. The host stays untyped in the broad default lane so
    // the unconditional range implication below remains the strict owner.
    let open_member = serde_json::json!({
        "additionalProperties": {},
        "properties": { "enabled": {} },
    });
    let object_member = serde_json::json!({
        "additionalProperties": {},
        "properties": { "enabled": {} },
        "type": "object",
    });
    let mut properties = serde_json::Map::new();
    properties.insert(
        "items".to_string(),
        serde_json::json!({
            "anyOf": [
                { "items": open_member, "type": "array" },
                { "items": object_member.clone(), "type": "array" },
                { "type": "integer" },
                { "type": "null" },
                { "additionalProperties": object_member.clone(), "type": "object" },
            ]
        }),
    );
    // The unconditional arm's carrier stays untyped: it must hold vacuously
    // for falsy ancestors a `with` chain would skip. Grafting the untyped
    // `enabled` carrier into the arm keeps the member's OBJECT kind — the
    // typeless carrier conjoins into the typed member slot instead of
    // widening it into a union alternative.
    let all_of = vec![serde_json::json!({
        "additionalProperties": {},
        "properties": {
            "items": {
                "anyOf": [
                    { "items": object_member.clone(), "type": "array" },
                    {
                        "additionalProperties": object_member,
                        "type": "object",
                    },
                    { "maximum": 0, "type": "integer" },
                    { "type": "null" },
                ]
            }
        },
    })];
    sim_assert_eq!(
        have: &schema,
        want: &expected_values_schema(properties, all_of, false)
    );

    for instance in [
        serde_json::json!({ "items": [{ "enabled": false, "template": 7 }] }),
        serde_json::json!({ "items": [{ "enabled": true, "template": "body" }] }),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance),
            "dead member consumers and live strings remain valid: instance={instance}; schema={schema}"
        );
    }
}

/// Interior carriers of conditional arms must hold
/// vacuously for falsy ancestors that a `with` chain skips at runtime, so
/// only the truthy states carry the leaf's iterable requirement.
#[test]
fn nested_with_chain_range_keeps_falsy_ancestors_valid() {
    let src = indoc! {r"
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: d
        spec:
          template:
            spec:
              {{- with .Values.affinity }}
              affinity:
              {{- with .podAffinity }}
                podAffinity:
                  {{- with .preferredDuringSchedulingIgnoredDuringExecution }}
                  preferredDuringSchedulingIgnoredDuringExecution:
                  {{- range . }}
                    - weight: {{ .weight }}
                  {{- end }}
                  {{- end }}
              {{- end }}
              {{- end }}
    "};
    let schema = schema_for_values_yaml(
        parse_ir(src),
        Some(indoc! {"
            affinity: {}
        "}),
    );

    for instance in [
        serde_json::json!({ "affinity": false }),
        serde_json::json!({ "affinity": 0 }),
        serde_json::json!({ "affinity": "" }),
        serde_json::json!({ "affinity": {} }),
        serde_json::json!({ "affinity": {
            "podAffinity": { "preferredDuringSchedulingIgnoredDuringExecution": [{ "weight": 1 }] }
        } }),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance),
            "falsy ancestors are skipped by the with chain and valid lists render: instance={instance}; schema={schema}"
        );
    }
    assert!(
        !schema_accepts_instance(
            &schema,
            &serde_json::json!({ "affinity": {
                "podAffinity": { "preferredDuringSchedulingIgnoredDuringExecution": "audit" }
            } }),
        ),
        "a live truthy non-iterable still fails the range: {schema}"
    );
}

/// A bare `*` member row must not collapse its container to an array-only
/// shape: `range` iterates maps as well as lists, so a map member ranged
/// inside an outer list item (velero's storage-location `annotations`)
/// keeps both collection lanes and accepts the declared map form.
#[test]
fn nested_member_range_keeps_map_lane_in_member_arm() {
    let src = indoc! {r#"
        {{- if typeIs "[]interface {}" .Values.locations }}
        {{- range .Values.locations }}
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: {{ .name | default "d" }}
          {{- with .annotations }}
          annotations:
              {{- range $key, $value := . }}
            {{- $key | nindent 4 }}: {{ $value | quote }}
            {{- end }}
          {{- end }}
        {{- end }}
        {{- end }}
    "#};
    let values_yaml = indoc! {"
        locations:
        - name:
          annotations: {}
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));

    for instance in [
        serde_json::json!({ "locations": [{ "name": "d", "annotations": {} }] }),
        serde_json::json!({ "locations": [{ "name": "d", "annotations": { "a": "b" } }] }),
        serde_json::json!({ "locations": "ignored" }),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance),
            "map-form annotations render and non-lists skip the typeIs branch: instance={instance}; schema={schema}"
        );
    }
    assert!(
        !schema_accepts_instance(&schema, &serde_json::json!({ "locations": [7] })),
        "a scalar item fails the member reads inside the range: {schema}"
    );
}

/// an `if` header's chained selector (`and .Values.webhook.create
/// .Values.webhook.podDisruptionBudget.enabled`) field-accesses `.enabled`
/// on the intermediate map, so a non-object host aborts rendering even
/// though the region's own body never renders for it. The member-host arm
/// must survive the sibling `hasKey` dispatch inside the body
/// (external-secrets' webhook `PodDisruptionBudget`).
#[test]
fn header_member_read_requires_an_object_host_beside_body_dispatch() {
    let src = indoc! {r#"
        {{- if and .Values.webhook.create .Values.webhook.podDisruptionBudget.enabled }}
        apiVersion: policy/v1
        kind: PodDisruptionBudget
        metadata:
          name: test
        spec:
          {{- if hasKey .Values.webhook.podDisruptionBudget "maxUnavailable" }}
          maxUnavailable: {{ .Values.webhook.podDisruptionBudget.maxUnavailable }}
          {{- else if hasKey .Values.webhook.podDisruptionBudget "minAvailable" }}
          minAvailable: {{ .Values.webhook.podDisruptionBudget.minAvailable }}
          {{- end }}
        {{- end }}
    "#};
    let schema = schema_for_values_yaml(
        parse_ir(src),
        Some(indoc! {"
            webhook:
              create: true
              podDisruptionBudget:
                enabled: false
                minAvailable: 1
        "}),
    );
    // The coalesced document carries the declared `create: true`; with it
    // null-deleted the header short-circuits before the member read.
    for (instance, want) in [
        (
            serde_json::json!({ "webhook": { "create": true, "podDisruptionBudget": 7 } }),
            false,
        ),
        (
            serde_json::json!({ "webhook": { "create": true, "podDisruptionBudget": [1] } }),
            false,
        ),
        (
            serde_json::json!({ "webhook": { "podDisruptionBudget": { "enabled": false } } }),
            true,
        ),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance) == want,
            "instance={instance}; schema={schema}"
        );
    }
}

/// The nack shape: a declared mapping default whose ONLY consumer is the
/// nil-safe grouped read `((.Values.global).labels)`. Helm's null-deletion
/// renders `global: null` (the receiver goes absent and the grouped chain
/// yields nil instead of aborting), so the declared default's base typing
/// must admit null while present non-null scalars keep aborting through
/// the presence-guarded member-host arm.
#[test]
fn nil_safe_grouped_receiver_with_declared_default_admits_null() {
    let src = indoc! {r"
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: test
          {{- with ((.Values.global).labels) }}
          labels:
            {{- toYaml . | nindent 4 }}
          {{- end }}
        data: {}
    "};
    let values_yaml = indoc! {"
        global:
          labels: {}
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));

    sim_assert_eq!(
        have: schema.pointer("/properties/global/type") == Some(&serde_json::json!("object")),
        want: false,
        "declared-default base must not pin bare `type: object`: {schema}",
    );
    for (instance, want) in [
        (serde_json::json!({ "global": null }), true),
        (serde_json::json!({}), true),
        (serde_json::json!({ "global": {} }), true),
        (
            serde_json::json!({ "global": { "labels": { "a": "b" } } }),
            true,
        ),
        (serde_json::json!({ "global": 42 }), false),
        (serde_json::json!({ "global": "oops" }), false),
        (serde_json::json!({ "global": false }), false),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance) == want,
            "instance={instance}; want={want}; schema={schema}"
        );
    }
}

/// Navigation ABORTS on a nil receiver, so every host read outside its own
/// presence gate must exist in the coalesced document — the state a user's
/// `null` deletion produces (metrics-server's `apiService: null` aborts with
/// "nil pointer evaluating interface {}.create"). The claim reaches
/// TOP-LEVEL hosts, which have no parent slot for a `required` member, and
/// it survives the chart's own mapping default, which the render-grade
/// presence relaxation would otherwise drop. Nil-safe grouped receivers and
/// `with`-scoped hosts keep every absent state open.
#[test]
fn navigated_hosts_must_exist_in_the_coalesced_document() {
    let src = indoc! {r"
        {{- if .Values.apiService.create }}
        apiVersion: v1
        kind: Service
        metadata:
          name: x
        {{- end }}
        ---
        {{- if .Values.rbac.serviceAccount.create }}
        apiVersion: v1
        kind: ServiceAccount
        metadata:
          name: y
        {{- end }}
        ---
        {{- if (.Values.nilSafe).enabled }}
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: n
        {{- end }}
        ---
        {{- with .Values.gated }}
        {{- if .enabled }}
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: g
        {{- end }}
        {{- end }}
    "};
    let values_yaml = indoc! {"
        apiService:
          create: true
        rbac:
          serviceAccount:
            create: true
        nilSafe: {}
        gated: {}
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));
    let composed = serde_json::json!({
        "apiService": { "create": true },
        "rbac": { "serviceAccount": { "create": true } },
        "nilSafe": {},
        "gated": {},
    });
    let without = |path: &[&str]| {
        let mut instance = composed.clone();
        let mut node = &mut instance;
        let Some((leaf, parents)) = path.split_last() else {
            return instance;
        };
        for segment in parents {
            node = &mut node[*segment];
        }
        if let Some(object) = node.as_object_mut() {
            object.remove(*leaf);
        }
        instance
    };
    for (instance, want, label) in [
        (composed.clone(), true, "the coalesced defaults render"),
        (
            without(&["apiService"]),
            false,
            "a deleted top-level host aborts the header read",
        ),
        (
            without(&["rbac"]),
            false,
            "a deleted host ancestor aborts the chained read",
        ),
        (
            without(&["rbac", "serviceAccount"]),
            false,
            "a deleted nested host aborts, default-supplied or not",
        ),
        (
            without(&["nilSafe"]),
            true,
            "a nil-safe grouped receiver renders when deleted",
        ),
        (
            without(&["gated"]),
            true,
            "a `with`-scoped host renders when deleted",
        ),
        (
            serde_json::json!({ "apiService": {}, "rbac": { "serviceAccount": { "create": true } },
                "nilSafe": {}, "gated": {} }),
            true,
            "an empty host map reads its member as nil",
        ),
    ] {
        assert!(
            schema_accepts_instance(&schema, &instance) == want,
            "navigated host presence ({label}): instance={instance}; want={want}; schema={schema}"
        );
    }
}

/// Ranging a local dict that a `set` overlaid on a values-backed map still
/// visits that map's members, so the members' own consumers bind to them:
/// navigating one aborts on a present non-mapping exactly as a direct range
/// would (traefik's `$services := .Values.service.additionalServices` plus a
/// synthetic "default" entry).
#[test]
fn overlaid_range_members_keep_their_member_contracts() {
    let src = indoc! {r#"
        {{- $services := .Values.additionalServices }}
        {{- $services = set $services "default" (omit .Values.service "additionalServices") }}
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: test
        data:
          {{- range $name, $service := $services }}
          {{- if ne $service.enabled false }}
          {{ $name }}: live
          {{- end }}
          {{- end }}
    "#};
    let values_yaml = indoc! {"
        additionalServices: {}
        service:
          enabled: true
    "};
    let schema = schema_for_values_yaml(parse_ir(src), Some(values_yaml));

    for (overrides, want) in [
        (
            serde_json::json!({ "additionalServices": { "audit": { "enabled": true } } }),
            true,
        ),
        (serde_json::json!({ "additionalServices": {} }), true),
        // A present non-mapping member aborts the member navigation.
        (
            serde_json::json!({ "additionalServices": { "audit": false } }),
            false,
        ),
        (
            serde_json::json!({ "additionalServices": { "audit": "x" } }),
            false,
        ),
        (
            serde_json::json!({ "additionalServices": { "audit": 7 } }),
            false,
        ),
        (
            serde_json::json!({ "additionalServices": { "audit": [] } }),
            false,
        ),
    ] {
        let instance = composed_instance(values_yaml, overrides);
        assert!(
            schema_accepts_instance(&schema, &instance) == want,
            "the overlaid range binds its member contracts: \
             instance={instance}; want={want}; schema={schema}"
        );
    }
}