@scalar/openapi-parser 0.23.3 → 0.23.5

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 (57) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/configuration/index.d.ts +0 -1
  3. package/dist/configuration/index.d.ts.map +1 -1
  4. package/dist/configuration/index.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +2 -2
  8. package/dist/types/index.d.ts +3 -5
  9. package/dist/types/index.d.ts.map +1 -1
  10. package/dist/utils/betterAjvErrors/helpers.d.ts +2 -6
  11. package/dist/utils/betterAjvErrors/helpers.d.ts.map +1 -1
  12. package/dist/utils/betterAjvErrors/helpers.js +1 -4
  13. package/dist/utils/betterAjvErrors/helpers.js.map +2 -2
  14. package/dist/utils/betterAjvErrors/index.d.ts +1 -1
  15. package/dist/utils/betterAjvErrors/index.d.ts.map +1 -1
  16. package/dist/utils/join/index.d.ts +1 -1
  17. package/dist/utils/join/index.d.ts.map +1 -1
  18. package/dist/utils/join/index.js.map +1 -1
  19. package/dist/utils/join/join.d.ts +2 -2
  20. package/dist/utils/join/join.d.ts.map +1 -1
  21. package/dist/utils/join/join.js +1 -1
  22. package/dist/utils/join/join.js.map +2 -2
  23. package/dist/utils/load/index.d.ts +2 -1
  24. package/dist/utils/load/index.d.ts.map +1 -1
  25. package/dist/utils/load/index.js.map +2 -2
  26. package/dist/utils/openapi/openapi.d.ts +720 -180
  27. package/dist/utils/openapi/openapi.d.ts.map +1 -1
  28. package/dist/utils/resolve-references.d.ts +2 -1
  29. package/dist/utils/resolve-references.d.ts.map +1 -1
  30. package/dist/utils/resolve-references.js.map +1 -1
  31. package/dist/utils/transform/sanitize.d.ts +2 -1
  32. package/dist/utils/transform/sanitize.d.ts.map +1 -1
  33. package/dist/utils/transform/sanitize.js +1 -2
  34. package/dist/utils/transform/sanitize.js.map +2 -2
  35. package/dist/utils/transform/utils/addInfoObject.d.ts +0 -1
  36. package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
  37. package/dist/utils/transform/utils/addInfoObject.js +0 -1
  38. package/dist/utils/transform/utils/addInfoObject.js.map +2 -2
  39. package/dist/utils/transform-errors.d.ts +1 -1
  40. package/dist/utils/transform-errors.d.ts.map +1 -1
  41. package/package.json +6 -10
  42. package/dist/lib/Validator/index.d.ts +0 -2
  43. package/dist/lib/Validator/index.d.ts.map +0 -1
  44. package/dist/lib/Validator/index.js +0 -5
  45. package/dist/lib/Validator/index.js.map +0 -7
  46. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts +0 -2
  47. package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts.map +0 -1
  48. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js +0 -27
  49. package/dist/utils/betterAjvErrors/json/get-meta-from-path.js.map +0 -7
  50. package/dist/utils/betterAjvErrors/json/index.d.ts +0 -2
  51. package/dist/utils/betterAjvErrors/json/index.d.ts.map +0 -1
  52. package/dist/utils/betterAjvErrors/json/index.js +0 -5
  53. package/dist/utils/betterAjvErrors/json/index.js.map +0 -7
  54. package/dist/utils/betterAjvErrors/json/utils.d.ts +0 -2
  55. package/dist/utils/betterAjvErrors/json/utils.d.ts.map +0 -1
  56. package/dist/utils/betterAjvErrors/json/utils.js +0 -11
  57. package/dist/utils/betterAjvErrors/json/utils.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/utils/openapi/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAS,MAAM,eAAe,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,aAAa,CAAC,EAAE,cAAc;kBASpC,sBAAsB,YAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE9D"}
@@ -1,6 +1,6 @@
1
1
  import type { OpenAPI } from '@scalar/openapi-types';
2
2
  import type { AnyObject, ErrorObject, Filesystem, FilesystemEntry, ThrowOnErrorOption } from '../types/index.js';
