// Copyright 2024 CUE Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package jsonschema import ( "fmt" "strings" ) //go:generate go tool stringer -type=Version -linecomment type Version int const ( VersionUnknown Version = iota // unknown VersionDraft4 // http://json-schema.org/draft-04/schema# // Note: draft 5 never existed and should not be used. VersionDraft6 // http://json-schema.org/draft-06/schema# VersionDraft7 // http://json-schema.org/draft-07/schema# VersionDraft2019_09 // https://json-schema.org/draft/2019-09/schema VersionDraft2020_12 // https://json-schema.org/draft/2020-12/schema numJSONSchemaVersions // unknown // Note: The following versions stand alone: they're not in the regular JSON Schema lineage. VersionOpenAPI // OpenAPI 3.0 VersionKubernetesAPI // Kubernetes API VersionKubernetesCRD // Kubernetes CRD ) const ( openAPI = versionSet(1 << VersionOpenAPI) k8sAPI = versionSet(1 << VersionKubernetesAPI) k8sCRD = versionSet(1 << VersionKubernetesCRD) k8s = k8sAPI | k8sCRD openAPILike = openAPI | k8s ) // is reports whether v is in the set vs. func (v Version) is(vs versionSet) bool { return vs.contains(v) } type versionSet int // allVersions includes all regular versions of JSON Schema. // It does not include OpenAPI v3.0 const allVersions = versionSet(1<