@hey-api/json-schema-ref-parser 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -0
  3. package/dist/lib/bundle.d.ts +26 -0
  4. package/dist/lib/bundle.js +293 -0
  5. package/dist/lib/dereference.d.ts +11 -0
  6. package/dist/lib/dereference.js +224 -0
  7. package/dist/lib/index.d.ts +74 -0
  8. package/dist/lib/index.js +208 -0
  9. package/dist/lib/options.d.ts +61 -0
  10. package/dist/lib/options.js +45 -0
  11. package/dist/lib/parse.d.ts +13 -0
  12. package/dist/lib/parse.js +87 -0
  13. package/dist/lib/parsers/binary.d.ts +2 -0
  14. package/dist/lib/parsers/binary.js +12 -0
  15. package/dist/lib/parsers/json.d.ts +2 -0
  16. package/dist/lib/parsers/json.js +38 -0
  17. package/dist/lib/parsers/text.d.ts +2 -0
  18. package/dist/lib/parsers/text.js +18 -0
  19. package/dist/lib/parsers/yaml.d.ts +2 -0
  20. package/dist/lib/parsers/yaml.js +28 -0
  21. package/dist/lib/pointer.d.ts +88 -0
  22. package/dist/lib/pointer.js +293 -0
  23. package/dist/lib/ref.d.ts +180 -0
  24. package/dist/lib/ref.js +226 -0
  25. package/dist/lib/refs.d.ts +127 -0
  26. package/dist/lib/refs.js +232 -0
  27. package/dist/lib/resolve-external.d.ts +13 -0
  28. package/dist/lib/resolve-external.js +147 -0
  29. package/dist/lib/resolvers/file.d.ts +4 -0
  30. package/dist/lib/resolvers/file.js +61 -0
  31. package/dist/lib/resolvers/url.d.ts +11 -0
  32. package/dist/lib/resolvers/url.js +57 -0
  33. package/dist/lib/types/index.d.ts +43 -0
  34. package/dist/lib/types/index.js +2 -0
  35. package/dist/lib/util/convert-path-to-posix.d.ts +1 -0
  36. package/dist/lib/util/convert-path-to-posix.js +14 -0
  37. package/dist/lib/util/errors.d.ts +56 -0
  38. package/dist/lib/util/errors.js +112 -0
  39. package/dist/lib/util/is-windows.d.ts +1 -0
  40. package/dist/lib/util/is-windows.js +6 -0
  41. package/dist/lib/util/plugins.d.ts +16 -0
  42. package/dist/lib/util/plugins.js +45 -0
  43. package/dist/lib/util/url.d.ts +79 -0
  44. package/dist/lib/util/url.js +285 -0
  45. package/dist/vite.config.d.ts +2 -0
  46. package/dist/vite.config.js +18 -0
  47. package/lib/bundle.ts +299 -0
  48. package/lib/dereference.ts +286 -0
  49. package/lib/index.ts +209 -0
  50. package/lib/options.ts +108 -0
  51. package/lib/parse.ts +56 -0
  52. package/lib/parsers/binary.ts +13 -0
  53. package/lib/parsers/json.ts +39 -0
  54. package/lib/parsers/text.ts +21 -0
  55. package/lib/parsers/yaml.ts +26 -0
  56. package/lib/pointer.ts +327 -0
  57. package/lib/ref.ts +279 -0
  58. package/lib/refs.ts +239 -0
  59. package/lib/resolve-external.ts +141 -0
  60. package/lib/resolvers/file.ts +24 -0
  61. package/lib/resolvers/url.ts +78 -0
  62. package/lib/types/index.ts +51 -0
  63. package/lib/util/convert-path-to-posix.ts +11 -0
  64. package/lib/util/errors.ts +153 -0
  65. package/lib/util/is-windows.ts +2 -0
  66. package/lib/util/plugins.ts +56 -0
  67. package/lib/util/url.ts +266 -0
  68. package/package.json +96 -0
