-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/jsonschema: add OpenAPI 3.0 version support
Although OpenAPI 3.0 is its own fork of JSON Schema, with distinct semantics (new and removed keywords, different semantics for other keywords), `encoding/jsonschema` does not currently have any way of choosing OpenAPI-specific behaviour. Fix that by adding an OpenAPI version. As it's not in the linear progression of other JSON Schema versions (OpenAPI moved to using exactly JSON Schema 2020-12 in 3.1), we treat it distinctly, requiring all keywords to opt into it explicitly. This in turn means that almost all keywords require their version set to be specified explicitly, so it seems like there's no longer much benefit to having the vanilla `p0`, `p1` etc constraint functions, so we change to passing the version set for all constraints. While we're about it, remove `todo` and use the regular `p1` function so that all the constraint names line up nicely. Finally we change `encoding/openapi` to choose the correct version based on the value of the `openapi` field. For #3375 Signed-off-by: Roger Peppe <[email protected]> Change-Id: I0070f8c02a9b403e2018b84919b886b0bc5f29d8 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200578 Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
7 changed files
with
143 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#openapi | ||
#version: openapi | ||
|
||
-- schema.yaml -- | ||
components: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters