this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

encoding/jsonschema: encode oneOf etc using matchN

This CL updates JSON Schema generation to use the newly added
`matchN` primitive for `allOf`, `anyOf` and `oneOf`.

This has a much closer correlation with the JSON Schema primitives
than the current approach of using CUE's `&` and `|` operators.
Specifically:
- the schema arguments should not affect the final result other
than to validate it, but both `&` and `|` can affect the result.
- the result could become non-concrete due to `|` ambiguity in `anyOf`.

Although this does fix a bunch of issues, there are some regressions.
See issues #3418, #3420, #3422 for details.

Comparative test stats (pre-matchN before post-matchN):

```
v2:
schema extract (pass / total): 971 / 1637 = 59.3%
schema extract (pass / total): 975 / 1637 = 59.6%
tests (pass / total): 3081 / 7175 = 42.9%
tests (pass / total): 3140 / 7175 = 43.8%
tests on extracted schemas (pass / total): 3081 / 3542 = 87.0%
tests on extracted schemas (pass / total): 3140 / 3546 = 88.6%

v3:
schema extract (pass / total): 971 / 1637 = 59.3%
schema extract (pass / total): 967 / 1637 = 59.1%
tests (pass / total): 3063 / 7175 = 42.7%
tests (pass / total): 3074 / 7175 = 42.8%
tests on extracted schemas (pass / total): 3063 / 3542 = 86.5%
tests on extracted schemas (pass / total): 3074 / 3538 = 86.9%
```

This change also requires that we update the CI generated code
and remove the workaround for the previous `oneOf` limitation.

Also add a `brokenInV2` tag to the encoding/jsonschema tests to work
around the fact that some V2 tests are now broken.

