encoding/jsonschema: fix two bugs in CUE-to-JSON-Schema generation
Fix two pre-existing bugs in the JSON Schema generator:
1. Use itemItemsBounds (maxItems/minItems) instead of itemLengthBounds
(maxLength/minLength) when generating array length constraints for
closed lists with prefix items. The old code incorrectly generated
string length keywords for array length bounds.
2. Add support for generating uniqueItems from list.UniqueItems().
Previously, list.UniqueItems() was not recognized and silently
mapped to a true schema, losing the uniqueness constraint during
CUE-to-JSON-Schema generation.
Also cater for cases where we know that something is of list type
but we don't know have a size or an ellipsis. The behavior is still
not correct (it's unduly lax) but it's better than the error.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I477023f63843776f3709e264260b7c6a9e683dbe
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1232502
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>