3
- export type ResolveReferencesResult = {
3
+ type ResolveReferencesResult = {
4
4
  valid: boolean;
5
5
  errors: ErrorObject[];
6
6
  schema: OpenAPI.Document;
@@ -20,4 +20,5 @@ export type ResolveReferencesOptions = ThrowOnErrorOption & {
20
20
  * Takes a specification and resolves all references.
21
21
  */
22
22
  export declare function resolveReferences(input: AnyObject | Filesystem, options?: ResolveReferencesOptions, file?: FilesystemEntry, errors?: ErrorObject[]): ResolveReferencesResult;
23
+ export {};
23
24
  //# sourceMappingURL=resolve-references.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-references.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAiB5G,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACnE,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAE/B,KAAK,EAAE,SAAS,GAAG,UAAU,EAE7B,OAAO,CAAC,EAAE,wBAAwB,EAElC,IAAI,CAAC,EAAE,eAAe,EAEtB,MAAM,GAAE,WAAW,EAAO,GACzB,uBAAuB,CAuCzB"}
1
+ {"version":3,"file":"resolve-references.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAiB5G,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAC1D;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACnE,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAE/B,KAAK,EAAE,SAAS,GAAG,UAAU,EAE7B,OAAO,CAAC,EAAE,wBAAwB,EAElC,IAAI,CAAC,EAAE,eAAe,EAEtB,MAAM,GAAE,WAAW,EAAO,GACzB,uBAAuB,CAuCzB"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/resolve-references.ts"],
4
- "sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\n\nimport { ERRORS } from '@/configuration'\nimport type { AnyObject, ErrorObject, Filesystem, FilesystemEntry, ThrowOnErrorOption } from '@/types/index'\n\nimport { getEntrypoint } from './get-entrypoint'\nimport { getSegmentsFromPath } from './get-segments-from-path'\nimport { isObject } from './is-object'\nimport { makeFilesystem } from './make-filesystem'\n\n// TODO: Add support for all pointer words\n// export const pointerWords = new Set([\n// '$ref',\n// '$id',\n// '$anchor',\n// '$dynamicRef',\n// '$dynamicAnchor',\n// '$schema',\n// ])\n\nexport type ResolveReferencesResult = {\n valid: boolean\n errors: ErrorObject[]\n schema: OpenAPI.Document\n}\n\nexport type ResolveReferencesOptions = ThrowOnErrorOption & {\n /**\n * Fired when dereferenced a schema.\n *\n * Note that for object schemas, its properties may not be dereferenced when the hook is called.\n */\n onDereference?: (data: { schema: AnyObject; ref: string }) => void\n}\n\n/**\n * Takes a specification and resolves all references.\n */\nexport function resolveReferences(\n // Just a specification, or a set of files.\n input: AnyObject | Filesystem,\n // Additional options to control the behaviour\n options?: ResolveReferencesOptions,\n // Fallback to the entrypoint\n file?: FilesystemEntry,\n // Errors that occurred during the process\n errors: ErrorObject[] = [],\n): ResolveReferencesResult {\n // Detach from input\n const clonedInput = structuredClone(input)\n\n // Make it a filesystem, even if it's just one file\n const filesystem = makeFilesystem(clonedInput)\n\n // Get the main file\n const entrypoint = getEntrypoint(filesystem)\n\n const finalInput = file?.specification ?? entrypoint.specification\n\n // Does it look like an OpenAPI document?\n if (!isObject(finalInput)) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.NO_CONTENT)\n }\n\n return {\n valid: false,\n errors,\n schema: finalInput as OpenAPI.Document,\n }\n }\n\n // Recursively resolve all references\n dereference(finalInput, filesystem, file ?? entrypoint, new WeakSet(), errors, options)\n\n // Remove duplicates (according to message) from errors\n errors = errors.filter(\n (error, index, self) => index === self.findIndex((t) => t.message === error.message && t.code === error.code),\n )\n\n // Return the resolved specification\n return {\n valid: errors.length === 0,\n errors,\n schema: finalInput as OpenAPI.Document,\n }\n}\n\n/**\n * Resolves the circular reference to an object and deletes the $ref properties (in-place).\n */\nfunction dereference(\n schema: AnyObject,\n filesystem: Filesystem,\n entrypoint: FilesystemEntry,\n // references to resolved object\n resolvedSchemas: WeakSet<object>,\n // error output\n errors: ErrorObject[],\n\n options?: ResolveReferencesOptions,\n): void {\n if (schema === null || resolvedSchemas.has(schema)) {\n return\n }\n resolvedSchemas.add(schema)\n\n function resolveExternal(externalFile: FilesystemEntry) {\n dereference(externalFile.specification, filesystem, externalFile, resolvedSchemas, errors, options)\n\n return externalFile\n }\n\n while (schema.$ref !== undefined) {\n // Find the referenced content\n const resolved = resolveUri(schema.$ref, options, entrypoint, filesystem, resolveExternal, errors)\n\n // invalid\n if (typeof resolved !== 'object' || resolved === null) {\n break\n }\n const dereferencedRef = schema.$ref\n\n // Get rid of the reference\n delete schema.$ref\n\n for (const key of Object.keys(resolved)) {\n if (schema[key] === undefined) {\n schema[key] = resolved[key]\n }\n }\n\n if (dereferencedRef) {\n options?.onDereference?.({ schema, ref: dereferencedRef })\n }\n }\n\n // Iterate over the whole object\n for (const value of Object.values(schema)) {\n if (typeof value === 'object' && value !== null) {\n dereference(value, filesystem, entrypoint, resolvedSchemas, errors, options)\n }\n }\n}\n\n/**\n * Resolves a URI to a part of the specification\n *\n * The output is not necessarily dereferenced\n */\nfunction resolveUri(\n // 'foobar.json#/foo/bar'\n uri: string,\n options: ResolveReferencesOptions,\n // { filename: './foobar.json '}\n file: FilesystemEntry,\n // [ { filename: './foobar.json '} ]\n filesystem: Filesystem,\n\n // a function to resolve references in external file\n resolve: (file: FilesystemEntry) => FilesystemEntry,\n\n errors: ErrorObject[],\n): AnyObject | undefined {\n // Ignore invalid URIs\n if (typeof uri !== 'string') {\n if (options?.throwOnError) {\n throw new Error(ERRORS.INVALID_REFERENCE.replace('%s', uri))\n }\n\n errors.push({\n code: 'INVALID_REFERENCE',\n message: ERRORS.INVALID_REFERENCE.replace('%s', uri),\n })\n\n return undefined\n }\n\n // Understand the URI\n const [prefix, path] = uri.split('#', 2)\n\n /** Check whether the file is pointing to itself */\n const isDifferentFile = prefix !== file.filename\n\n // External references\n if (prefix && isDifferentFile) {\n const externalReference = filesystem.find((entry) => {\n return entry.filename === prefix\n })\n\n if (!externalReference) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', prefix))\n }\n\n errors.push({\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', prefix),\n })\n\n return undefined\n }\n // $ref: 'other-file.yaml'\n if (path === undefined) {\n return externalReference.specification\n }\n\n // $ref: 'other-file.yaml#/foo/bar'\n // resolve refs first before accessing properties directly\n return resolveUri(`#${path}`, options, resolve(externalReference), filesystem, resolve, errors)\n }\n\n // Pointers\n const segments = getSegmentsFromPath(path)\n\n // Try to find the URI\n try {\n return segments.reduce((acc, key) => {\n return acc[key]\n }, file.specification)\n } catch (_error) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.INVALID_REFERENCE.replace('%s', uri))\n }\n\n errors.push({\n code: 'INVALID_REFERENCE',\n message: ERRORS.INVALID_REFERENCE.replace('%s', uri),\n })\n }\n\n return undefined\n}\n"],
4
+ "sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\n\nimport { ERRORS } from '@/configuration'\nimport type { AnyObject, ErrorObject, Filesystem, FilesystemEntry, ThrowOnErrorOption } from '@/types/index'\n\nimport { getEntrypoint } from './get-entrypoint'\nimport { getSegmentsFromPath } from './get-segments-from-path'\nimport { isObject } from './is-object'\nimport { makeFilesystem } from './make-filesystem'\n\n// TODO: Add support for all pointer words\n// export const pointerWords = new Set([\n// '$ref',\n// '$id',\n// '$anchor',\n// '$dynamicRef',\n// '$dynamicAnchor',\n// '$schema',\n// ])\n\ntype ResolveReferencesResult = {\n valid: boolean\n errors: ErrorObject[]\n schema: OpenAPI.Document\n}\n\nexport type ResolveReferencesOptions = ThrowOnErrorOption & {\n /**\n * Fired when dereferenced a schema.\n *\n * Note that for object schemas, its properties may not be dereferenced when the hook is called.\n */\n onDereference?: (data: { schema: AnyObject; ref: string }) => void\n}\n\n/**\n * Takes a specification and resolves all references.\n */\nexport function resolveReferences(\n // Just a specification, or a set of files.\n input: AnyObject | Filesystem,\n // Additional options to control the behaviour\n options?: ResolveReferencesOptions,\n // Fallback to the entrypoint\n file?: FilesystemEntry,\n // Errors that occurred during the process\n errors: ErrorObject[] = [],\n): ResolveReferencesResult {\n // Detach from input\n const clonedInput = structuredClone(input)\n\n // Make it a filesystem, even if it's just one file\n const filesystem = makeFilesystem(clonedInput)\n\n // Get the main file\n const entrypoint = getEntrypoint(filesystem)\n\n const finalInput = file?.specification ?? entrypoint.specification\n\n // Does it look like an OpenAPI document?\n if (!isObject(finalInput)) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.NO_CONTENT)\n }\n\n return {\n valid: false,\n errors,\n schema: finalInput as OpenAPI.Document,\n }\n }\n\n // Recursively resolve all references\n dereference(finalInput, filesystem, file ?? entrypoint, new WeakSet(), errors, options)\n\n // Remove duplicates (according to message) from errors\n errors = errors.filter(\n (error, index, self) => index === self.findIndex((t) => t.message === error.message && t.code === error.code),\n )\n\n // Return the resolved specification\n return {\n valid: errors.length === 0,\n errors,\n schema: finalInput as OpenAPI.Document,\n }\n}\n\n/**\n * Resolves the circular reference to an object and deletes the $ref properties (in-place).\n */\nfunction dereference(\n schema: AnyObject,\n filesystem: Filesystem,\n entrypoint: FilesystemEntry,\n // references to resolved object\n resolvedSchemas: WeakSet<object>,\n // error output\n errors: ErrorObject[],\n\n options?: ResolveReferencesOptions,\n): void {\n if (schema === null || resolvedSchemas.has(schema)) {\n return\n }\n resolvedSchemas.add(schema)\n\n function resolveExternal(externalFile: FilesystemEntry) {\n dereference(externalFile.specification, filesystem, externalFile, resolvedSchemas, errors, options)\n\n return externalFile\n }\n\n while (schema.$ref !== undefined) {\n // Find the referenced content\n const resolved = resolveUri(schema.$ref, options, entrypoint, filesystem, resolveExternal, errors)\n\n // invalid\n if (typeof resolved !== 'object' || resolved === null) {\n break\n }\n const dereferencedRef = schema.$ref\n\n // Get rid of the reference\n delete schema.$ref\n\n for (const key of Object.keys(resolved)) {\n if (schema[key] === undefined) {\n schema[key] = resolved[key]\n }\n }\n\n if (dereferencedRef) {\n options?.onDereference?.({ schema, ref: dereferencedRef })\n }\n }\n\n // Iterate over the whole object\n for (const value of Object.values(schema)) {\n if (typeof value === 'object' && value !== null) {\n dereference(value, filesystem, entrypoint, resolvedSchemas, errors, options)\n }\n }\n}\n\n/**\n * Resolves a URI to a part of the specification\n *\n * The output is not necessarily dereferenced\n */\nfunction resolveUri(\n // 'foobar.json#/foo/bar'\n uri: string,\n options: ResolveReferencesOptions,\n // { filename: './foobar.json '}\n file: FilesystemEntry,\n // [ { filename: './foobar.json '} ]\n filesystem: Filesystem,\n\n // a function to resolve references in external file\n resolve: (file: FilesystemEntry) => FilesystemEntry,\n\n errors: ErrorObject[],\n): AnyObject | undefined {\n // Ignore invalid URIs\n if (typeof uri !== 'string') {\n if (options?.throwOnError) {\n throw new Error(ERRORS.INVALID_REFERENCE.replace('%s', uri))\n }\n\n errors.push({\n code: 'INVALID_REFERENCE',\n message: ERRORS.INVALID_REFERENCE.replace('%s', uri),\n })\n\n return undefined\n }\n\n // Understand the URI\n const [prefix, path] = uri.split('#', 2)\n\n /** Check whether the file is pointing to itself */\n const isDifferentFile = prefix !== file.filename\n\n // External references\n if (prefix && isDifferentFile) {\n const externalReference = filesystem.find((entry) => {\n return entry.filename === prefix\n })\n\n if (!externalReference) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', prefix))\n }\n\n errors.push({\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', prefix),\n })\n\n return undefined\n }\n // $ref: 'other-file.yaml'\n if (path === undefined) {\n return externalReference.specification\n }\n\n // $ref: 'other-file.yaml#/foo/bar'\n // resolve refs first before accessing properties directly\n return resolveUri(`#${path}`, options, resolve(externalReference), filesystem, resolve, errors)\n }\n\n // Pointers\n const segments = getSegmentsFromPath(path)\n\n // Try to find the URI\n try {\n return segments.reduce((acc, key) => {\n return acc[key]\n }, file.specification)\n } catch (_error) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.INVALID_REFERENCE.replace('%s', uri))\n }\n\n errors.push({\n code: 'INVALID_REFERENCE',\n message: ERRORS.INVALID_REFERENCE.replace('%s', uri),\n })\n }\n\n return undefined\n}\n"],
5
5
  "mappings": "AAEA,SAAS,cAAc;AAGvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AA8BxB,SAAS,kBAEd,OAEA,SAEA,MAEA,SAAwB,CAAC,GACA;AAEzB,QAAM,cAAc,gBAAgB,KAAK;AAGzC,QAAM,aAAa,eAAe,WAAW;AAG7C,QAAM,aAAa,cAAc,UAAU;AAE3C,QAAM,aAAa,MAAM,iBAAiB,WAAW;AAGrD,MAAI,CAAC,SAAS,UAAU,GAAG;AACzB,QAAI,SAAS,cAAc;AACzB,YAAM,IAAI,MAAM,OAAO,UAAU;AAAA,IACnC;AAEA,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,QAAQ;AAAA,IACV;AAAA,EACF;AAGA,cAAY,YAAY,YAAY,QAAQ,YAAY,oBAAI,QAAQ,GAAG,QAAQ,OAAO;AAGtF,WAAS,OAAO;AAAA,IACd,CAAC,OAAO,OAAO,SAAS,UAAU,KAAK,UAAU,CAAC,MAAM,EAAE,YAAY,MAAM,WAAW,EAAE,SAAS,MAAM,IAAI;AAAA,EAC9G;AAGA,SAAO;AAAA,IACL,OAAO,OAAO,WAAW;AAAA,IACzB;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAKA,SAAS,YACP,QACA,YACA,YAEA,iBAEA,QAEA,SACM;AACN,MAAI,WAAW,QAAQ,gBAAgB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oBAAoB,WAAW,KAAK,CAAC,UAAU;AACnD,aAAO,MAAM,aAAa;AAAA,IAC5B,CAAC;AAED,QAAI,CAAC,mBAAmB;AACtB,UAAI,SAAS,cAAc;AACzB,cAAM,IAAI,MAAM,OAAO,6BAA6B,QAAQ,MAAM,MAAM,CAAC;AAAA,MAC3E;AAEA,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,SAAS,OAAO,6BAA6B,QAAQ,MAAM,MAAM;AAAA,MACnE,CAAC;AAED,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,QAAW;AACtB,aAAO,kBAAkB;AAAA,IAC3B;AAIA,WAAO,WAAW,IAAI,IAAI,IAAI,SAAS,QAAQ,iBAAiB,GAAG,YAAY,SAAS,MAAM;AAAA,EAChG;AAGA,QAAM,WAAW,oBAAoB,IAAI;AAGzC,MAAI;AACF,WAAO,SAAS,OAAO,CAAC,KAAK,QAAQ;AACnC,aAAO,IAAI,GAAG;AAAA,IAChB,GAAG,KAAK,aAAa;AAAA,EACvB,SAAS,QAAQ;AACf,QAAI,SAAS,cAAc;AACzB,YAAM,IAAI,MAAM,OAAO,kBAAkB,QAAQ,MAAM,GAAG,CAAC;AAAA,IAC7D;AAEA,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,SAAS,OAAO,kBAAkB,QAAQ,MAAM,GAAG;AAAA,IACrD,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
+ /** biome-ignore-all lint/performance/noBarrelFile: re-exports utilities */
1
2
  import type { OpenAPI } from '@scalar/openapi-types';
2
3
  import type { AnyObject } from '../../types/index.js';
4
+ export { DEFAULT_TITLE } from './utils/addInfoObject.js';
3
5
  export { DEFAULT_OPENAPI_VERSION } from './utils/addLatestOpenApiVersion.js';
4
- export { DEFAULT_TITLE, DEFAULT_VERSION } from './utils/addInfoObject.js';
5
6
  /**
6
7
  * Make an OpenAPI document a valid and clean OpenAPI document
7
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/utils/transform/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAO9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEtE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAUhE"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/utils/transform/sanitize.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAQ9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAUhE"}
@@ -3,8 +3,8 @@ import { addLatestOpenApiVersion } from "./utils/addLatestOpenApiVersion.js";
3
3
  import { addMissingTags } from "./utils/addMissingTags.js";
4
4
  import { normalizeSecuritySchemes } from "./utils/normalizeSecuritySchemes.js";
5
5
  import { rejectSwaggerDocuments } from "./utils/rejectSwaggerDocuments.js";
6
+ import { DEFAULT_TITLE } from "./utils/addInfoObject.js";
6
7
  import { DEFAULT_OPENAPI_VERSION } from "./utils/addLatestOpenApiVersion.js";
7
- import { DEFAULT_TITLE, DEFAULT_VERSION } from "./utils/addInfoObject.js";
8
8
  function sanitize(definition) {
9
9
  const transformers = [
10
10
  rejectSwaggerDocuments,
@@ -18,7 +18,6 @@ function sanitize(definition) {
18
18
  export {
19
19
  DEFAULT_OPENAPI_VERSION,
20
20
  DEFAULT_TITLE,
21
- DEFAULT_VERSION,
22
21
  sanitize
23
22
  };
24
23
  //# sourceMappingURL=sanitize.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/transform/sanitize.ts"],
4
- "sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\n\nimport type { AnyObject } from '@/types/index'\nimport { addInfoObject } from './utils/addInfoObject'\nimport { addLatestOpenApiVersion } from './utils/addLatestOpenApiVersion'\nimport { addMissingTags } from './utils/addMissingTags'\nimport { normalizeSecuritySchemes } from './utils/normalizeSecuritySchemes'\nimport { rejectSwaggerDocuments } from './utils/rejectSwaggerDocuments'\n\nexport { DEFAULT_OPENAPI_VERSION } from './utils/addLatestOpenApiVersion'\nexport { DEFAULT_TITLE, DEFAULT_VERSION } from './utils/addInfoObject'\n\n/**\n * Make an OpenAPI document a valid and clean OpenAPI document\n *\n * @deprecated We're about to drop this from the package.\n */\nexport function sanitize(definition: AnyObject): OpenAPI.Document {\n const transformers = [\n rejectSwaggerDocuments,\n addLatestOpenApiVersion,\n addInfoObject,\n addMissingTags,\n normalizeSecuritySchemes,\n ]\n\n return transformers.reduce((doc, transformer) => transformer(doc), definition)\n}\n"],
5
- "mappings": "AAGA,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AACxC,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAEvC,SAAS,+BAA+B;AACxC,SAAS,eAAe,uBAAuB;AAOxC,SAAS,SAAS,YAAyC;AAChE,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,aAAa,OAAO,CAAC,KAAK,gBAAgB,YAAY,GAAG,GAAG,UAAU;AAC/E;",
4
+ "sourcesContent": ["/** biome-ignore-all lint/performance/noBarrelFile: re-exports utilities */\nimport type { OpenAPI } from '@scalar/openapi-types'\n\nimport type { AnyObject } from '@/types/index'\n\nimport { addInfoObject } from './utils/addInfoObject'\nimport { addLatestOpenApiVersion } from './utils/addLatestOpenApiVersion'\nimport { addMissingTags } from './utils/addMissingTags'\nimport { normalizeSecuritySchemes } from './utils/normalizeSecuritySchemes'\nimport { rejectSwaggerDocuments } from './utils/rejectSwaggerDocuments'\n\nexport { DEFAULT_TITLE } from './utils/addInfoObject'\nexport { DEFAULT_OPENAPI_VERSION } from './utils/addLatestOpenApiVersion'\n\n/**\n * Make an OpenAPI document a valid and clean OpenAPI document\n *\n * @deprecated We're about to drop this from the package.\n */\nexport function sanitize(definition: AnyObject): OpenAPI.Document {\n const transformers = [\n rejectSwaggerDocuments,\n addLatestOpenApiVersion,\n addInfoObject,\n addMissingTags,\n normalizeSecuritySchemes,\n ]\n\n return transformers.reduce((doc, transformer) => transformer(doc), definition)\n}\n"],
5
+ "mappings": "AAKA,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AACxC,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AAEvC,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AAOjC,SAAS,SAAS,YAAyC;AAChE,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,aAAa,OAAO,CAAC,KAAK,gBAAgB,YAAY,GAAG,GAAG,UAAU;AAC/E;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,5 @@
1
1
  import type { AnyObject } from '../../../types/index.js';
2
2
  export declare const DEFAULT_TITLE = "API";
3
- export declare const DEFAULT_VERSION = "1.0";
4
3
  export declare const addInfoObject: (definition: AnyObject) => {
5
4
  info: any;
6
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"addInfoObject.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addInfoObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,aAAa,QAAQ,CAAA;AAClC,eAAO,MAAM,eAAe,QAAQ,CAAA;AAEpC,eAAO,MAAM,aAAa,GAAI,YAAY,SAAS;;CAOjD,CAAA"}
1
+ {"version":3,"file":"addInfoObject.d.ts","sourceRoot":"","sources":["../../../../src/utils/transform/utils/addInfoObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,aAAa,QAAQ,CAAA;AAGlC,eAAO,MAAM,aAAa,GAAI,YAAY,SAAS;;CAOjD,CAAA"}
@@ -10,7 +10,6 @@ const addInfoObject = (definition) => ({
10
10
  });
11
11
  export {
12
12
  DEFAULT_TITLE,
13
- DEFAULT_VERSION,
14
13
  addInfoObject
15
14
  };
16
15
  //# sourceMappingURL=addInfoObject.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/transform/utils/addInfoObject.ts"],
4
- "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const DEFAULT_TITLE = 'API'\nexport const DEFAULT_VERSION = '1.0'\n\nexport const addInfoObject = (definition: AnyObject) => ({\n ...definition,\n info: {\n ...definition.info,\n title: definition.info?.title ?? DEFAULT_TITLE,\n version: definition.info?.version ?? DEFAULT_VERSION,\n },\n})\n"],
5
- "mappings": "AAEO,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAExB,MAAM,gBAAgB,CAAC,gBAA2B;AAAA,EACvD,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,GAAG,WAAW;AAAA,IACd,OAAO,WAAW,MAAM,SAAS;AAAA,IACjC,SAAS,WAAW,MAAM,WAAW;AAAA,EACvC;AACF;",
4
+ "sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const DEFAULT_TITLE = 'API'\nconst DEFAULT_VERSION = '1.0'\n\nexport const addInfoObject = (definition: AnyObject) => ({\n ...definition,\n info: {\n ...definition.info,\n title: definition.info?.title ?? DEFAULT_TITLE,\n version: definition.info?.version ?? DEFAULT_VERSION,\n },\n})\n"],
5
+ "mappings": "AAEO,MAAM,gBAAgB;AAC7B,MAAM,kBAAkB;AAEjB,MAAM,gBAAgB,CAAC,gBAA2B;AAAA,EACvD,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,GAAG,WAAW;AAAA,IACd,OAAO,WAAW,MAAM,SAAS;AAAA,IACjC,SAAS,WAAW,MAAM,WAAW;AAAA,EACvC;AACF;",
6
6
  "names": []
7
7
  }