For #3380
For #3165

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I2630a6d2b1614b2479802e788c16249d2cf4aa6b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200526
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+503 -434
+4 -4
.github/workflows/evict_caches.yml
··· 21 21 run: touch -t 202211302355 $(find * -type d) 22 22 - name: Restore git file modification times 23 23 uses: chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe 24 - - id: DispatchTrailer 25 - name: Try to extract Dispatch-Trailer 24 + - name: Try to extract Dispatch-Trailer 25 + id: DispatchTrailer 26 26 run: |- 27 27 x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')" 28 28 if [[ "$x" == "" ]] ··· 38 38 echo "value<<EOD" >> $GITHUB_OUTPUT 39 39 echo "$x" >> $GITHUB_OUTPUT 40 40 echo "EOD" >> $GITHUB_OUTPUT 41 - - if: |- 41 + - name: Check we don't have Dispatch-Trailer on a protected branch 42 + if: |- 42 43 ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 43 44 Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, ' 44 45 Dispatch-Trailer: {"type":"')) 45 - name: Check we don't have Dispatch-Trailer on a protected branch 46 46 run: |- 47 47 echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch" 48 48 false
+4 -4
.github/workflows/push_tip_to_trybot.yml
··· 10 10 jobs: 11 11 push: 12 12 runs-on: ubuntu-22.04 13 - defaults: 14 - run: 15 - shell: bash 16 - if: ${{github.repository == 'cue-lang/cue'}} 17 13 steps: 18 14 - name: Write netrc file for cueckoo Gerrithub 19 15 run: |- ··· 49 45 echo "Giving up" 50 46 exit 1 51 47 fi 48 + defaults: 49 + run: 50 + shell: bash 51 + if: ${{github.repository == 'cue-lang/cue'}}
+11 -11
.github/workflows/release.yml
··· 14 14 jobs: 15 15 goreleaser: 16 16 runs-on: ubuntu-22.04 17 + if: ${{github.repository == 'cue-lang/cue'}} 17 18 defaults: 18 19 run: 19 20 shell: bash 20 - if: ${{github.repository == 'cue-lang/cue'}} 21 21 steps: 22 22 - name: Checkout code 23 23 uses: actions/checkout@v4 ··· 28 28 run: touch -t 202211302355 $(find * -type d) 29 29 - name: Restore git file modification times 30 30 uses: chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe 31 - - id: DispatchTrailer 32 - name: Try to extract Dispatch-Trailer 31 + - name: Try to extract Dispatch-Trailer 32 + id: DispatchTrailer 33 33 run: |- 34 34 x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')" 35 35 if [[ "$x" == "" ]] ··· 45 45 echo "value<<EOD" >> $GITHUB_OUTPUT 46 46 echo "$x" >> $GITHUB_OUTPUT 47 47 echo "EOD" >> $GITHUB_OUTPUT 48 - - if: |- 48 + - name: Check we don't have Dispatch-Trailer on a protected branch 49 + if: |- 49 50 ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 50 51 Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, ' 51 52 Dispatch-Trailer: {"type":"')) 52 - name: Check we don't have Dispatch-Trailer on a protected branch 53 53 run: |- 54 54 echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch" 55 55 false ··· 76 76 install-only: true 77 77 version: v2.2.0 78 78 - name: Run GoReleaser with CUE 79 - run: cue cmd release 80 - working-directory: ./internal/ci/goreleaser 81 79 env: 82 80 GITHUB_TOKEN: ${{ secrets.CUECKOO_GITHUB_PAT }} 83 - - if: startsWith(github.ref, 'refs/tags/v') 84 - name: Re-test cuelang.org 81 + run: cue cmd release 82 + working-directory: ./internal/ci/goreleaser 83 + - name: Re-test cuelang.org 84 + if: startsWith(github.ref, 'refs/tags/v') 85 85 run: 'curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail --request POST --data-binary "{\"event_type\":\"Re-test post release of ${GITHUB_REF##refs/tags/}\"}" https://api.github.com/repos/cue-lang/cuelang.org/dispatches' 86 - - if: startsWith(github.ref, 'refs/tags/v') 87 - name: Trigger unity build 86 + - name: Trigger unity build 87 + if: startsWith(github.ref, 'refs/tags/v') 88 88 run: 'curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PORCUEPINE_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail --request POST --data-binary "{\"event_type\":\"Check against CUE ${GITHUB_REF##refs/tags/}\",\"client_payload\":{\"type\":\"unity\",\"payload\":{\"versions\":\"\\\"${GITHUB_REF##refs/tags/}\\\"\"}}}" https://api.github.com/repos/cue-unity/unity-private/dispatches'
+1 -1
.github/workflows/tip_triggers.yml
··· 8 8 jobs: 9 9 push: 10 10 runs-on: ubuntu-22.04 11 + if: ${{github.repository == 'cue-lang/cue'}} 11 12 defaults: 12 13 run: 13 14 shell: bash 14 - if: ${{github.repository == 'cue-lang/cue'}} 15 15 steps: 16 16 - name: Trigger unity build 17 17 run: 'curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PORCUEPINE_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail --request POST --data-binary "{\"event_type\":\"Check against ${GITHUB_SHA}\",\"client_payload\":{\"type\":\"unity\",\"payload\":{\"versions\":\"\\\"commit:${GITHUB_SHA}\\\"\"}}}" https://api.github.com/repos/cue-unity/unity-private/dispatches'
+39 -39
.github/workflows/trybot.yml
··· 9 9 - release-branch.* 10 10 tags-ignore: 11 11 - v* 12 - pull_request: {} 13 12 workflow_dispatch: {} 13 + pull_request: {} 14 14 jobs: 15 15 test: 16 16 strategy: ··· 24 24 - macos-14 25 25 - windows-2022 26 26 runs-on: ${{ matrix.runner }} 27 - defaults: 28 - run: 29 - shell: bash 30 27 if: |- 31 28 (contains(github.event.head_commit.message, ' 32 29 Dispatch-Trailer: {"type":"trybot"')) || ! (contains(github.event.head_commit.message, ' 33 30 Dispatch-Trailer: {"type":"')) 31 + defaults: 32 + run: 33 + shell: bash 34 34 steps: 35 35 - name: Checkout code 36 36 uses: actions/checkout@v4 ··· 41 41 run: touch -t 202211302355 $(find * -type d) 42 42 - name: Restore git file modification times 43 43 uses: chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe 44 - - id: DispatchTrailer 45 - name: Try to extract Dispatch-Trailer 44 + - name: Try to extract Dispatch-Trailer 45 + id: DispatchTrailer 46 46 run: |- 47 47 x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')" 48 48 if [[ "$x" == "" ]] ··· 58 58 echo "value<<EOD" >> $GITHUB_OUTPUT 59 59 echo "$x" >> $GITHUB_OUTPUT 60 60 echo "EOD" >> $GITHUB_OUTPUT 61 - - if: |- 61 + - name: Check we don't have Dispatch-Trailer on a protected branch 62 + if: |- 62 63 ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 63 64 Dispatch-Trailer: {"type":"')))) && (contains(github.event.head_commit.message, ' 64 65 Dispatch-Trailer: {"type":"')) 65 - name: Check we don't have Dispatch-Trailer on a protected branch 66 66 run: |- 67 67 echo "github.event.head_commit.message contains Dispatch-Trailer but we are on a protected branch" 68 68 false ··· 71 71 with: 72 72 cache: false 73 73 go-version: ${{ matrix.go-version }} 74 - - id: go-mod-cache-dir 75 - name: Get go mod cache directory 74 + - name: Get go mod cache directory 75 + id: go-mod-cache-dir 76 76 run: echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT} 77 - - id: go-cache-dir 78 - name: Get go build/test cache directory 77 + - name: Get go build/test cache directory 78 + id: go-cache-dir 79 79 run: echo "dir=$(go env GOCACHE)" >> ${GITHUB_OUTPUT} 80 - - if: |- 81 - (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 82 - Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) 83 - uses: actions/cache@v4 84 - with: 80 + - with: 85 81 path: |- 86 82 ${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download 87 83 ${{ steps.go-cache-dir.outputs.dir }} 88 84 key: ${{ runner.os }}-${{ matrix.go-version }}-${{ github.run_id }} 89 85 restore-keys: ${{ runner.os }}-${{ matrix.go-version }} 90 - - if: |- 91 - ! (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 86 + if: |- 87 + (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 92 88 Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) 93 - uses: actions/cache/restore@v4 94 - with: 89 + uses: actions/cache@v4 90 + - with: 95 91 path: |- 96 92 ${{ steps.go-mod-cache-dir.outputs.dir }}/cache/download 97 93 ${{ steps.go-cache-dir.outputs.dir }} 98 94 key: ${{ runner.os }}-${{ matrix.go-version }}-${{ github.run_id }} 99 95 restore-keys: ${{ runner.os }}-${{ matrix.go-version }} 96 + uses: actions/cache/restore@v4 97 + if: |- 98 + ! (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 99 + Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) 100 100 - if: |- 101 101 github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 102 102 Dispatch-Trailer: {"type":"')))) || github.ref == 'refs/heads/ci/test') 103 103 run: go clean -testcache 104 - - if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 105 - name: Early git and code sanity checks 104 + - name: Early git and code sanity checks 105 + if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 106 106 run: go run ./internal/ci/checks 107 - - if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 108 - name: Generate 107 + - name: Generate 109 108 run: go generate ./... 110 - - if: |- 109 + if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 110 + - name: Test 111 + if: |- 111 112 ((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 112 113 Dispatch-Trailer: {"type":"')))) || !(matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 113 - name: Test 114 114 run: go test ./... 115 - - if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 116 - name: Test with -race 117 - run: go test -race ./... 115 + - name: Test with -race 118 116 env: 119 117 GORACE: atexit_sleep_ms=10 118 + if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 119 + run: go test -race ./... 120 120 - name: Test with -tags=cuewasm 121 121 run: go test -tags cuewasm ./cmd/cue/cmd ./cue/interpreter/wasm 122 122 - name: gcloud auth for end-to-end tests 123 123 id: auth 124 + uses: google-github-actions/auth@v2 124 125 if: |- 125 126 github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 126 127 Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 127 - uses: google-github-actions/auth@v2 128 128 with: 129 129 credentials_json: ${{ secrets.E2E_GCLOUD_KEY }} 130 - - if: |- 130 + - name: gcloud setup for end-to-end tests 131 + if: |- 131 132 github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 132 133 Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 133 - name: gcloud setup for end-to-end tests 134 134 uses: google-github-actions/setup-gcloud@v2 135 - - if: |- 135 + - name: End-to-end test 136 + env: 137 + CUE_TEST_LOGINS: ${{ secrets.E2E_CUE_LOGINS }} 138 + if: |- 136 139 github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, ' 137 140 Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04') 138 - name: End-to-end test 139 - env: 140 - CUE_TEST_LOGINS: ${{ secrets.E2E_CUE_LOGINS }} 141 141 run: |- 142 142 cd internal/_e2e 143 143 go test -race ··· 147 147 go vet ./... 148 148 go mod tidy 149 149 (cd internal/_e2e && go test -run=-) 150 - - if: always() 151 - name: Check that git is clean at the end of the job 150 + - name: Check that git is clean at the end of the job 151 + if: always() 152 152 run: test -z "$(git status --porcelain)" || (git status; git diff; false)
+7 -7
.github/workflows/trybot_dispatch.yml
··· 9 9 jobs: 10 10 trybot: 11 11 runs-on: ubuntu-22.04 12 + if: ${{ ((github.ref == 'refs/heads/ci/test') && false) || github.event.client_payload.type == 'trybot' }} 12 13 defaults: 13 14 run: 14 15 shell: bash 15 - if: ${{ ((github.ref == 'refs/heads/ci/test') && false) || github.event.client_payload.type == 'trybot' }} 16 16 steps: 17 17 - name: Write netrc file for cueckoo Gerrithub 18 18 run: |- ··· 22 22 password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }} 23 23 EOD 24 24 chmod 600 ~/.netrc 25 - - id: payload 25 + - name: Write fake payload 26 + id: payload 26 27 if: github.repository == 'cue-lang/cue' && (github.ref == 'refs/heads/ci/test') 27 - name: Write fake payload 28 28 run: |- 29 29 cat <<EOD >> $GITHUB_OUTPUT 30 30 value<<DOE 31 31 null 32 32 DOE 33 33 EOD 34 - - if: github.event.client_payload.type != 'trybot' 35 - name: Trigger TryBot (fake data) 34 + - name: Trigger TryBot (fake data) 35 + if: github.event.client_payload.type != 'trybot' 36 36 run: |- 37 37 mkdir tmpgit 38 38 cd tmpgit ··· 81 81 echo "Giving up" 82 82 exit 1 83 83 fi 84 - - if: github.event.client_payload.type == 'trybot' 85 - name: Trigger TryBot (repository_dispatch payload) 84 + - name: Trigger TryBot (repository_dispatch payload) 85 + if: github.event.client_payload.type == 'trybot' 86 86 run: |- 87 87 mkdir tmpgit 88 88 cd tmpgit
+34 -33
cue.mod/pkg/github.com/SchemaStore/schemastore/src/schemas/json/github-workflow.cue
··· 18 18 // files, tags, or branch changes. For a list of available 19 19 // events, see 20 20 // https://help.github.com/en/github/automating-your-workflow-with-github-actions/events-that-trigger-workflows. 21 - on!: #event | [...#event] & [_, ...] | { 21 + on!: matchN(1, [#event, [...#event] & [_, ...], { 22 22 // Runs your workflow anytime the branch_protection_rule event 23 23 // occurs. More than one activity type triggers this event. 24 24 branch_protection_rule?: #eventObject & (null | bool | number | string | [...] | { ··· 460 460 schedule?: [...null | bool | number | string | [...] | { 461 461 cron?: string 462 462 }] & [_, ...] 463 - } 463 + }]) 464 464 465 465 // A map of environment variables that are available to all jobs 466 466 // and steps in the workflow. ··· 482 482 // will be canceled. To also cancel any currently running job or 483 483 // workflow in the same concurrency group, specify 484 484 // cancel-in-progress: true. 485 - concurrency?: string | #concurrency 485 + concurrency?: matchN(1, [string, #concurrency]) 486 486 487 487 // A workflow run is made up of one or more jobs. Jobs run in 488 488 // parallel by default. To run jobs sequentially, you can define ··· 494 494 // within the workflow usage limits. For more information, see 495 495 // https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#usage-limits. 496 496 jobs!: { 497 - {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: #normalJob | #reusableWorkflowCallJob} 497 + {[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$" & !~"^()$"]: matchN(1, [#normalJob, #reusableWorkflowCallJob])} 498 498 } 499 499 500 500 // The name for workflow runs generated from the workflow. GitHub ··· 517 517 518 518 // To cancel any currently running job or workflow in the same 519 519 // concurrency group, specify cancel-in-progress: true. 520 - "cancel-in-progress"?: bool | #expressionSyntax 520 + "cancel-in-progress"?: matchN(1, [bool, #expressionSyntax]) 521 521 } 522 522 523 - #configuration: string | number | bool | { 523 + #configuration: matchN(1, [string, number, bool, { 524 524 [string]: #configuration 525 - } | [...#configuration] 525 + }, [...#configuration]]) 526 526 527 527 #container: { 528 528 // The Docker image to use as the container to run the action. The ··· 567 567 "working-directory"?: #["working-directory"] 568 568 } 569 569 570 - #permissions: "read-all" | "write-all" | #["permissions-event"] 570 + #permissions: matchN(1, ["read-all" | "write-all", #["permissions-event"]]) 571 571 572 572 #: "permissions-event": { 573 573 actions?: #["permissions-level"] ··· 588 588 589 589 #: "permissions-level": "read" | "write" | "none" 590 590 591 - #env: { 591 + #env: matchN(1, [{ 592 592 [string]: bool | number | string 593 - } | #stringContainingExpressionSyntax 593 + }, #stringContainingExpressionSyntax]) 594 594 595 595 #environment: { 596 596 // The name of the environment configured in the repo. ··· 634 634 ... 635 635 } 636 636 637 - #shell: string | ("bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell") 637 + #shell: matchN(>=1, [string, "bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell"]) 638 638 639 639 #types: [_, ...] 640 640 641 641 #: "working-directory": string 642 642 643 - #jobNeeds: [...#name] & [_, ...] | #name 643 + #jobNeeds: matchN(1, [[...#name] & [_, ...], #name]) 644 644 645 - #matrix: { 646 - {[=~"^(in|ex)clude$" & !~"^()$"]: #expressionSyntax | [...{ 645 + #matrix: matchN(1, [{ 646 + {[=~"^(in|ex)clude$" & !~"^()$"]: matchN(1, [#expressionSyntax, [...{ 647 647 [string]: #configuration 648 - }] & [_, ...]} 649 - {[!~"^(in|ex)clude$" & !~"^()$"]: [...#configuration] & [_, ...] | #expressionSyntax} 650 - } | #expressionSyntax 648 + }] & [_, ...]]) 649 + } 650 + {[!~"^(in|ex)clude$" & !~"^()$"]: matchN(1, [[...#configuration] & [_, ...], #expressionSyntax])} 651 + }, #expressionSyntax]) 651 652 652 653 #reusableWorkflowCallJob: { 653 654 // The name of the job displayed on GitHub. ··· 683 684 // 'secrets' to provide a map of secrets that are passed to the 684 685 // called workflow. Any secrets that you pass must match the 685 686 // names defined in the called workflow. 686 - secrets?: #env | "inherit" 687 + secrets?: matchN(1, [#env, "inherit"]) 687 688 688 689 // A strategy creates a build matrix for your jobs. You can define 689 690 // different variations of an environment to run each job in. ··· 713 714 // will be canceled. To also cancel any currently running job or 714 715 // workflow in the same concurrency group, specify 715 716 // cancel-in-progress: true. 716 - concurrency?: string | #concurrency 717 + concurrency?: matchN(1, [string, #concurrency]) 717 718 } 718 719 719 720 #normalJob: { ··· 724 725 725 726 // The type of machine to run the job on. The machine can be 726 727 // either a GitHub-hosted runner, or a self-hosted runner. 727 - "runs-on"!: string | [string] & [_, ...] | { 728 + "runs-on"!: matchN(>=1, [string, matchN(>=1, [[string] & [_, ...]]), { 728 729 group?: string 729 - labels?: string | [...string] 730 + labels?: matchN(1, [string, [...string]]) 730 731 ... 731 - } | #stringContainingExpressionSyntax | #expressionSyntax 732 + }, #stringContainingExpressionSyntax, #expressionSyntax]) 732 733 733 734 // The environment that the job references. 734 - environment?: string | #environment 735 + environment?: matchN(1, [string, #environment]) 735 736 736 737 // A map of outputs for a job. Job outputs are available to all 737 738 // downstream jobs that depend on this job. ··· 765 766 // environment variables are not preserved between steps. GitHub 766 767 // provides built-in steps to set up and complete a job. 767 768 // Must contain either `uses` or `run` 768 - steps?: [...({ 769 + steps?: [...matchN(2, [matchN(1, [{ 769 770 uses!: string 770 771 ... 771 - } | { 772 + }, { 772 773 run!: string 773 774 ... 774 - }) & { 775 + }]), { 775 776 // A unique identifier for the step. You can use the id to 776 777 // reference the step in contexts. For more information, see 777 778 // https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions. ··· 847 848 848 849 // Prevents a job from failing when a step fails. Set to true to 849 850 // allow a job to pass when this step fails. 850 - "continue-on-error"?: bool | #expressionSyntax | *false 851 + "continue-on-error"?: matchN(1, [bool, #expressionSyntax]) | *false 851 852 852 853 // The maximum number of minutes to run the step before killing 853 854 // the process. 854 - "timeout-minutes"?: number | #expressionSyntax 855 - }] & [_, ...] 855 + "timeout-minutes"?: matchN(1, [number, #expressionSyntax]) 856 + }])] & [_, ...] 856 857 857 858 // The maximum number of minutes to let a workflow run before 858 859 // GitHub automatically cancels it. Default: 360 859 - "timeout-minutes"?: number | #expressionSyntax | *360 860 + "timeout-minutes"?: matchN(1, [number, #expressionSyntax]) | *360 860 861 861 862 // A strategy creates a build matrix for your jobs. You can define 862 863 // different variations of an environment to run each job in. ··· 876 877 877 878 // Prevents a workflow run from failing when a job fails. Set to 878 879 // true to allow a workflow run to pass when this job fails. 879 - "continue-on-error"?: bool | #expressionSyntax 880 + "continue-on-error"?: matchN(1, [bool, #expressionSyntax]) 880 881 881 882 // A container to run any steps in a job that don't already 882 883 // specify a container. If you have steps that use both script ··· 886 887 // If you do not set a container, all steps will run directly on 887 888 // the host specified by runs-on unless a step refers to an 888 889 // action configured to run in a container. 889 - container?: string | #container 890 + container?: matchN(1, [string, #container]) 890 891 891 892 // Additional containers to host services for a job in a workflow. 892 893 // These are useful for creating databases or cache services like ··· 918 919 // will be canceled. To also cancel any currently running job or 919 920 // workflow in the same concurrency group, specify 920 921 // cancel-in-progress: true. 921 - concurrency?: string | #concurrency 922 + concurrency?: matchN(1, [string, #concurrency]) 922 923 } 923 924 }
-11
cue.mod/usr/github.com/SchemaStore/schemastore/src/schemas/json/workflow.cue
··· 2 2 3 3 #job: ((#Workflow & {jobs: _}).jobs & {x: _}).x 4 4 #step: ((#job & {steps: _}).steps & [_])[0] 5 - 6 - // CUE does not properly encode a JSON Schema oneOf; see 7 - // https://cuelang.org/issue/3165. For now, apply a temporary workaround which 8 - // forces the other option to bottom. 9 - #Workflow: jobs?: [string]: steps?: [...( 10 - { 11 - uses?: _|_ 12 - } | { 13 - run?: _|_ 14 - }), 15 - ]
+1 -1
encoding/jsonschema/constraints.go
··· 49 49 } 50 50 51 51 // Note: the following table is ordered lexically by keyword name. 52 - // The various implementations are grouped by kind in the constaint-*.go files. 52 + // The various implementations are grouped by kind in the constraint-*.go files. 53 53 54 54 const numPhases = 5 55 55
+53 -12
encoding/jsonschema/constraints_combinator.go
··· 15 15 package jsonschema 16 16 17 17 import ( 18 + "strconv" 19 + 18 20 "cuelang.org/go/cue" 19 21 "cuelang.org/go/cue/ast" 20 22 "cuelang.org/go/cue/token" ··· 23 25 // Constraint combinators. 24 26 25 27 func constraintAllOf(key string, n cue.Value, s *state) { 26 - var a []ast.Expr 27 28 var knownTypes cue.Kind 28 - for _, v := range s.listItems("allOf", n, false) { 29 + items := s.listItems("allOf", n, false) 30 + if len(items) == 0 { 31 + s.errf(n, "allOf requires at least one subschema") 32 + return 33 + } 34 + a := make([]ast.Expr, 0, len(items)) 35 + for _, v := range items { 29 36 x, sub := s.schemaState(v, s.allowedTypes, nil, true) 30 37 s.allowedTypes &= sub.allowedTypes 31 38 if sub.hasConstraints() { ··· 44 51 // as that's a known-impossible assertion? 45 52 if len(a) > 0 { 46 53 s.knownTypes &= knownTypes 47 - s.all.add(n, ast.NewBinExpr(token.AND, a...)) 54 + s.all.add(n, ast.NewCall( 55 + ast.NewIdent("matchN"), 56 + // TODO it would be nice to be able to use a special sentinel "all" value 57 + // here rather than redundantly encoding the length of the list. 58 + &ast.BasicLit{ 59 + Kind: token.INT, 60 + Value: strconv.Itoa(len(items)), 61 + }, 62 + ast.NewList(a...), 63 + )) 48 64 } 49 65 } 50 66 51 67 func constraintAnyOf(key string, n cue.Value, s *state) { 52 68 var types cue.Kind 53 - var a []ast.Expr 54 69 var knownTypes cue.Kind 55 - for _, v := range s.listItems("anyOf", n, false) { 70 + items := s.listItems("anyOf", n, false) 71 + if len(items) == 0 { 72 + s.errf(n, "anyOf requires at least one subschema") 73 + return 74 + } 75 + a := make([]ast.Expr, 0, len(items)) 76 + for _, v := range items { 56 77 x, sub := s.schemaState(v, s.allowedTypes, nil, true) 57 78 types |= sub.allowedTypes 58 79 knownTypes |= sub.knownTypes 59 80 a = append(a, x) 60 81 } 61 82 s.allowedTypes &= types 62 - if len(a) > 0 { 63 - s.knownTypes &= knownTypes 64 - s.all.add(n, ast.NewBinExpr(token.OR, a...)) 65 - } 83 + s.knownTypes &= knownTypes 84 + s.all.add(n, ast.NewCall( 85 + ast.NewIdent("matchN"), 86 + &ast.UnaryExpr{ 87 + Op: token.GEQ, 88 + X: &ast.BasicLit{ 89 + Kind: token.INT, 90 + Value: "1", 91 + }, 92 + }, 93 + ast.NewList(a...), 94 + )) 66 95 } 67 96 68 97 func constraintOneOf(key string, n cue.Value, s *state) { 69 98 var types cue.Kind 70 99 var knownTypes cue.Kind 71 - var a []ast.Expr 72 100 hasSome := false 73 - for _, v := range s.listItems("oneOf", n, false) { 101 + items := s.listItems("oneOf", n, false) 102 + if len(items) == 0 { 103 + s.errf(n, "oneOf requires at least one subschema") 104 + return 105 + } 106 + a := make([]ast.Expr, 0, len(items)) 107 + for _, v := range items { 74 108 x, sub := s.schemaState(v, s.allowedTypes, nil, true) 75 109 types |= sub.allowedTypes 76 110 ··· 89 123 s.allowedTypes &= types 90 124 if len(a) > 0 && hasSome { 91 125 s.knownTypes &= knownTypes 92 - s.all.add(n, ast.NewBinExpr(token.OR, a...)) 126 + s.all.add(n, ast.NewCall( 127 + ast.NewIdent("matchN"), 128 + &ast.BasicLit{ 129 + Kind: token.INT, 130 + Value: "1", 131 + }, 132 + ast.NewList(a...), 133 + )) 93 134 } 94 135 95 136 // TODO: oneOf({a:x}, {b:y}, ..., not(anyOf({a:x}, {b:y}, ...))),
+6 -2
encoding/jsonschema/decode_test.go
··· 68 68 test.Run(t, func(t *cuetxtar.Test) { 69 69 cfg := &jsonschema.Config{} 70 70 71 + if t.HasTag("brokenInV2") && t.M.Name() == "v2" { 72 + t.Skip("skipping because test is broken under the v2 evaluator") 73 + } 74 + 71 75 if t.HasTag("openapi") { 72 76 cfg.Root = "#/components/schemas/" 73 77 cfg.Map = func(p token.Pos, a []string) ([]ast.Label, error) { ··· 119 123 // Verify that the generated CUE compiles. 120 124 schemav := ctx.CompileBytes(b, cue.Filename("generated.cue")) 121 125 if err := schemav.Err(); err != nil { 122 - t.Fatal(errors.Details(err, nil)) 126 + t.Fatal(errors.Details(err, nil), qt.Commentf("generated code: %q", b)) 123 127 } 124 128 testEntries, err := fs.ReadDir(fsys, "test") 125 129 if err != nil { ··· 168 172 } 169 173 } else { 170 174 if err := rv.Err(); err != nil { 171 - t.Fatalf("test %v unexpectedly fails", file) 175 + t.Fatalf("test %v unexpectedly fails: %v", file, errors.Details(err, nil)) 172 176 } 173 177 } 174 178 }
+2 -2
encoding/jsonschema/testdata/external/tests/draft2019-09/additionalItems.json
··· 230 230 ], 231 231 "valid": true, 232 232 "skip": { 233 - "v2": "5 errors in empty disjunction:\nconflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 234 - "v3": "conflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\nincompatible list lengths (1 and 2):\n instance.json:1:1\n" 233 + "v2": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n", 234 + "v3": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 235 235 } 236 236 } 237 237 ]
+24 -6
encoding/jsonschema/testdata/external/tests/draft2019-09/allOf.json
··· 40 40 "data": { 41 41 "foo": "baz" 42 42 }, 43 - "valid": false 43 + "valid": false, 44 + "skip": { 45 + "v3": "unexpected success" 46 + } 44 47 }, 45 48 { 46 49 "description": "mismatch first", 47 50 "data": { 48 51 "bar": 2 49 52 }, 50 - "valid": false 53 + "valid": false, 54 + "skip": { 55 + "v3": "unexpected success" 56 + } 51 57 }, 52 58 { 53 59 "description": "wrong type", ··· 118 124 "bar": 2, 119 125 "baz": null 120 126 }, 121 - "valid": false 127 + "valid": false, 128 + "skip": { 129 + "v3": "unexpected success" 130 + } 122 131 }, 123 132 { 124 133 "description": "mismatch second allOf", ··· 126 135 "foo": "quux", 127 136 "bar": 2 128 137 }, 129 - "valid": false 138 + "valid": false, 139 + "skip": { 140 + "v3": "unexpected success" 141 + } 130 142 }, 131 143 { 132 144 "description": "mismatch both", 133 145 "data": { 134 146 "bar": 2 135 147 }, 136 - "valid": false 148 + "valid": false, 149 + "skip": { 150 + "v3": "unexpected success" 151 + } 137 152 } 138 153 ] 139 154 }, ··· 369 384 { 370 385 "description": "allOf: false, anyOf: true, oneOf: true", 371 386 "data": 15, 372 - "valid": false 387 + "valid": false, 388 + "skip": { 389 + "v2": "unexpected success" 390 + } 373 391 }, 374 392 { 375 393 "description": "allOf: true, anyOf: false, oneOf: false",
+10 -14
encoding/jsonschema/testdata/external/tests/draft2019-09/anyOf.json
··· 93 93 false 94 94 ] 95 95 }, 96 + "skip": { 97 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:17\n" 98 + }, 96 99 "tests": [ 97 100 { 98 101 "description": "any value is valid", 99 102 "data": "foo", 100 - "valid": true 103 + "valid": true, 104 + "skip": { 105 + "v3": "could not compile schema" 106 + } 101 107 } 102 108 ] 103 109 }, ··· 111 117 ] 112 118 }, 113 119 "skip": { 114 - "v2": "extract error: cannot compile resulting schema: 2 errors in empty disjunction:\nexplicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n", 115 - "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n" 120 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:14\n" 116 121 }, 117 122 "tests": [ 118 123 { ··· 120 125 "data": "foo", 121 126 "valid": false, 122 127 "skip": { 123 - "v2": "could not compile schema", 124 128 "v3": "could not compile schema" 125 129 } 126 130 } ··· 159 163 "data": { 160 164 "bar": 2 161 165 }, 162 - "valid": true, 163 - "skip": { 164 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 165 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 166 - } 166 + "valid": true 167 167 }, 168 168 { 169 169 "description": "second anyOf valid (complex)", 170 170 "data": { 171 171 "foo": "baz" 172 172 }, 173 - "valid": true, 174 - "skip": { 175 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 176 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 177 - } 173 + "valid": true 178 174 }, 179 175 { 180 176 "description": "both anyOf valid (complex)",
+10 -38
encoding/jsonschema/testdata/external/tests/draft2019-09/oneOf.json
··· 26 26 { 27 27 "description": "both oneOf valid", 28 28 "data": 3, 29 - "valid": false, 30 - "skip": { 31 - "v2": "unexpected success", 32 - "v3": "unexpected success" 33 - } 29 + "valid": false 34 30 }, 35 31 { 36 32 "description": "neither oneOf valid", ··· 67 63 { 68 64 "description": "both oneOf valid", 69 65 "data": "foo", 70 - "valid": false, 71 - "skip": { 72 - "v2": "unexpected success", 73 - "v3": "unexpected success" 74 - } 66 + "valid": false 75 67 } 76 68 ] 77 69 }, ··· 194 186 }, 195 187 "valid": true, 196 188 "skip": { 197 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 198 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 189 + "v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 199 190 } 200 191 }, 201 192 { ··· 205 196 }, 206 197 "valid": true, 207 198 "skip": { 208 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 209 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 199 + "v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 210 200 } 211 201 }, 212 202 { ··· 215 205 "foo": "baz", 216 206 "bar": 2 217 207 }, 218 - "valid": false, 219 - "skip": { 220 - "v2": "unexpected success", 221 - "v3": "unexpected success" 222 - } 208 + "valid": false 223 209 }, 224 210 { 225 211 "description": "neither oneOf valid (complex)", ··· 293 279 "foo": 1, 294 280 "bar": 2 295 281 }, 296 - "valid": true, 297 - "skip": { 298 - "v2": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n", 299 - "v3": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n" 300 - } 282 + "valid": true 301 283 }, 302 284 { 303 285 "description": "second valid - valid", ··· 305 287 "foo": 1, 306 288 "baz": 3 307 289 }, 308 - "valid": true, 309 - "skip": { 310 - "v2": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n", 311 - "v3": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n" 312 - } 290 + "valid": true 313 291 }, 314 292 { 315 293 "description": "both valid - invalid", ··· 318 296 "bar": 2, 319 297 "baz": 3 320 298 }, 321 - "valid": false, 322 - "skip": { 323 - "v2": "unexpected success", 324 - "v3": "unexpected success" 325 - } 299 + "valid": false 326 300 } 327 301 ] 328 302 }, ··· 358 332 }, 359 333 "valid": true, 360 334 "skip": { 361 - "v2": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n", 362 - "v3": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n" 335 + "v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 363 336 } 364 337 }, 365 338 { ··· 369 342 }, 370 343 "valid": true, 371 344 "skip": { 372 - "v2": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n", 373 - "v3": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n" 345 + "v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 374 346 } 375 347 }, 376 348 {
+24 -6
encoding/jsonschema/testdata/external/tests/draft2020-12/allOf.json
··· 40 40 "data": { 41 41 "foo": "baz" 42 42 }, 43 - "valid": false 43 + "valid": false, 44 + "skip": { 45 + "v3": "unexpected success" 46 + } 44 47 }, 45 48 { 46 49 "description": "mismatch first", 47 50 "data": { 48 51 "bar": 2 49 52 }, 50 - "valid": false 53 + "valid": false, 54 + "skip": { 55 + "v3": "unexpected success" 56 + } 51 57 }, 52 58 { 53 59 "description": "wrong type", ··· 118 124 "bar": 2, 119 125 "baz": null 120 126 }, 121 - "valid": false 127 + "valid": false, 128 + "skip": { 129 + "v3": "unexpected success" 130 + } 122 131 }, 123 132 { 124 133 "description": "mismatch second allOf", ··· 126 135 "foo": "quux", 127 136 "bar": 2 128 137 }, 129 - "valid": false 138 + "valid": false, 139 + "skip": { 140 + "v3": "unexpected success" 141 + } 130 142 }, 131 143 { 132 144 "description": "mismatch both", 133 145 "data": { 134 146 "bar": 2 135 147 }, 136 - "valid": false 148 + "valid": false, 149 + "skip": { 150 + "v3": "unexpected success" 151 + } 137 152 } 138 153 ] 139 154 }, ··· 369 384 { 370 385 "description": "allOf: false, anyOf: true, oneOf: true", 371 386 "data": 15, 372 - "valid": false 387 + "valid": false, 388 + "skip": { 389 + "v2": "unexpected success" 390 + } 373 391 }, 374 392 { 375 393 "description": "allOf: true, anyOf: false, oneOf: false",
+10 -14
encoding/jsonschema/testdata/external/tests/draft2020-12/anyOf.json
··· 93 93 false 94 94 ] 95 95 }, 96 + "skip": { 97 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:17\n" 98 + }, 96 99 "tests": [ 97 100 { 98 101 "description": "any value is valid", 99 102 "data": "foo", 100 - "valid": true 103 + "valid": true, 104 + "skip": { 105 + "v3": "could not compile schema" 106 + } 101 107 } 102 108 ] 103 109 }, ··· 111 117 ] 112 118 }, 113 119 "skip": { 114 - "v2": "extract error: cannot compile resulting schema: 2 errors in empty disjunction:\nexplicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n", 115 - "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n" 120 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:14\n" 116 121 }, 117 122 "tests": [ 118 123 { ··· 120 125 "data": "foo", 121 126 "valid": false, 122 127 "skip": { 123 - "v2": "could not compile schema", 124 128 "v3": "could not compile schema" 125 129 } 126 130 } ··· 159 163 "data": { 160 164 "bar": 2 161 165 }, 162 - "valid": true, 163 - "skip": { 164 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 165 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 166 - } 166 + "valid": true 167 167 }, 168 168 { 169 169 "description": "second anyOf valid (complex)", 170 170 "data": { 171 171 "foo": "baz" 172 172 }, 173 - "valid": true, 174 - "skip": { 175 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 176 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 177 - } 173 + "valid": true 178 174 }, 179 175 { 180 176 "description": "both anyOf valid (complex)",
+10 -38
encoding/jsonschema/testdata/external/tests/draft2020-12/oneOf.json
··· 26 26 { 27 27 "description": "both oneOf valid", 28 28 "data": 3, 29 - "valid": false, 30 - "skip": { 31 - "v2": "unexpected success", 32 - "v3": "unexpected success" 33 - } 29 + "valid": false 34 30 }, 35 31 { 36 32 "description": "neither oneOf valid", ··· 67 63 { 68 64 "description": "both oneOf valid", 69 65 "data": "foo", 70 - "valid": false, 71 - "skip": { 72 - "v2": "unexpected success", 73 - "v3": "unexpected success" 74 - } 66 + "valid": false 75 67 } 76 68 ] 77 69 }, ··· 194 186 }, 195 187 "valid": true, 196 188 "skip": { 197 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 198 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 189 + "v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 199 190 } 200 191 }, 201 192 { ··· 205 196 }, 206 197 "valid": true, 207 198 "skip": { 208 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 209 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 199 + "v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 210 200 } 211 201 }, 212 202 { ··· 215 205 "foo": "baz", 216 206 "bar": 2 217 207 }, 218 - "valid": false, 219 - "skip": { 220 - "v2": "unexpected success", 221 - "v3": "unexpected success" 222 - } 208 + "valid": false 223 209 }, 224 210 { 225 211 "description": "neither oneOf valid (complex)", ··· 293 279 "foo": 1, 294 280 "bar": 2 295 281 }, 296 - "valid": true, 297 - "skip": { 298 - "v2": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n", 299 - "v3": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n" 300 - } 282 + "valid": true 301 283 }, 302 284 { 303 285 "description": "second valid - valid", ··· 305 287 "foo": 1, 306 288 "baz": 3 307 289 }, 308 - "valid": true, 309 - "skip": { 310 - "v2": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n", 311 - "v3": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n" 312 - } 290 + "valid": true 313 291 }, 314 292 { 315 293 "description": "both valid - invalid", ··· 318 296 "bar": 2, 319 297 "baz": 3 320 298 }, 321 - "valid": false, 322 - "skip": { 323 - "v2": "unexpected success", 324 - "v3": "unexpected success" 325 - } 299 + "valid": false 326 300 } 327 301 ] 328 302 }, ··· 358 332 }, 359 333 "valid": true, 360 334 "skip": { 361 - "v2": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n", 362 - "v3": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n" 335 + "v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 363 336 } 364 337 }, 365 338 { ··· 369 342 }, 370 343 "valid": true, 371 344 "skip": { 372 - "v2": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n", 373 - "v3": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n" 345 + "v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n" 374 346 } 375 347 }, 376 348 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft4/additionalItems.json
··· 192 192 ], 193 193 "valid": true, 194 194 "skip": { 195 - "v2": "5 errors in empty disjunction:\nconflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 196 - "v3": "conflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\nincompatible list lengths (1 and 2):\n instance.json:1:1\n" 195 + "v2": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n", 196 + "v3": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 197 197 } 198 198 } 199 199 ]
+24 -6
encoding/jsonschema/testdata/external/tests/draft4/allOf.json
··· 39 39 "data": { 40 40 "foo": "baz" 41 41 }, 42 - "valid": false 42 + "valid": false, 43 + "skip": { 44 + "v3": "unexpected success" 45 + } 43 46 }, 44 47 { 45 48 "description": "mismatch first", 46 49 "data": { 47 50 "bar": 2 48 51 }, 49 - "valid": false 52 + "valid": false, 53 + "skip": { 54 + "v3": "unexpected success" 55 + } 50 56 }, 51 57 { 52 58 "description": "wrong type", ··· 116 122 "bar": 2, 117 123 "baz": null 118 124 }, 119 - "valid": false 125 + "valid": false, 126 + "skip": { 127 + "v3": "unexpected success" 128 + } 120 129 }, 121 130 { 122 131 "description": "mismatch second allOf", ··· 124 133 "foo": "quux", 125 134 "bar": 2 126 135 }, 127 - "valid": false 136 + "valid": false, 137 + "skip": { 138 + "v3": "unexpected success" 139 + } 128 140 }, 129 141 { 130 142 "description": "mismatch both", 131 143 "data": { 132 144 "bar": 2 133 145 }, 134 - "valid": false 146 + "valid": false, 147 + "skip": { 148 + "v3": "unexpected success" 149 + } 135 150 } 136 151 ] 137 152 }, ··· 301 316 { 302 317 "description": "allOf: false, anyOf: true, oneOf: true", 303 318 "data": 15, 304 - "valid": false 319 + "valid": false, 320 + "skip": { 321 + "v2": "unexpected success" 322 + } 305 323 }, 306 324 { 307 325 "description": "allOf: true, anyOf: false, oneOf: false",
+2 -10
encoding/jsonschema/testdata/external/tests/draft4/anyOf.json
··· 97 97 "data": { 98 98 "bar": 2 99 99 }, 100 - "valid": true, 101 - "skip": { 102 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 103 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 104 - } 100 + "valid": true 105 101 }, 106 102 { 107 103 "description": "second anyOf valid (complex)", 108 104 "data": { 109 105 "foo": "baz" 110 106 }, 111 - "valid": true, 112 - "skip": { 113 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 114 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 115 - } 107 + "valid": true 116 108 }, 117 109 { 118 110 "description": "both anyOf valid (complex)",
+10 -38
encoding/jsonschema/testdata/external/tests/draft4/oneOf.json
··· 25 25 { 26 26 "description": "both oneOf valid", 27 27 "data": 3, 28 - "valid": false, 29 - "skip": { 30 - "v2": "unexpected success", 31 - "v3": "unexpected success" 32 - } 28 + "valid": false 33 29 }, 34 30 { 35 31 "description": "neither oneOf valid", ··· 65 61 { 66 62 "description": "both oneOf valid", 67 63 "data": "foo", 68 - "valid": false, 69 - "skip": { 70 - "v2": "unexpected success", 71 - "v3": "unexpected success" 72 - } 64 + "valid": false 73 65 } 74 66 ] 75 67 }, ··· 107 99 }, 108 100 "valid": true, 109 101 "skip": { 110 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 111 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 102 + "v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 112 103 } 113 104 }, 114 105 { ··· 118 109 }, 119 110 "valid": true, 120 111 "skip": { 121 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 122 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 112 + "v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 123 113 } 124 114 }, 125 115 { ··· 128 118 "foo": "baz", 129 119 "bar": 2 130 120 }, 131 - "valid": false, 132 - "skip": { 133 - "v2": "unexpected success", 134 - "v3": "unexpected success" 135 - } 121 + "valid": false 136 122 }, 137 123 { 138 124 "description": "neither oneOf valid (complex)", ··· 204 190 "foo": 1, 205 191 "bar": 2 206 192 }, 207 - "valid": true, 208 - "skip": { 209 - "v2": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n", 210 - "v3": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n" 211 - } 193 + "valid": true 212 194 }, 213 195 { 214 196 "description": "second valid - valid", ··· 216 198 "foo": 1, 217 199 "baz": 3 218 200 }, 219 - "valid": true, 220 - "skip": { 221 - "v2": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n", 222 - "v3": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n" 223 - } 201 + "valid": true 224 202 }, 225 203 { 226 204 "description": "both valid - invalid", ··· 229 207 "bar": 2, 230 208 "baz": 3 231 209 }, 232 - "valid": false, 233 - "skip": { 234 - "v2": "unexpected success", 235 - "v3": "unexpected success" 236 - } 210 + "valid": false 237 211 } 238 212 ] 239 213 }, ··· 268 242 }, 269 243 "valid": true, 270 244 "skip": { 271 - "v2": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n", 272 - "v3": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n" 245 + "v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 273 246 } 274 247 }, 275 248 { ··· 279 252 }, 280 253 "valid": true, 281 254 "skip": { 282 - "v2": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n", 283 - "v3": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n" 255 + "v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 284 256 } 285 257 }, 286 258 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft6/additionalItems.json
··· 223 223 ], 224 224 "valid": true, 225 225 "skip": { 226 - "v2": "5 errors in empty disjunction:\nconflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 227 - "v3": "conflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\nincompatible list lengths (1 and 2):\n instance.json:1:1\n" 226 + "v2": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n", 227 + "v3": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 228 228 } 229 229 } 230 230 ]
+24 -6
encoding/jsonschema/testdata/external/tests/draft6/allOf.json
··· 39 39 "data": { 40 40 "foo": "baz" 41 41 }, 42 - "valid": false 42 + "valid": false, 43 + "skip": { 44 + "v3": "unexpected success" 45 + } 43 46 }, 44 47 { 45 48 "description": "mismatch first", 46 49 "data": { 47 50 "bar": 2 48 51 }, 49 - "valid": false 52 + "valid": false, 53 + "skip": { 54 + "v3": "unexpected success" 55 + } 50 56 }, 51 57 { 52 58 "description": "wrong type", ··· 116 122 "bar": 2, 117 123 "baz": null 118 124 }, 119 - "valid": false 125 + "valid": false, 126 + "skip": { 127 + "v3": "unexpected success" 128 + } 120 129 }, 121 130 { 122 131 "description": "mismatch second allOf", ··· 124 133 "foo": "quux", 125 134 "bar": 2 126 135 }, 127 - "valid": false 136 + "valid": false, 137 + "skip": { 138 + "v3": "unexpected success" 139 + } 128 140 }, 129 141 { 130 142 "description": "mismatch both", 131 143 "data": { 132 144 "bar": 2 133 145 }, 134 - "valid": false 146 + "valid": false, 147 + "skip": { 148 + "v3": "unexpected success" 149 + } 135 150 } 136 151 ] 137 152 }, ··· 357 372 { 358 373 "description": "allOf: false, anyOf: true, oneOf: true", 359 374 "data": 15, 360 - "valid": false 375 + "valid": false, 376 + "skip": { 377 + "v2": "unexpected success" 378 + } 361 379 }, 362 380 { 363 381 "description": "allOf: true, anyOf: false, oneOf: false",
+10 -14
encoding/jsonschema/testdata/external/tests/draft6/anyOf.json
··· 89 89 false 90 90 ] 91 91 }, 92 + "skip": { 93 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:17\n" 94 + }, 92 95 "tests": [ 93 96 { 94 97 "description": "any value is valid", 95 98 "data": "foo", 96 - "valid": true 99 + "valid": true, 100 + "skip": { 101 + "v3": "could not compile schema" 102 + } 97 103 } 98 104 ] 99 105 }, ··· 106 112 ] 107 113 }, 108 114 "skip": { 109 - "v2": "extract error: cannot compile resulting schema: 2 errors in empty disjunction:\nexplicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n", 110 - "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n" 115 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:14\n" 111 116 }, 112 117 "tests": [ 113 118 { ··· 115 120 "data": "foo", 116 121 "valid": false, 117 122 "skip": { 118 - "v2": "could not compile schema", 119 123 "v3": "could not compile schema" 120 124 } 121 125 } ··· 153 157 "data": { 154 158 "bar": 2 155 159 }, 156 - "valid": true, 157 - "skip": { 158 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 159 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 160 - } 160 + "valid": true 161 161 }, 162 162 { 163 163 "description": "second anyOf valid (complex)", 164 164 "data": { 165 165 "foo": "baz" 166 166 }, 167 - "valid": true, 168 - "skip": { 169 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 170 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 171 - } 167 + "valid": true 172 168 }, 173 169 { 174 170 "description": "both anyOf valid (complex)",
+10 -38
encoding/jsonschema/testdata/external/tests/draft6/oneOf.json
··· 25 25 { 26 26 "description": "both oneOf valid", 27 27 "data": 3, 28 - "valid": false, 29 - "skip": { 30 - "v2": "unexpected success", 31 - "v3": "unexpected success" 32 - } 28 + "valid": false 33 29 }, 34 30 { 35 31 "description": "neither oneOf valid", ··· 65 61 { 66 62 "description": "both oneOf valid", 67 63 "data": "foo", 68 - "valid": false, 69 - "skip": { 70 - "v2": "unexpected success", 71 - "v3": "unexpected success" 72 - } 64 + "valid": false 73 65 } 74 66 ] 75 67 }, ··· 187 179 }, 188 180 "valid": true, 189 181 "skip": { 190 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 191 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 182 + "v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 192 183 } 193 184 }, 194 185 { ··· 198 189 }, 199 190 "valid": true, 200 191 "skip": { 201 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 202 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 192 + "v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 203 193 } 204 194 }, 205 195 { ··· 208 198 "foo": "baz", 209 199 "bar": 2 210 200 }, 211 - "valid": false, 212 - "skip": { 213 - "v2": "unexpected success", 214 - "v3": "unexpected success" 215 - } 201 + "valid": false 216 202 }, 217 203 { 218 204 "description": "neither oneOf valid (complex)", ··· 284 270 "foo": 1, 285 271 "bar": 2 286 272 }, 287 - "valid": true, 288 - "skip": { 289 - "v2": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n", 290 - "v3": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n" 291 - } 273 + "valid": true 292 274 }, 293 275 { 294 276 "description": "second valid - valid", ··· 296 278 "foo": 1, 297 279 "baz": 3 298 280 }, 299 - "valid": true, 300 - "skip": { 301 - "v2": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n", 302 - "v3": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n" 303 - } 281 + "valid": true 304 282 }, 305 283 { 306 284 "description": "both valid - invalid", ··· 309 287 "bar": 2, 310 288 "baz": 3 311 289 }, 312 - "valid": false, 313 - "skip": { 314 - "v2": "unexpected success", 315 - "v3": "unexpected success" 316 - } 290 + "valid": false 317 291 } 318 292 ] 319 293 }, ··· 348 322 }, 349 323 "valid": true, 350 324 "skip": { 351 - "v2": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n", 352 - "v3": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n" 325 + "v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 353 326 } 354 327 }, 355 328 { ··· 359 332 }, 360 333 "valid": true, 361 334 "skip": { 362 - "v2": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n", 363 - "v3": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n" 335 + "v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 364 336 } 365 337 }, 366 338 {
+2 -2
encoding/jsonschema/testdata/external/tests/draft7/additionalItems.json
··· 223 223 ], 224 224 "valid": true, 225 225 "skip": { 226 - "v2": "5 errors in empty disjunction:\nconflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:1\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\n", 227 - "v3": "conflicting values [1,null] and {...} (mismatched types list and struct):\n generated.cue:2:41\n instance.json:1:1\nconflicting values bool and [1,null] (mismatched types bool and list):\n generated.cue:2:8\n instance.json:1:1\nconflicting values null and [1,null] (mismatched types null and list):\n generated.cue:2:1\n instance.json:1:1\nconflicting values number and [1,null] (mismatched types number and list):\n generated.cue:2:15\n instance.json:1:1\nconflicting values string and [1,null] (mismatched types string and list):\n generated.cue:2:24\n instance.json:1:1\nincompatible list lengths (1 and 2):\n instance.json:1:1\n" 226 + "v2": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n", 227 + "v3": "invalid value [1,null] (does not satisfy matchN(1, [null | bool | number | string | [int] | {}])): 0 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 228 228 } 229 229 } 230 230 ]
+24 -6
encoding/jsonschema/testdata/external/tests/draft7/allOf.json
··· 39 39 "data": { 40 40 "foo": "baz" 41 41 }, 42 - "valid": false 42 + "valid": false, 43 + "skip": { 44 + "v3": "unexpected success" 45 + } 43 46 }, 44 47 { 45 48 "description": "mismatch first", 46 49 "data": { 47 50 "bar": 2 48 51 }, 49 - "valid": false 52 + "valid": false, 53 + "skip": { 54 + "v3": "unexpected success" 55 + } 50 56 }, 51 57 { 52 58 "description": "wrong type", ··· 116 122 "bar": 2, 117 123 "baz": null 118 124 }, 119 - "valid": false 125 + "valid": false, 126 + "skip": { 127 + "v3": "unexpected success" 128 + } 120 129 }, 121 130 { 122 131 "description": "mismatch second allOf", ··· 124 133 "foo": "quux", 125 134 "bar": 2 126 135 }, 127 - "valid": false 136 + "valid": false, 137 + "skip": { 138 + "v3": "unexpected success" 139 + } 128 140 }, 129 141 { 130 142 "description": "mismatch both", 131 143 "data": { 132 144 "bar": 2 133 145 }, 134 - "valid": false 146 + "valid": false, 147 + "skip": { 148 + "v3": "unexpected success" 149 + } 135 150 } 136 151 ] 137 152 }, ··· 357 372 { 358 373 "description": "allOf: false, anyOf: true, oneOf: true", 359 374 "data": 15, 360 - "valid": false 375 + "valid": false, 376 + "skip": { 377 + "v2": "unexpected success" 378 + } 361 379 }, 362 380 { 363 381 "description": "allOf: true, anyOf: false, oneOf: false",
+10 -14
encoding/jsonschema/testdata/external/tests/draft7/anyOf.json
··· 89 89 false 90 90 ] 91 91 }, 92 + "skip": { 93 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:17\n" 94 + }, 92 95 "tests": [ 93 96 { 94 97 "description": "any value is valid", 95 98 "data": "foo", 96 - "valid": true 99 + "valid": true, 100 + "skip": { 101 + "v3": "could not compile schema" 102 + } 97 103 } 98 104 ] 99 105 }, ··· 106 112 ] 107 113 }, 108 114 "skip": { 109 - "v2": "extract error: cannot compile resulting schema: 2 errors in empty disjunction:\nexplicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n", 110 - "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:1\nexplicit error (_|_ literal) in source:\n generated.cue:2:7\n" 115 + "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:2:14\n" 111 116 }, 112 117 "tests": [ 113 118 { ··· 115 120 "data": "foo", 116 121 "valid": false, 117 122 "skip": { 118 - "v2": "could not compile schema", 119 123 "v3": "could not compile schema" 120 124 } 121 125 } ··· 153 157 "data": { 154 158 "bar": 2 155 159 }, 156 - "valid": true, 157 - "skip": { 158 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 159 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 160 - } 160 + "valid": true 161 161 }, 162 162 { 163 163 "description": "second anyOf valid (complex)", 164 164 "data": { 165 165 "foo": "baz" 166 166 }, 167 - "valid": true, 168 - "skip": { 169 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 170 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 171 - } 167 + "valid": true 172 168 }, 173 169 { 174 170 "description": "both anyOf valid (complex)",
+10 -38
encoding/jsonschema/testdata/external/tests/draft7/oneOf.json
··· 25 25 { 26 26 "description": "both oneOf valid", 27 27 "data": 3, 28 - "valid": false, 29 - "skip": { 30 - "v2": "unexpected success", 31 - "v3": "unexpected success" 32 - } 28 + "valid": false 33 29 }, 34 30 { 35 31 "description": "neither oneOf valid", ··· 65 61 { 66 62 "description": "both oneOf valid", 67 63 "data": "foo", 68 - "valid": false, 69 - "skip": { 70 - "v2": "unexpected success", 71 - "v3": "unexpected success" 72 - } 64 + "valid": false 73 65 } 74 66 ] 75 67 }, ··· 187 179 }, 188 180 "valid": true, 189 181 "skip": { 190 - "v2": "incomplete value {bar:2} | {bar:2,foo!:string}\n", 191 - "v3": "incomplete value {bar:2} | {bar:2,foo!:string}\n" 182 + "v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 192 183 } 193 184 }, 194 185 { ··· 198 189 }, 199 190 "valid": true, 200 191 "skip": { 201 - "v2": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n", 202 - "v3": "incomplete value {foo:\"baz\",bar!:int} | {foo:\"baz\"}\n" 192 + "v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 203 193 } 204 194 }, 205 195 { ··· 208 198 "foo": "baz", 209 199 "bar": 2 210 200 }, 211 - "valid": false, 212 - "skip": { 213 - "v2": "unexpected success", 214 - "v3": "unexpected success" 215 - } 201 + "valid": false 216 202 }, 217 203 { 218 204 "description": "neither oneOf valid (complex)", ··· 284 270 "foo": 1, 285 271 "bar": 2 286 272 }, 287 - "valid": true, 288 - "skip": { 289 - "v2": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n", 290 - "v3": "incomplete value {foo:1,bar:2} | {foo:1,bar:2,baz!:_}\n" 291 - } 273 + "valid": true 292 274 }, 293 275 { 294 276 "description": "second valid - valid", ··· 296 278 "foo": 1, 297 279 "baz": 3 298 280 }, 299 - "valid": true, 300 - "skip": { 301 - "v2": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n", 302 - "v3": "incomplete value {foo:1,baz:3,bar!:_} | {foo:1,baz:3}\n" 303 - } 281 + "valid": true 304 282 }, 305 283 { 306 284 "description": "both valid - invalid", ··· 309 287 "bar": 2, 310 288 "baz": 3 311 289 }, 312 - "valid": false, 313 - "skip": { 314 - "v2": "unexpected success", 315 - "v3": "unexpected success" 316 - } 290 + "valid": false 317 291 } 318 292 ] 319 293 }, ··· 348 322 }, 349 323 "valid": true, 350 324 "skip": { 351 - "v2": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n", 352 - "v3": "incomplete value {bar:8,baz?:_} | {bar:8,foo!:_}\n" 325 + "v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 353 326 } 354 327 }, 355 328 { ··· 359 332 }, 360 333 "valid": true, 361 334 "skip": { 362 - "v2": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n", 363 - "v3": "incomplete value {foo:\"foo\",bar!:_,baz?:_} | {foo:\"foo\"}\n" 335 + "v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n" 364 336 } 365 337 }, 366 338 {
+2 -1
encoding/jsonschema/testdata/txtar/boolschema.txtar
··· 1 + #noverify 1 2 -- schema.json -- 2 3 { 3 4 "anyOf": [ ··· 7 8 } 8 9 9 10 -- out/decode/extract -- 10 - _ | _|_ 11 + matchN(>=1, [_, _|_])
+1 -1
encoding/jsonschema/testdata/txtar/emptyobjinanyof.txtar
··· 23 23 -- out/decode/extract -- 24 24 _ 25 25 26 - #shell: string | ("bash" | "sh" | "cmd" | "powershell") 26 + #shell: matchN(>=1, [string, "bash" | "sh" | "cmd" | "powershell"])
+3 -3
encoding/jsonschema/testdata/txtar/id_in_oneOf.txtar
··· 19 19 -- out/decode/extract -- 20 20 @jsonschema(schema="http://json-schema.org/draft-07/schema#") 21 21 @jsonschema(id="https://test.example/foo") 22 - { 22 + matchN(1, [{ 23 23 @jsonschema(id="https://1.test.example/string") 24 24 string 25 - } | { 25 + }, { 26 26 @jsonschema(id="https://2.test.example/object") 27 27 ... 28 - } 28 + }])
+2 -2
encoding/jsonschema/testdata/txtar/issue3176.txtar
··· 18 18 -- out/decode/extract -- 19 19 import "strings" 20 20 21 - ({ 21 + matchN(1, [{ 22 22 ... 23 - } | strings.MaxRunes(3)) & (string | { 23 + }, strings.MaxRunes(3)]) & (string | { 24 24 {[=~"^x-" & !~"^()$"]: string} 25 25 ... 26 26 })
+74
encoding/jsonschema/testdata/txtar/issue3351.txtar
··· 1 + #noverify 2 + #brokenInV2 1 3 -- schema.json -- 2 4 { 3 5 "$schema": "https://json-schema.org/draft/2019-09/schema", ··· 62 64 "title": "JSON-e templates", 63 65 "type": "object" 64 66 } 67 + -- out/decode-v3/extract -- 68 + _schema 69 + _schema: { 70 + // JSON-e templates 71 + @jsonschema(schema="https://json-schema.org/draft/2019-09/schema") 72 + @jsonschema(id="https://www.sourcemeta.com/schemas/vendor/json-e@1.json") 73 + $else?: #["jsone-value"] 74 + $let?: [string]: null | bool | number | string | [...] | { 75 + [string]: _schema 76 + } 77 + $sort?: matchN(>=1, [_schema, [...number]]) 78 + {[!~"^($else|$let|$sort)$"]: #["jsone-value"]} 79 + 80 + #: "jsone-value": matchN(1, [_schema, [..._schema]]) 81 + 82 + #: "jsone-array": [...#["jsone-value"]] 83 + 84 + #: "jsone-object-array": [..._schema] 85 + } 86 + -- diff/-out/decode-v3/extract<==>+out/decode/extract -- 87 + diff old new 88 + --- old 89 + +++ new 90 + @@ -7,10 +7,10 @@ 91 + $let?: [string]: null | bool | number | string | [...] | { 92 + [string]: _schema 93 + } 94 + - $sort?: _schema | [...number] 95 + + $sort?: matchN(>=1, [_schema, [...number]]) 96 + {[!~"^($else|$let|$sort)$"]: #["jsone-value"]} 97 + 98 + - #: "jsone-value": _schema | [..._schema] 99 + + #: "jsone-value": matchN(1, [_schema, [..._schema]]) 100 + 101 + #: "jsone-array": [...#["jsone-value"]] 102 + 103 + -- out/decode-v3-noshare/extract -- 104 + _schema 105 + _schema: { 106 + // JSON-e templates 107 + @jsonschema(schema="https://json-schema.org/draft/2019-09/schema") 108 + @jsonschema(id="https://www.sourcemeta.com/schemas/vendor/json-e@1.json") 109 + $else?: #["jsone-value"] 110 + $let?: [string]: null | bool | number | string | [...] | { 111 + [string]: _schema 112 + } 113 + $sort?: matchN(>=1, [_schema, [...number]]) 114 + {[!~"^($else|$let|$sort)$"]: #["jsone-value"]} 115 + 116 + #: "jsone-value": matchN(1, [_schema, [..._schema]]) 117 + 118 + #: "jsone-array": [...#["jsone-value"]] 119 + 120 + #: "jsone-object-array": [..._schema] 121 + } 122 + -- diff/-out/decode-v3-noshare/extract<==>+out/decode/extract -- 123 + diff old new 124 + --- old 125 + +++ new 126 + @@ -7,10 +7,10 @@ 127 + $let?: [string]: null | bool | number | string | [...] | { 128 + [string]: _schema 129 + } 130 + - $sort?: _schema | [...number] 131 + + $sort?: matchN(>=1, [_schema, [...number]]) 132 + {[!~"^($else|$let|$sort)$"]: #["jsone-value"]} 133 + 134 + - #: "jsone-value": _schema | [..._schema] 135 + + #: "jsone-value": matchN(1, [_schema, [..._schema]]) 136 + 137 + #: "jsone-array": [...#["jsone-value"]] 138 + 65 139 -- out/decode/extract -- 66 140 _schema 67 141 _schema: {
+33
encoding/jsonschema/testdata/txtar/oneOfWithMatchNField.txtar
··· 1 + Check that fields are quoted correctly if they are named after 2 + the matchN builtin. 3 + 4 + -- schema.json -- 5 + { 6 + "type": "object", 7 + "properties": { 8 + "matchN": { 9 + "oneOf": [ 10 + { 11 + "const": 1 12 + }, 13 + { 14 + "const": 2 15 + } 16 + ] 17 + } 18 + } 19 + } 20 + -- out/decode/extract -- 21 + "matchN"?: matchN(1, [1, 2]) 22 + ... 23 + -- test/ok1.json -- 24 + {"matchN": 1} 25 + -- test/ok2.json -- 26 + {"matchN": 2} 27 + -- test/err-nomatch.json -- 28 + {"matchN": 3} 29 + -- out/decode/testerr/err-nomatch -- 30 + matchN: invalid value 3 (does not satisfy matchN(1, [1,2])): 0 matched, expected 1: 31 + generated.cue:1:12 32 + generated.cue:1:19 33 + test/err-nomatch.json:1:12
+1 -1
encoding/jsonschema/testdata/txtar/type.txtar
··· 39 39 baz: 1.3 40 40 ... 41 41 } 42 - numOrList?: number | [...number] | *[1, 2, 3] 42 + numOrList?: matchN(1, [number, [...number]]) | *[1, 2, 3]
+3 -3
encoding/jsonschema/testdata/txtar/typedis.txtar
··· 39 39 -- out/decode/extract -- 40 40 // Main schema 41 41 intOrString1?: int | string 42 - intOrString2?: int | string 43 - intOrString3?: int | string 44 - disjunction?: int | string | int & >=3 42 + intOrString2?: matchN(1, [int, string]) 43 + intOrString3?: matchN(>=1, [int, string]) 44 + disjunction?: matchN(1, [matchN(>=1, [int, string]), int & >=3]) 45 45 ...
+3 -3
encoding/jsonschema/testdata/txtar/typeexcluded.txtar
··· 120 120 e4?: [...string] 121 121 e5?: int & >=0 122 122 e6?: [...=~"^[A-Za-z0-9 _.-]+$"] 123 - e7?: true | { 123 + e7?: matchN(>=1, [true, matchN(1, [{ 124 124 disableFix?: bool 125 125 ... 126 - } & { 126 + }]) & { 127 127 ignoreMediaFeatureNames?: list.UniqueItems() & [_, ...] & [...string] 128 128 ... 129 - } 129 + }]) 130 130 ...
+1 -1
encoding/jsonschema/testdata/txtar/used.txtar
··· 45 45 46 46 #enum: "a" | "b" | "c" 47 47 48 - #lists: "a" | "b" | "c" | (["X"] | ["X", "a" | "b" | "c"] | ["X", "d" | "e" | "f"]) 48 + #lists: matchN(1, ["a" | "b" | "c", matchN(1, [["X"], ["X", "a" | "b" | "c"], ["X", "d" | "e" | "f"]])])