@@ -3,9 +3,9 @@ import { readdir, readFile } from "node:fs/promises";
33import YAML from "yaml" ;
44import { join } from "node:path" ;
55import { argv } from "node:process" ;
6- import { registerSchema , validate } from "@hyperjump/json-schema/draft-2020-12 " ;
6+ import { registerSchema , validate } from "@hyperjump/json-schema/openapi-3-1 " ;
77import "@hyperjump/json-schema/draft-04" ;
8- import { BASIC , addKeyword , defineVocabulary } from "@hyperjump/json-schema/experimental" ;
8+ import { BASIC , defineVocabulary } from "@hyperjump/json-schema/experimental" ;
99
1010/**
1111 * @import { EvaluationPlugin } from "@hyperjump/json-schema/experimental"
@@ -118,65 +118,22 @@ const runTests = async (schemaUri, testDirectory) => {
118118 } ;
119119} ;
120120
121- addKeyword ( {
122- id : "https://spec.openapis.org/oas/schema/vocab/keyword/discriminator" ,
123- interpret : ( discriminator , instance , context ) => {
124- return true ;
125- } ,
126- /* discriminator is not exactly an annotation, but it's not allowed
127- * to change the validation outcome (hence returing true from interopret())
128- * and for our purposes of testing, this is sufficient.
129- */
130- annotation : ( discriminator ) => {
131- return discriminator ;
132- } ,
133- } ) ;
134-
135- addKeyword ( {
136- id : "https://spec.openapis.org/oas/schema/vocab/keyword/example" ,
137- interpret : ( example , instance , context ) => {
138- return true ;
139- } ,
140- annotation : ( example ) => {
141- return example ;
142- } ,
143- } ) ;
144-
145- addKeyword ( {
146- id : "https://spec.openapis.org/oas/schema/vocab/keyword/externalDocs" ,
147- interpret : ( externalDocs , instance , context ) => {
148- return true ;
149- } ,
150- annotation : ( externalDocs ) => {
151- return externalDocs ;
152- } ,
153- } ) ;
154-
155- addKeyword ( {
156- id : "https://spec.openapis.org/oas/schema/vocab/keyword/xml" ,
157- interpret : ( xml , instance , context ) => {
158- return true ;
159- } ,
160- annotation : ( xml ) => {
161- return xml ;
162- } ,
163- } ) ;
164-
165- defineVocabulary (
166- "https://spec.openapis.org/oas/3.1/vocab/base" ,
167- {
168- "discriminator" : "https://spec.openapis.org/oas/schema/vocab/keyword/discriminator" ,
169- "example" : "https://spec.openapis.org/oas/schema/vocab/keyword/example" ,
170- "externalDocs" : "https://spec.openapis.org/oas/schema/vocab/keyword/externalDocs" ,
171- "xml" : "https://spec.openapis.org/oas/schema/vocab/keyword/xml" ,
172- } ,
173- ) ;
174-
175121const parseYamlFromFile = ( filePath ) => {
176122 const schemaYaml = readFileSync ( filePath , "utf8" ) ;
177123 return YAML . parse ( schemaYaml , { prettyErrors : true } ) ;
178124} ;
179- registerSchema ( parseYamlFromFile ( "./src/schemas/validation/meta.yaml" ) ) ;
125+
126+ const meta = parseYamlFromFile ( "./src/schemas/validation/meta.yaml" ) ;
127+ const oasBaseVocab = Object . keys ( meta . $vocabulary ) [ 0 ] ;
128+
129+ defineVocabulary ( oasBaseVocab , {
130+ "discriminator" : "https://spec.openapis.org/oas/3.0/keyword/discriminator" ,
131+ "example" : "https://spec.openapis.org/oas/3.0/keyword/example" ,
132+ "externalDocs" : "https://spec.openapis.org/oas/3.0/keyword/externalDocs" ,
133+ "xml" : "https://spec.openapis.org/oas/3.0/keyword/xml"
134+ } ) ;
135+
136+ registerSchema ( meta ) ;
180137registerSchema ( parseYamlFromFile ( "./src/schemas/validation/dialect.yaml" ) ) ;
181138registerSchema ( parseYamlFromFile ( "./src/schemas/validation/schema.yaml" ) ) ;
182139
0 commit comments