package/lib/index.ts ADDED
@@ -0,0 +1,209 @@
1
+ import $Refs from "./refs.js";
2
+ import { newFile, parseFile } from "./parse.js";
3
+ import { resolveExternal } from "./resolve-external.js";
4
+ import _bundle from "./bundle.js";
5
+ import _dereference from "./dereference.js";
6
+ import * as url from "./util/url.js";
7
+ import { isHandledError, JSONParserErrorGroup } from "./util/errors.js";
8
+ import { ono } from "@jsdevtools/ono";
9
+ import { getJsonSchemaRefParserDefaultOptions } from "./options.js";
10
+ import type { JSONSchema } from "./types/index.js";
11
+ import { urlResolver } from "./resolvers/url.js";
12
+ import { fileResolver } from "./resolvers/file.js";
13
+
14
+ interface ResolvedInput {
15
+ path: string;
16
+ schema: string | JSONSchema | Buffer<ArrayBufferLike> | Awaited<JSONSchema> | undefined;
17
+ type: 'file' | 'json' | 'url';
18
+ }
19
+
20
+ export const getResolvedInput = ({
21
+ pathOrUrlOrSchema,
22
+ }: {
23
+ pathOrUrlOrSchema: JSONSchema | string | unknown;
24
+ }): ResolvedInput => {
25
+ if (!pathOrUrlOrSchema) {
26
+ throw ono(`Expected a file path, URL, or object. Got ${pathOrUrlOrSchema}`);
27
+ }
28
+
29
+ const resolvedInput: ResolvedInput = {
30
+ path: typeof pathOrUrlOrSchema === 'string' ? pathOrUrlOrSchema : '',
31
+ schema: undefined,
32
+ type: 'url',
33
+ }
34
+
35
+ // If the path is a filesystem path, then convert it to a URL.
36
+ // NOTE: According to the JSON Reference spec, these should already be URLs,
37
+ // but, in practice, many people use local filesystem paths instead.
38
+ // So we're being generous here and doing the conversion automatically.
39
+ // This is not intended to be a 100% bulletproof solution.
40
+ // If it doesn't work for your use-case, then use a URL instead.
41
+ if (url.isFileSystemPath(resolvedInput.path)) {
42
+ resolvedInput.path = url.fromFileSystemPath(resolvedInput.path);
43
+ resolvedInput.type = 'file';
44
+ } else if (!resolvedInput.path && pathOrUrlOrSchema && typeof pathOrUrlOrSchema === 'object') {
45
+ if ("$id" in pathOrUrlOrSchema && pathOrUrlOrSchema.$id) {
46
+ // when schema id has defined an URL should use that hostname to request the references,
47
+ // instead of using the current page URL
48
+ const { hostname, protocol } = new URL(pathOrUrlOrSchema.$id as string);
49
+ resolvedInput.path = `${protocol}//${hostname}:${protocol === "https:" ? 443 : 80}`;
50
+ resolvedInput.type = 'url';
51
+ } else {
52
+ resolvedInput.schema = pathOrUrlOrSchema;
53
+ resolvedInput.type = 'json';
54
+ }
55
+ }
56
+
57
+ // resolve the absolute path of the schema
58
+ resolvedInput.path = url.resolve(url.cwd(), resolvedInput.path);
59
+
60
+ return resolvedInput;
61
+ }
62
+
63
+ /**
64
+ * This class parses a JSON schema, builds a map of its JSON references and their resolved values,
65
+ * and provides methods for traversing, manipulating, and dereferencing those references.
66
+ */
67
+ export class $RefParser {
68
+ /**
69
+ * The resolved JSON references
70
+ *
71
+ * @type {$Refs}
72
+ * @readonly
73
+ */
74
+ $refs = new $Refs<JSONSchema>();
75
+ public options = getJsonSchemaRefParserDefaultOptions()
76
+ /**
77
+ * The parsed (and possibly dereferenced) JSON schema object
78
+ *
79
+ * @type {object}
80
+ * @readonly
81
+ */
82
+ public schema: JSONSchema | null = null;
83
+
84
+ /**
85
+ * Bundles all referenced files/URLs into a single schema that only has internal `$ref` pointers. This lets you split-up your schema however you want while you're building it, but easily combine all those files together when it's time to package or distribute the schema to other people. The resulting schema size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.
86
+ *
87
+ * This also eliminates the risk of circular references, so the schema can be safely serialized using `JSON.stringify()`.
88
+ *
89
+ * See https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#bundleschema-options-callback
90
+ *
91
+ * @param pathOrUrlOrSchema A JSON Schema object, or the file path or URL of a JSON Schema file.
92
+ */
93
+ public async bundle({
94
+ arrayBuffer,
95
+ pathOrUrlOrSchema,
96
+ resolvedInput,
97
+ }: {
98
+ arrayBuffer?: ArrayBuffer;
99
+ pathOrUrlOrSchema: JSONSchema | string | unknown;
100
+ resolvedInput?: ResolvedInput;
101
+ }): Promise<JSONSchema> {
102
+ await this.parse({ arrayBuffer, pathOrUrlOrSchema, resolvedInput });
103
+ await resolveExternal(this, this.options);
104
+ const errors = JSONParserErrorGroup.getParserErrors(this);
105
+ if (errors.length > 0) {
106
+ throw new JSONParserErrorGroup(this);
107
+ }
108
+ _bundle(this, this.options);
109
+ const errors2 = JSONParserErrorGroup.getParserErrors(this);
110
+ if (errors2.length > 0) {
111
+ throw new JSONParserErrorGroup(this);
112
+ }
113
+ return this.schema!;
114
+ }
115
+
116
+ /**
117
+ * Dereferences all `$ref` pointers in the JSON Schema, replacing each reference with its resolved value. This results in a schema object that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.
118
+ *
119
+ * The dereference method maintains object reference equality, meaning that all `$ref` pointers that point to the same object will be replaced with references to the same object. Again, this is great for programmatic usage, but it does introduce the risk of circular references, so be careful if you intend to serialize the schema using `JSON.stringify()`. Consider using the bundle method instead, which does not create circular references.
120
+ *
121
+ * See https://apitools.dev/json-schema-ref-parser/docs/ref-parser.html#dereferenceschema-options-callback
122
+ *
123
+ * @param pathOrUrlOrSchema A JSON Schema object, or the file path or URL of a JSON Schema file.
124
+ */
125
+ public async dereference({
126
+ pathOrUrlOrSchema,
127
+ }: {
128
+ pathOrUrlOrSchema: JSONSchema | string | unknown;
129
+ }): Promise<JSONSchema> {
130
+ await this.parse({ pathOrUrlOrSchema });
131
+ await resolveExternal(this, this.options);
132
+ const errors = JSONParserErrorGroup.getParserErrors(this);
133
+ if (errors.length > 0) {
134
+ throw new JSONParserErrorGroup(this);
135
+ }
136
+ _dereference(this, this.options);
137
+ const errors2 = JSONParserErrorGroup.getParserErrors(this);
138
+ if (errors2.length > 0) {
139
+ throw new JSONParserErrorGroup(this);
140
+ }
141
+ return this.schema!;
142
+ }
143
+
144
+ /**
145
+ * Parses the given JSON schema.
146
+ * This method does not resolve any JSON references.
147
+ * It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
148
+ *
149
+ * @param pathOrUrlOrSchema A JSON Schema object, or the file path or URL of a JSON Schema file.
150
+ * @returns - The returned promise resolves with the parsed JSON schema object.
151
+ */
152
+ public async parse({
153
+ arrayBuffer,
154
+ pathOrUrlOrSchema,
155
+ resolvedInput: _resolvedInput,
156
+ }: {
157
+ arrayBuffer?: ArrayBuffer;
158
+ pathOrUrlOrSchema: JSONSchema | string | unknown;
159
+ resolvedInput?: ResolvedInput;
160
+ }): Promise<{ schema: JSONSchema }> {
161
+ const resolvedInput = _resolvedInput || getResolvedInput({ pathOrUrlOrSchema });
162
+ const { path, type } = resolvedInput;
163
+ let { schema } = resolvedInput;
164
+
165
+ // reset everything
166
+ this.schema = null;
167
+ this.$refs = new $Refs();
168
+
169
+ if (schema) {
170
+ // immediately add a new $Ref with the schema object as value
171
+ const $ref = this.$refs._add(path);
172
+ $ref.pathType = url.isFileSystemPath(path) ? 'file' : 'http';
173
+ $ref.value = schema;
174
+ } else if (type !== 'json') {
175
+ const file = newFile(path)
176
+
177
+ // Add a new $Ref for this file, even though we don't have the value yet.
178
+ // This ensures that we don't simultaneously read & parse the same file multiple times
179
+ const $refAdded = this.$refs._add(file.url);
180
+ $refAdded.pathType = type;
181
+ try {
182
+ const resolver = type === 'file' ? fileResolver : urlResolver;
183
+ await resolver.handler(file, arrayBuffer);
184
+ const parseResult = await parseFile(file, this.options);
185
+ $refAdded.value = parseResult.result;
186
+ schema = parseResult.result;
187
+ } catch (err) {
188
+ if (isHandledError(err)) {
189
+ $refAdded.value = err;
190
+ }
191
+
192
+ throw err;
193
+ }
194
+ }
195
+
196
+ if (schema === null || typeof schema !== 'object' || Buffer.isBuffer(schema)) {
197
+ throw ono.syntax(`"${this.$refs._root$Ref.path || schema}" is not a valid JSON Schema`);
198
+ }
199
+
200
+ this.schema = schema;
201
+
202
+ return {
203
+ schema,
204
+ };
205
+ }
206
+ }
207
+
208
+ export { sendRequest } from './resolvers/url.js'
209
+ export type { JSONSchema } from "./types/index.js";
package/lib/options.ts ADDED
@@ -0,0 +1,108 @@
1
+ import { jsonParser } from "./parsers/json.js";
2
+ import { yamlParser } from "./parsers/yaml.js";
3
+ import { textParser } from "./parsers/text.js";
4
+ import { binaryParser } from "./parsers/binary.js";
5
+
6
+ import type { JSONSchemaObject, Plugin } from "./types/index.js";
7
+
8
+ export interface DereferenceOptions {
9
+ /**
10
+ * Determines whether circular `$ref` pointers are handled.
11
+ *
12
+ * If set to `false`, then a `ReferenceError` will be thrown if the schema contains any circular references.
13
+ *
14
+ * If set to `"ignore"`, then circular references will simply be ignored. No error will be thrown, but the `$Refs.circular` property will still be set to `true`.
15
+ */
16
+ circular?: boolean | "ignore";
17
+ /**
18
+ * A function, called for each path, which can return true to stop this path and all
19
+ * subpaths from being dereferenced further. This is useful in schemas where some
20
+ * subpaths contain literal $ref keys that should not be dereferenced.
21
+ */
22
+ excludedPathMatcher?(path: string): boolean;
23
+ /**
24
+ * Callback invoked during dereferencing.
25
+ *
26
+ * @argument {string} path - The path being dereferenced (ie. the `$ref` string)
27
+ * @argument {JSONSchemaObject} value - The JSON-Schema that the `$ref` resolved to
28
+ * @argument {JSONSchemaObject} parent - The parent of the dereferenced object
29
+ * @argument {string} parentPropName - The prop name of the parent object whose value was dereferenced
30
+ */
31
+ onDereference?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
32
+ }
33
+
34
+ /**
35
+ * Options that determine how JSON schemas are parsed, resolved, and dereferenced.
36
+ *
37
+ * @param [options] - Overridden options
38
+ * @class
39
+ */
40
+ export interface $RefParserOptions {
41
+ /**
42
+ * The `dereference` options control how JSON Schema `$Ref` Parser will dereference `$ref` pointers within the JSON schema.
43
+ */
44
+ dereference: DereferenceOptions;
45
+ /**
46
+ * The `parse` options determine how different types of files will be parsed.
47
+ *
48
+ * JSON Schema `$Ref` Parser comes with built-in JSON, YAML, plain-text, and binary parsers, any of which you can configure or disable. You can also add your own custom parsers if you want.
49
+ */
50
+ parse: {
51
+ binary: Plugin;
52
+ json: Plugin;
53
+ text: Plugin;
54
+ yaml: Plugin;
55
+ };
56
+ /**
57
+ * The maximum amount of time (in milliseconds) that JSON Schema $Ref Parser will spend dereferencing a single schema.
58
+ * It will throw a timeout error if the operation takes longer than this.
59
+ */
60
+ timeoutMs?: number;
61
+ }
62
+
63
+ export const getJsonSchemaRefParserDefaultOptions = (): $RefParserOptions => ({
64
+ /**
65
+ * Determines the types of JSON references that are allowed.
66
+ */
67
+ dereference: {
68
+ /**
69
+ * Dereference circular (recursive) JSON references?
70
+ * If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
71
+ * If "ignore", then circular references will not be dereferenced.
72
+ *
73
+ * @type {boolean|string}
74
+ */
75
+ circular: true,
76
+ /**
77
+ * A function, called for each path, which can return true to stop this path and all
78
+ * subpaths from being dereferenced further. This is useful in schemas where some
79
+ * subpaths contain literal $ref keys that should not be dereferenced.
80
+ *
81
+ * @type {function}
82
+ */
83
+ excludedPathMatcher: () => false,
84
+ // @ts-expect-error
85
+ referenceResolution: "relative",
86
+ },
87
+ /**
88
+ * Determines how different types of files will be parsed.
89
+ *
90
+ * You can add additional parsers of your own, replace an existing one with
91
+ * your own implementation, or disable any parser by setting it to false.
92
+ */
93
+ parse: {
94
+ binary: { ...binaryParser },
95
+ json: { ...jsonParser },
96
+ text: { ...textParser },
97
+ yaml: { ...yamlParser },
98
+ },
99
+ });
100
+
101
+ export type Options = $RefParserOptions;
102
+
103
+ type DeepPartial<T> = T extends object
104
+ ? {
105
+ [P in keyof T]?: DeepPartial<T[P]>;
106
+ }
107
+ : T;
108
+ export type ParserOptions = DeepPartial<$RefParserOptions>;
package/lib/parse.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { ono } from "@jsdevtools/ono";
2
+ import { getExtension } from "./util/url.js";
3
+ import * as plugins from "./util/plugins.js";
4
+ import type { PluginResult } from "./util/plugins.js";
5
+ import { ParserError } from "./util/errors.js";
6
+ import type { $RefParserOptions } from "./options.js";
7
+ import type { FileInfo } from "./types/index.js";
8
+
9
+ /**
10
+ * Prepares the file object so we can populate it with data and other values
11
+ * when it's read and parsed. This "file object" will be passed to all
12
+ * resolvers and parsers.
13
+ */
14
+ export function newFile(path: string): FileInfo {
15
+ let url = path;
16
+ // Remove the URL fragment, if any
17
+ const hashIndex = url.indexOf("#");
18
+ let hash = "";
19
+ if (hashIndex > -1) {
20
+ hash = url.substring(hashIndex);
21
+ url = url.substring(0, hashIndex);
22
+ }
23
+ return {
24
+ extension: getExtension(url),
25
+ hash,
26
+ url,
27
+ } as FileInfo;
28
+ }
29
+
30
+ /**
31
+ * Parses the given file's contents, using the configured parser plugins.
32
+ */
33
+ export const parseFile = async (file: FileInfo, options: $RefParserOptions): Promise<PluginResult> => {
34
+ try {
35
+ // If none of the parsers are a match for this file, try all of them. This
36
+ // handles situations where the file is a supported type, just with an
37
+ // unknown extension.
38
+ const parsers = [options.parse.json, options.parse.yaml, options.parse.text, options.parse.binary];
39
+ const filtered = parsers.filter((plugin) => plugin.canHandle(file));
40
+ return await plugins.run(filtered.length ? filtered : parsers, file);
41
+ } catch (error: any) {
42
+ if (error && error.message && error.message.startsWith("Error parsing")) {
43
+ throw error;
44
+ }
45
+
46
+ if (!error || !("error" in error)) {
47
+ throw ono.syntax(`Unable to parse ${file.url}`);
48
+ }
49
+
50
+ if (error.error instanceof ParserError) {
51
+ throw error.error;
52
+ }
53
+
54
+ throw new ParserError(error.error.message, file.url);
55
+ }
56
+ }
@@ -0,0 +1,13 @@
1
+ import type { FileInfo } from "../types/index.js";
2
+ import type { Plugin } from "../types/index.js";
3
+
4
+ const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
5
+
6
+ export const binaryParser: Plugin = {
7
+ canHandle: (file: FileInfo) => Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url),
8
+ handler: (file: FileInfo): Buffer<ArrayBufferLike> => Buffer.isBuffer(file.data)
9
+ ? file.data
10
+ // This will reject if data is anything other than a string or typed array
11
+ : Buffer.from(file.data),
12
+ name: 'binary',
13
+ };
@@ -0,0 +1,39 @@
1
+ import { ParserError } from "../util/errors.js";
2
+ import type { FileInfo } from "../types/index.js";
3
+ import type { Plugin } from "../types/index.js";
4
+
5
+ export const jsonParser: Plugin = {
6
+ canHandle: (file: FileInfo) => file.extension === '.json',
7
+ async handler(file: FileInfo): Promise<object | undefined> {
8
+ let data = file.data;
9
+ if (Buffer.isBuffer(data)) {
10
+ data = data.toString();
11
+ }
12
+
13
+ if (typeof data !== "string") {
14
+ // data is already a JavaScript value (object, array, number, null, NaN, etc.)
15
+ return data as object;
16
+ }
17
+
18
+ if (!data.trim().length) {
19
+ // this mirrors the YAML behavior
20
+ return;
21
+ }
22
+
23
+ try {
24
+ return JSON.parse(data);
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ } catch (error: any) {
27
+ try {
28
+ // find the first curly brace
29
+ const firstCurlyBrace = data.indexOf("{");
30
+ // remove any characters before the first curly brace
31
+ data = data.slice(firstCurlyBrace);
32
+ return JSON.parse(data);
33
+ } catch (error: any) {
34
+ throw new ParserError(error.message, file.url);
35
+ }
36
+ }
37
+ },
38
+ name: 'json',
39
+ };
@@ -0,0 +1,21 @@
1
+ import type { FileInfo } from "../types/index.js";
2
+ import { ParserError } from "../util/errors.js";
3
+ import type { Plugin } from "../types/index.js";
4
+
5
+ const TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
6
+
7
+ export const textParser: Plugin = {
8
+ canHandle: (file: FileInfo) => (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url),
9
+ handler(file: FileInfo): string {
10
+ if (typeof file.data === "string") {
11
+ return file.data;
12
+ }
13
+
14
+ if (!Buffer.isBuffer(file.data)) {
15
+ throw new ParserError("data is not text", file.url);
16
+ }
17
+
18
+ return file.data.toString('utf-8');
19
+ },
20
+ name: 'text',
21
+ };
@@ -0,0 +1,26 @@
1
+ import { ParserError } from "../util/errors.js";
2
+ import yaml from "js-yaml";
3
+ import { JSON_SCHEMA } from "js-yaml";
4
+ import type { FileInfo, JSONSchema } from "../types/index.js";
5
+ import type { Plugin } from "../types/index.js";
6
+
7
+ export const yamlParser: Plugin = {
8
+ // JSON is valid YAML
9
+ canHandle: (file: FileInfo) => [".yaml", ".yml", ".json"].includes(file.extension),
10
+ handler: async (file: FileInfo): Promise<JSONSchema> => {
11
+ const data = Buffer.isBuffer(file.data) ? file.data.toString() : file.data;
12
+
13
+ if (typeof data !== "string") {
14
+ // data is already a JavaScript value (object, array, number, null, NaN, etc.)
15
+ return data;
16
+ }
17
+
18
+ try {
19
+ const yamlSchema = yaml.load(data, { schema: JSON_SCHEMA }) as JSONSchema
20
+ return yamlSchema;
21
+ } catch (error: any) {
22
+ throw new ParserError(error?.message || "Parser Error", file.url);
23
+ }
24
+ },
25
+ name: 'yaml',
26
+ };