@@ -2,5 +2,5 @@ import type { AnyObject } from '../types/index.js';
2
2
  /**
3
3
  * Transforms ajv errors, finds the positions in the schema and returns an enriched format.
4
4
  */
5
- export declare function transformErrors(specification: AnyObject, errors: any): any;
5
+ export declare function transformErrors(specification: AnyObject, errors: any): any[];
6
6
  //# sourceMappingURL=transform-errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-errors.d.ts","sourceRoot":"","sources":["../../src/utils/transform-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;GAEG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAkBpE"}
1
+ {"version":3,"file":"transform-errors.d.ts","sourceRoot":"","sources":["../../src/utils/transform-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;GAEG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAkBpE"}
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "parser",
18
18
  "typescript"
19
19
  ],
20
- "version": "0.23.3",
20
+ "version": "0.23.5",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -54,20 +54,17 @@
54
54
  "jsonpointer": "^5.0.1",
55
55
  "leven": "^4.0.0",
56
56
  "yaml": "2.8.0",
57
- "@scalar/json-magic": "0.8.2",
58
- "@scalar/openapi-upgrader": "0.1.4",
59
- "@scalar/openapi-types": "0.5.1"
57
+ "@scalar/json-magic": "0.8.4",
58
+ "@scalar/openapi-types": "0.5.2",
59
+ "@scalar/openapi-upgrader": "0.1.5"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@apidevtools/swagger-parser": "10.1.0",
63
63
  "@types/node": "^22.9.0",
