Mirror of https://github.com/cue-lang/cue cuelang.org
cue go

encoding/jsonschema: fix closedness handling in Generate master

Fix several issues where closedness was lost during JSON Schema generation, causing definitions to accept additional properties that CUE would reject. Omit additionalProperties: false when a struct has only $ref conjuncts and no local properties, since additionalProperties is lexically scoped and would reject all fields from the referenced schema. For recursive non-definitions, a redirect mechanism ensures self-references resolve to the enclosing definition's $defs entry. For mutually recursive non-definitions, other non-definitions encountered in a closed context are also inlined at the property level, with a flag to prevent unbounded recursion. When a definition's body is a conjunction of non-definitions (e.g. makeStructItem so their properties become local to additionalProperties. Add an explicit SpreadOp case to makeItem0 for clarity. Fixes #4356. Signed-off-by: Roger Peppe <rogpeppe@gmail.com> Change-Id: Ib945e2fd1fbfb49deea00b0099444d075505098a Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1237525 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>