64
- "fastify": "^5.3.3",
65
- "json-to-ast": "^2.1.0",
66
64
  "just-diff": "^6.0.2",
67
- "tinybench": "^2.8.0",
68
65
  "vite": "7.1.11",
69
- "@scalar/build-tooling": "0.3.0",
70
- "@scalar/types": "0.5.0"
66
+ "@scalar/build-tooling": "0.3.1",
67
+ "@scalar/types": "0.5.1"
71
68
  },
72
69
  "scripts": {
73
70
  "build": "scalar-build-esbuild",
@@ -75,7 +72,6 @@
75
72
  "lint:check": "eslint .",
76
73
  "lint:fix": "eslint . --fix",
77
74
  "test": "NODE_OPTIONS=--max_old_space_size=8192 vitest",
78
- "test:prepare": "vite-node scripts/load-files.ts",
79
75
  "types:build": "scalar-types-build",
80
76
  "types:check": "scalar-types-check"
81
77
  }
@@ -1,2 +0,0 @@
1
- export { Validator } from './Validator.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
@@ -1,5 +0,0 @@
1
- import { Validator } from "./Validator.js";
2
- export {
3
- Validator
4
- };
5
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/lib/Validator/index.ts"],
4
- "sourcesContent": ["export { Validator } from './Validator'\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export default function getMetaFromPath(jsonAst: any, dataPath: any, includeIdentifierLocation: any): any;
2
- //# sourceMappingURL=get-meta-from-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-meta-from-path.d.ts","sourceRoot":"","sources":["../../../../src/utils/betterAjvErrors/json/get-meta-from-path.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,KAAA,EAAE,QAAQ,KAAA,EAAE,yBAAyB,KAAA,OA0BnF"}
@@ -1,27 +0,0 @@
1
- import { getPointers } from "./utils.js";
2
- function getMetaFromPath(jsonAst, dataPath, includeIdentifierLocation) {
3
- const pointers = getPointers(dataPath);
4
- const lastPointerIndex = pointers.length - 1;
5
- return pointers.reduce((obj, pointer, idx) => {
6
- switch (obj?.type) {
7
- case "Object": {
8
- const filtered = obj.members.filter((child) => child.name.value === pointer);
9
- if (filtered.length !== 1) {
10
- throw new Error(`Couldn't find property ${pointer} of ${dataPath}`);
11
- }
12
- const { name, value } = filtered[0];
13
- return includeIdentifierLocation && idx === lastPointerIndex ? name : value;
14
- }
15
- case "Array":
16
- return obj.elements[pointer];
17
- default:
18
- if (obj.loc) {
19
- return obj;
20
- }
21
- }
22
- }, jsonAst.body);
23
- }
24
- export {
25
- getMetaFromPath as default
26
- };
27
- //# sourceMappingURL=get-meta-from-path.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/utils/betterAjvErrors/json/get-meta-from-path.ts"],
4
- "sourcesContent": ["import { getPointers } from './utils'\n\nexport default function getMetaFromPath(jsonAst, dataPath, includeIdentifierLocation) {\n const pointers = getPointers(dataPath)\n const lastPointerIndex = pointers.length - 1\n return pointers.reduce((obj, pointer, idx) => {\n switch (obj?.type) {\n case 'Object': {\n const filtered = obj.members.filter((child) => child.name.value === pointer)\n if (filtered.length !== 1) {\n throw new Error(`Couldn't find property ${pointer} of ${dataPath}`)\n }\n\n const { name, value } = filtered[0]\n return includeIdentifierLocation && idx === lastPointerIndex ? name : value\n }\n case 'Array':\n return obj.elements[pointer]\n default:\n // Unexpected type\n // console.log(obj)\n\n // Anyway, if there's location, let's just use it.\n if (obj.loc) {\n return obj\n }\n }\n }, jsonAst.body)\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAEb,SAAR,gBAAiC,SAAS,UAAU,2BAA2B;AACpF,QAAM,WAAW,YAAY,QAAQ;AACrC,QAAM,mBAAmB,SAAS,SAAS;AAC3C,SAAO,SAAS,OAAO,CAAC,KAAK,SAAS,QAAQ;AAC5C,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK,UAAU;AACb,cAAM,WAAW,IAAI,QAAQ,OAAO,CAAC,UAAU,MAAM,KAAK,UAAU,OAAO;AAC3E,YAAI,SAAS,WAAW,GAAG;AACzB,gBAAM,IAAI,MAAM,0BAA0B,OAAO,OAAO,QAAQ,EAAE;AAAA,QACpE;AAEA,cAAM,EAAE,MAAM,MAAM,IAAI,SAAS,CAAC;AAClC,eAAO,6BAA6B,QAAQ,mBAAmB,OAAO;AAAA,MACxE;AAAA,MACA,KAAK;AACH,eAAO,IAAI,SAAS,OAAO;AAAA,MAC7B;AAKE,YAAI,IAAI,KAAK;AACX,iBAAO;AAAA,QACT;AAAA,IACJ;AAAA,EACF,GAAG,QAAQ,IAAI;AACjB;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export { default as getMetaFromPath } from './get-meta-from-path.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/betterAjvErrors/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
@@ -1,5 +0,0 @@
1
- import { default as default2 } from "./get-meta-from-path.js";
2
- export {
3
- default2 as getMetaFromPath
4
- };
5
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/utils/betterAjvErrors/json/index.ts"],
4
- "sourcesContent": ["export { default as getMetaFromPath } from './get-meta-from-path'\n"],
5
- "mappings": "AAAA,SAAoB,WAAXA,gBAAkC;",
6
- "names": ["default"]
7
- }
@@ -1,2 +0,0 @@
1
- export declare const getPointers: (dataPath: any) => any;
2
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/betterAjvErrors/json/utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,GAAI,aAAQ,QAMnC,CAAA"}
@@ -1,11 +0,0 @@
1
- const getPointers = (dataPath) => {
2
- const pointers = dataPath.split("/").slice(1);
3
- for (const index in pointers) {
4
- pointers[index] = pointers[index].split("~1").join("/").split("~0").join("~");
5
- }
6
- return pointers;
7
- };
8
- export {
9
- getPointers
10
- };
11
- //# sourceMappingURL=utils.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/utils/betterAjvErrors/json/utils.ts"],
4
- "sourcesContent": ["// TODO: Better error handling\nexport const getPointers = (dataPath) => {\n const pointers = dataPath.split('/').slice(1)\n for (const index in pointers) {\n pointers[index] = pointers[index].split('~1').join('/').split('~0').join('~')\n }\n return pointers\n}\n"],
5
- "mappings": "AACO,MAAM,cAAc,CAAC,aAAa;AACvC,QAAM,WAAW,SAAS,MAAM,GAAG,EAAE,MAAM,CAAC;AAC5C,aAAW,SAAS,UAAU;AAC5B,aAAS,KAAK,IAAI,SAAS,KAAK,EAAE,MAAM,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,IAAI,EAAE,KAAK,GAAG;AAAA,EAC9E;AACA,SAAO;AACT;",
6
- "names": []
7
- }