@scalar/openapi-parser 0.11.1 → 0.13.0
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.
- package/CHANGELOG.md +12 -0
- package/dist/configuration/index.d.ts +2 -2
- package/dist/configuration/index.js +2 -2
- package/dist/configuration/index.js.map +1 -1
- package/dist/index.d.ts +17 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -4
- package/dist/index.js.map +2 -2
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +2 -2
- package/dist/lib/Validator/Validator.js.map +1 -1
- package/dist/lib/Validator/index.d.ts +1 -2
- package/dist/lib/Validator/index.d.ts.map +1 -1
- package/dist/lib/Validator/index.js +4 -2
- package/dist/lib/Validator/index.js.map +2 -2
- package/dist/plugins/fetch-urls/{fetchUrls.d.ts → fetch-urls.d.ts} +1 -1
- package/dist/plugins/fetch-urls/fetch-urls.d.ts.map +1 -0
- package/dist/plugins/fetch-urls/{fetchUrls.js → fetch-urls.js} +1 -1
- package/dist/plugins/fetch-urls/fetch-urls.js.map +7 -0
- package/dist/plugins/fetch-urls/index.d.ts +1 -1
- package/dist/plugins/fetch-urls/index.d.ts.map +1 -1
- package/dist/plugins/fetch-urls/index.js +5 -1
- package/dist/plugins/fetch-urls/index.js.map +2 -2
- package/dist/plugins/read-files/index.d.ts +1 -1
- package/dist/plugins/read-files/index.d.ts.map +1 -1
- package/dist/plugins/read-files/index.js +4 -1
- package/dist/plugins/read-files/index.js.map +2 -2
- package/dist/plugins/read-files/{readFiles.d.ts → read-files.d.ts} +1 -1
- package/dist/plugins/read-files/read-files.d.ts.map +1 -0
- package/dist/plugins/read-files/{readFiles.js → read-files.js} +3 -3
- package/dist/plugins/read-files/read-files.js.map +7 -0
- package/dist/polyfills/index.d.ts +1 -1
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +22 -2
- package/dist/polyfills/index.js.map +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/validation-errors/base.js.map +1 -1
- package/dist/utils/dereference.d.ts +1 -1
- package/dist/utils/dereference.d.ts.map +1 -1
- package/dist/utils/dereference.js +3 -3
- package/dist/utils/dereference.js.map +1 -1
- package/dist/utils/details.d.ts +1 -2
- package/dist/utils/details.d.ts.map +1 -1
- package/dist/utils/details.js +12 -9
- package/dist/utils/details.js.map +2 -2
- package/dist/utils/{escapeJsonPointer.d.ts → escape-json-pointer.d.ts} +1 -1
- package/dist/utils/escape-json-pointer.d.ts.map +1 -0
- package/dist/utils/{escapeJsonPointer.js → escape-json-pointer.js} +1 -1
- package/dist/utils/{escapeJsonPointer.js.map → escape-json-pointer.js.map} +1 -1
- package/dist/utils/filter.d.ts.map +1 -1
- package/dist/utils/filter.js +2 -2
- package/dist/utils/filter.js.map +1 -1
- package/dist/utils/{getEntrypoint.d.ts → get-entrypoint.d.ts} +1 -1
- package/dist/utils/get-entrypoint.d.ts.map +1 -0
- package/dist/utils/{getEntrypoint.js → get-entrypoint.js} +1 -1
- package/dist/utils/get-entrypoint.js.map +7 -0
- package/dist/utils/{getListOfReferences.d.ts → get-list-of-references.d.ts} +1 -1
- package/dist/utils/get-list-of-references.d.ts.map +1 -0
- package/dist/utils/{getListOfReferences.js → get-list-of-references.js} +1 -1
- package/dist/utils/get-list-of-references.js.map +7 -0
- package/dist/utils/{getSegmentsFromPath.d.ts → get-segments-from-path.d.ts} +1 -1
- package/dist/utils/get-segments-from-path.d.ts.map +1 -0
- package/dist/utils/{getSegmentsFromPath.js → get-segments-from-path.js} +2 -2
- package/dist/utils/get-segments-from-path.js.map +7 -0
- package/dist/utils/{isFilesystem.d.ts → is-filesystem.d.ts} +1 -1
- package/dist/utils/is-filesystem.d.ts.map +1 -0
- package/dist/utils/{isFilesystem.js → is-filesystem.js} +1 -1
- package/dist/utils/is-filesystem.js.map +7 -0
- package/dist/utils/{isJson.d.ts → is-json.d.ts} +1 -1
- package/dist/utils/is-json.d.ts.map +1 -0
- package/dist/utils/{isJson.js → is-json.js} +1 -1
- package/dist/utils/{isJson.js.map → is-json.js.map} +1 -1
- package/dist/utils/{isObject.d.ts → is-object.d.ts} +1 -1
- package/dist/utils/is-object.d.ts.map +1 -0
- package/dist/utils/{isObject.js → is-object.js} +1 -1
- package/dist/utils/{isObject.js.map → is-object.js.map} +1 -1
- package/dist/utils/{isYaml.d.ts → is-yaml.d.ts} +1 -1
- package/dist/utils/is-yaml.d.ts.map +1 -0
- package/dist/utils/{isYaml.js → is-yaml.js} +1 -1
- package/dist/utils/{isYaml.js.map → is-yaml.js.map} +1 -1
- package/dist/utils/load/index.d.ts +1 -1
- package/dist/utils/load/index.d.ts.map +1 -1
- package/dist/utils/load/index.js +4 -1
- package/dist/utils/load/index.js.map +2 -2
- package/dist/utils/load/load.d.ts.map +1 -1
- package/dist/utils/load/load.js +4 -4
- package/dist/utils/load/load.js.map +1 -1
- package/dist/utils/{makeFilesystem.d.ts → make-filesystem.d.ts} +1 -1
- package/dist/utils/make-filesystem.d.ts.map +1 -0
- package/dist/utils/{makeFilesystem.js → make-filesystem.js} +3 -3
- package/dist/utils/make-filesystem.js.map +7 -0
- package/dist/utils/normalize.d.ts +1 -1
- package/dist/utils/normalize.d.ts.map +1 -1
- package/dist/utils/normalize.js +17 -12
- package/dist/utils/normalize.js.map +2 -2
- package/dist/utils/{resolveReferences.d.ts → resolve-references.d.ts} +1 -1
- package/dist/utils/resolve-references.d.ts.map +1 -0
- package/dist/utils/{resolveReferences.js → resolve-references.js} +15 -4
- package/dist/utils/resolve-references.js.map +7 -0
- package/dist/utils/{toJson.d.ts → to-json.d.ts} +1 -1
- package/dist/utils/to-json.d.ts.map +1 -0
- package/dist/utils/{toJson.js → to-json.js} +1 -1
- package/dist/utils/to-json.js.map +7 -0
- package/dist/utils/{toYaml.d.ts → to-yaml.d.ts} +1 -1
- package/dist/utils/to-yaml.d.ts.map +1 -0
- package/dist/utils/{toYaml.js → to-yaml.js} +1 -1
- package/dist/utils/{toYaml.js.map → to-yaml.js.map} +2 -2
- package/dist/utils/transform/sanitize.d.ts +2 -0
- package/dist/utils/transform/sanitize.d.ts.map +1 -1
- package/dist/utils/transform/sanitize.js.map +2 -2
- package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
- package/dist/utils/transform/utils/addInfoObject.js.map +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +1 -1
- package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
- package/dist/utils/transform/utils/addMissingTags.js.map +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +1 -1
- package/dist/utils/{transformErrors.d.ts → transform-errors.d.ts} +1 -1
- package/dist/utils/transform-errors.d.ts.map +1 -0
- package/dist/utils/{transformErrors.js → transform-errors.js} +1 -1
- package/dist/utils/transform-errors.js.map +7 -0
- package/dist/utils/traverse.d.ts.map +1 -1
- package/dist/utils/traverse.js.map +1 -1
- package/dist/utils/{unescapeJsonPointer.d.ts → unescape-json-pointer.d.ts} +1 -1
- package/dist/utils/unescape-json-pointer.d.ts.map +1 -0
- package/dist/utils/{unescapeJsonPointer.js → unescape-json-pointer.js} +1 -1
- package/dist/utils/{unescapeJsonPointer.js.map → unescape-json-pointer.js.map} +1 -1
- package/dist/utils/{upgradeFromThreeToThreeOne.d.ts → upgrade-from-three-to-three-one.d.ts} +1 -1
- package/dist/utils/upgrade-from-three-to-three-one.d.ts.map +1 -0
- package/dist/utils/{upgradeFromThreeToThreeOne.js → upgrade-from-three-to-three-one.js} +1 -2
- package/dist/utils/upgrade-from-three-to-three-one.js.map +7 -0
- package/dist/utils/{upgradeFromTwoToThree.d.ts → upgrade-from-two-to-three.d.ts} +1 -1
- package/dist/utils/upgrade-from-two-to-three.d.ts.map +1 -0
- package/dist/utils/{upgradeFromTwoToThree.js → upgrade-from-two-to-three.js} +1 -1
- package/dist/utils/{upgradeFromTwoToThree.js.map → upgrade-from-two-to-three.js.map} +1 -1
- package/dist/utils/upgrade.bench.js +1 -1
- package/dist/utils/upgrade.bench.js.map +1 -1
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/upgrade.js +4 -4
- package/dist/utils/upgrade.js.map +1 -1
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/validate.js +1 -1
- package/dist/utils/validate.js.map +1 -1
- package/package.json +3 -3
- package/dist/lib/Validator/Validator.test.js +0 -8
- package/dist/lib/Validator/Validator.test.js.map +0 -7
- package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +0 -1
- package/dist/plugins/fetch-urls/fetchUrls.js.map +0 -7
- package/dist/plugins/fetch-urls/fetchUrls.test.js +0 -50
- package/dist/plugins/fetch-urls/fetchUrls.test.js.map +0 -7
- package/dist/plugins/read-files/readFiles.d.ts.map +0 -1
- package/dist/plugins/read-files/readFiles.js.map +0 -7
- package/dist/plugins/read-files/readFiles.test.js +0 -20
- package/dist/plugins/read-files/readFiles.test.js.map +0 -7
- package/dist/utils/dereference.test.js +0 -300
- package/dist/utils/dereference.test.js.map +0 -7
- package/dist/utils/errors.test.js +0 -48
- package/dist/utils/errors.test.js.map +0 -7
- package/dist/utils/escapeJsonPointer.d.ts.map +0 -1
- package/dist/utils/escapeJsonPointer.test.js +0 -11
- package/dist/utils/escapeJsonPointer.test.js.map +0 -7
- package/dist/utils/getEntrypoint.d.ts.map +0 -1
- package/dist/utils/getEntrypoint.js.map +0 -7
- package/dist/utils/getEntrypoint.test.js +0 -18
- package/dist/utils/getEntrypoint.test.js.map +0 -7
- package/dist/utils/getListOfReferences.d.ts.map +0 -1
- package/dist/utils/getListOfReferences.js.map +0 -7
- package/dist/utils/getSegmentsFromPath.d.ts.map +0 -1
- package/dist/utils/getSegmentsFromPath.js.map +0 -7
- package/dist/utils/getSegmentsFromPath.test.js +0 -13
- package/dist/utils/getSegmentsFromPath.test.js.map +0 -7
- package/dist/utils/index.d.ts +0 -27
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -27
- package/dist/utils/index.js.map +0 -7
- package/dist/utils/isFilesystem.d.ts.map +0 -1
- package/dist/utils/isFilesystem.js.map +0 -7
- package/dist/utils/isJson.d.ts.map +0 -1
- package/dist/utils/isObject.d.ts.map +0 -1
- package/dist/utils/isObject.test.js +0 -23
- package/dist/utils/isObject.test.js.map +0 -7
- package/dist/utils/isYaml.d.ts.map +0 -1
- package/dist/utils/load/load.test.js +0 -361
- package/dist/utils/load/load.test.js.map +0 -7
- package/dist/utils/makeFilesystem.d.ts.map +0 -1
- package/dist/utils/makeFilesystem.js.map +0 -7
- package/dist/utils/makeFilesystem.test.js +0 -15
- package/dist/utils/makeFilesystem.test.js.map +0 -7
- package/dist/utils/normalize.test.js +0 -88
- package/dist/utils/normalize.test.js.map +0 -7
- package/dist/utils/openapi/actions/details.d.ts +0 -7
- package/dist/utils/openapi/actions/details.d.ts.map +0 -1
- package/dist/utils/openapi/actions/details.js +0 -11
- package/dist/utils/openapi/actions/details.js.map +0 -7
- package/dist/utils/openapi/actions/files.d.ts +0 -6
- package/dist/utils/openapi/actions/files.d.ts.map +0 -1
- package/dist/utils/openapi/actions/files.js +0 -9
- package/dist/utils/openapi/actions/files.js.map +0 -7
- package/dist/utils/openapi/actions/get.d.ts +0 -6
- package/dist/utils/openapi/actions/get.d.ts.map +0 -1
- package/dist/utils/openapi/actions/get.js +0 -11
- package/dist/utils/openapi/actions/get.js.map +0 -7
- package/dist/utils/openapi/actions/toJson.d.ts +0 -6
- package/dist/utils/openapi/actions/toJson.d.ts.map +0 -1
- package/dist/utils/openapi/actions/toJson.js +0 -11
- package/dist/utils/openapi/actions/toJson.js.map +0 -7
- package/dist/utils/openapi/actions/toYaml.d.ts +0 -6
- package/dist/utils/openapi/actions/toYaml.d.ts.map +0 -1
- package/dist/utils/openapi/actions/toYaml.js +0 -11
- package/dist/utils/openapi/actions/toYaml.js.map +0 -7
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts +0 -27
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +0 -1
- package/dist/utils/openapi/commands/dereferenceCommand.js +0 -27
- package/dist/utils/openapi/commands/dereferenceCommand.js.map +0 -7
- package/dist/utils/openapi/commands/filterCommand.d.ts +0 -41
- package/dist/utils/openapi/commands/filterCommand.d.ts.map +0 -1
- package/dist/utils/openapi/commands/filterCommand.js +0 -26
- package/dist/utils/openapi/commands/filterCommand.js.map +0 -7
- package/dist/utils/openapi/commands/loadCommand.d.ts +0 -8321
- package/dist/utils/openapi/commands/loadCommand.d.ts.map +0 -1
- package/dist/utils/openapi/commands/loadCommand.js +0 -42
- package/dist/utils/openapi/commands/loadCommand.js.map +0 -7
- package/dist/utils/openapi/commands/upgradeCommand.d.ts +0 -3406
- package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +0 -1
- package/dist/utils/openapi/commands/upgradeCommand.js +0 -29
- package/dist/utils/openapi/commands/upgradeCommand.js.map +0 -7
- package/dist/utils/openapi/commands/validateCommand.d.ts +0 -3451
- package/dist/utils/openapi/commands/validateCommand.d.ts.map +0 -1
- package/dist/utils/openapi/commands/validateCommand.js +0 -33
- package/dist/utils/openapi/commands/validateCommand.js.map +0 -7
- package/dist/utils/openapi/index.d.ts +0 -2
- package/dist/utils/openapi/index.d.ts.map +0 -1
- package/dist/utils/openapi/index.js +0 -2
- package/dist/utils/openapi/index.js.map +0 -7
- package/dist/utils/openapi/openapi.d.ts +0 -1272
- package/dist/utils/openapi/openapi.d.ts.map +0 -1
- package/dist/utils/openapi/openapi.js +0 -15
- package/dist/utils/openapi/openapi.js.map +0 -7
- package/dist/utils/openapi/openapi.test-d.d.ts +0 -2
- package/dist/utils/openapi/openapi.test-d.d.ts.map +0 -1
- package/dist/utils/openapi/openapi.test-d.js +0 -14
- package/dist/utils/openapi/openapi.test-d.js.map +0 -7
- package/dist/utils/openapi/openapi.test.js +0 -309
- package/dist/utils/openapi/openapi.test.js.map +0 -7
- package/dist/utils/openapi/utils/queueTask.d.ts +0 -6
- package/dist/utils/openapi/utils/queueTask.d.ts.map +0 -1
- package/dist/utils/openapi/utils/queueTask.js +0 -10
- package/dist/utils/openapi/utils/queueTask.js.map +0 -7
- package/dist/utils/openapi/utils/workThroughQueue.d.ts +0 -6
- package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +0 -1
- package/dist/utils/openapi/utils/workThroughQueue.js +0 -52
- package/dist/utils/openapi/utils/workThroughQueue.js.map +0 -7
- package/dist/utils/openapi/utils/workThroughQueue.test.js +0 -244
- package/dist/utils/openapi/utils/workThroughQueue.test.js.map +0 -7
- package/dist/utils/resolveReferences.d.ts.map +0 -1
- package/dist/utils/resolveReferences.js.map +0 -7
- package/dist/utils/resolveReferences.test.js +0 -567
- package/dist/utils/resolveReferences.test.js.map +0 -7
- package/dist/utils/toJson.d.ts.map +0 -1
- package/dist/utils/toJson.js.map +0 -7
- package/dist/utils/toYaml.d.ts.map +0 -1
- package/dist/utils/transform/index.d.ts +0 -2
- package/dist/utils/transform/index.d.ts.map +0 -1
- package/dist/utils/transform/index.js +0 -2
- package/dist/utils/transform/index.js.map +0 -7
- package/dist/utils/transform/sanitize.test.js +0 -148
- package/dist/utils/transform/sanitize.test.js.map +0 -7
- package/dist/utils/transformErrors.d.ts.map +0 -1
- package/dist/utils/transformErrors.js.map +0 -7
- package/dist/utils/transformErrors.test.js +0 -17
- package/dist/utils/transformErrors.test.js.map +0 -7
- package/dist/utils/traverse.test.js +0 -68
- package/dist/utils/traverse.test.js.map +0 -7
- package/dist/utils/unescapeJsonPointer.d.ts.map +0 -1
- package/dist/utils/unescapeJsonPointer.test.js +0 -19
- package/dist/utils/unescapeJsonPointer.test.js.map +0 -7
- package/dist/utils/upgrade.test.js +0 -57
- package/dist/utils/upgrade.test.js.map +0 -7
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +0 -1
- package/dist/utils/upgradeFromThreeToThreeOne.js.map +0 -7
- package/dist/utils/upgradeFromThreeToThreeOne.test.js +0 -462
- package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +0 -7
- package/dist/utils/upgradeFromTwoToThree.d.ts.map +0 -1
- package/dist/utils/upgradeFromTwoToThree.test.js +0 -589
- package/dist/utils/upgradeFromTwoToThree.test.js.map +0 -7
- package/dist/utils/validate.test.js +0 -64
- package/dist/utils/validate.test.js.map +0 -7
package/dist/utils/filter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getEntrypoint } from "./
|
|
2
|
-
import { makeFilesystem } from "./
|
|
1
|
+
import { getEntrypoint } from "./get-entrypoint.js";
|
|
2
|
+
import { makeFilesystem } from "./make-filesystem.js";
|
|
3
3
|
import { traverse } from "./traverse.js";
|
|
4
4
|
function filter(specification, callback) {
|
|
5
5
|
const filesystem = makeFilesystem(specification);
|
package/dist/utils/filter.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/filter.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AnyApiDefinitionFormat, AnyObject, FilterResult } from '
|
|
4
|
+
"sourcesContent": ["import type { AnyApiDefinitionFormat, AnyObject, FilterResult } from '@/types/index'\nimport { getEntrypoint } from './get-entrypoint'\nimport { makeFilesystem } from './make-filesystem'\nimport { traverse } from './traverse'\n\nexport type FilterCallback = (schema: AnyObject) => boolean\n\n/**\n * Filter the specification based on the callback\n */\nexport function filter(specification: AnyApiDefinitionFormat, callback: FilterCallback): FilterResult {\n const filesystem = makeFilesystem(specification)\n\n return {\n specification: traverse(getEntrypoint(filesystem).specification, (schema) => {\n return callback(schema) ? schema : undefined\n }),\n }\n}\n"],
|
|
5
5
|
"mappings": "AACA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAOlB,SAAS,OAAO,eAAuC,UAAwC;AACpG,QAAM,aAAa,eAAe,aAAa;AAE/C,SAAO;AAAA,IACL,eAAe,SAAS,cAAc,UAAU,EAAE,eAAe,CAAC,WAAW;AAC3E,aAAO,SAAS,MAAM,IAAI,SAAS;AAAA,IACrC,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,4 +3,4 @@ import type { Filesystem, FilesystemEntry } from '../types/index.js';
|
|
|
3
3
|
* Return just the entrypoint of the filesystem.
|
|
4
4
|
*/
|
|
5
5
|
export declare function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined;
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=get-entrypoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/get-entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEhE;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAElF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-entrypoint.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Filesystem, FilesystemEntry } from '@/types/index'\n\n/**\n * Return just the entrypoint of the filesystem.\n */\nexport function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined {\n return filesystem?.find((file) => file.isEntrypoint)\n}\n"],
|
|
5
|
+
"mappings": "AAKO,SAAS,cAAc,YAAsD;AAClF,SAAO,YAAY,KAAK,CAAC,SAAS,KAAK,YAAY;AACrD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,4 +5,4 @@ import type { AnyObject } from '../types/index.js';
|
|
|
5
5
|
* Warning: Doesn’t return internal references.
|
|
6
6
|
*/
|
|
7
7
|
export declare function getListOfReferences(specification: AnyObject): string[];
|
|
8
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=get-list-of-references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-list-of-references.d.ts","sourceRoot":"","sources":["../../src/utils/get-list-of-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,YAmB3D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-list-of-references.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnyObject } from '@/types/index'\nimport { traverse } from './traverse'\n\n/**\n * Walks through the specification and returns all references as an array.\n *\n * Warning: Doesn\u2019t return internal references.\n */\nexport function getListOfReferences(specification: AnyObject) {\n const references: string[] = []\n\n // Make sure we\u2019re dealing with an object\n if (!specification || typeof specification !== 'object') {\n return references\n }\n\n // Traverse the specification and collect all references\n traverse(specification, (value: any) => {\n if (value.$ref && typeof value.$ref === 'string' && !value.$ref.startsWith('#')) {\n references.push(value.$ref.split('#')[0])\n }\n\n return value\n })\n\n // Remove duplicates\n return [...new Set(references)]\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,gBAAgB;AAOlB,SAAS,oBAAoB,eAA0B;AAC5D,QAAM,aAAuB,CAAC;AAG9B,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AAGA,WAAS,eAAe,CAAC,UAAe;AACtC,QAAI,MAAM,QAAQ,OAAO,MAAM,SAAS,YAAY,CAAC,MAAM,KAAK,WAAW,GAAG,GAAG;AAC/E,iBAAW,KAAK,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,IAC1C;AAEA,WAAO;AAAA,EACT,CAAC;AAGD,SAAO,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-segments-from-path.d.ts","sourceRoot":"","sources":["../../src/utils/get-segments-from-path.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,YAW/C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unescapeJsonPointer } from "./
|
|
1
|
+
import { unescapeJsonPointer } from "./unescape-json-pointer.js";
|
|
2
2
|
function getSegmentsFromPath(path) {
|
|
3
3
|
return (
|
|
4
4
|
// /paths/~1test
|
|
@@ -8,4 +8,4 @@ function getSegmentsFromPath(path) {
|
|
|
8
8
|
export {
|
|
9
9
|
getSegmentsFromPath
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=
|
|
11
|
+
//# sourceMappingURL=get-segments-from-path.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/get-segments-from-path.ts"],
|
|
4
|
+
"sourcesContent": ["import { unescapeJsonPointer } from './unescape-json-pointer'\n\n/**\n * Translate `/paths/~1test` to `['paths', '/test']`\n */\nexport function getSegmentsFromPath(path: string) {\n return (\n // /paths/~1test\n path\n // ['', 'paths', '~1test']\n .split('/')\n // ['paths', '~test']\n .slice(1)\n // ['paths', '/test']\n .map(unescapeJsonPointer)\n )\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,2BAA2B;AAK7B,SAAS,oBAAoB,MAAc;AAChD;AAAA;AAAA,IAEE,KAEG,MAAM,GAAG,EAET,MAAM,CAAC,EAEP,IAAI,mBAAmB;AAAA;AAE9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/is-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,UAAU,CAO5D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/is-filesystem.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Filesystem } from '@/types'\n\n/**\n * Check if the value is a filesystem\n */\nexport function isFilesystem(value: any): value is Filesystem {\n return (\n typeof value !== 'undefined' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.some((file) => file.isEntrypoint === true)\n )\n}\n"],
|
|
5
|
+
"mappings": "AAKO,SAAS,aAAa,OAAiC;AAC5D,SACE,OAAO,UAAU,eACjB,MAAM,QAAQ,KAAK,KACnB,MAAM,SAAS,KACf,MAAM,KAAK,CAAC,SAAS,KAAK,iBAAiB,IAAI;AAEnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isJson(value: string): boolean;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=is-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-json.d.ts","sourceRoot":"","sources":["../../src/utils/is-json.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAQnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/
|
|
3
|
+
"sources": ["../../src/utils/is-json.ts"],
|
|
4
4
|
"sourcesContent": ["export function isJson(value: string) {\n try {\n JSON.parse(value)\n\n return true\n } catch {\n return false\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAO,SAAS,OAAO,OAAe;AACpC,MAAI;AACF,SAAK,MAAM,KAAK;AAEhB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-object.d.ts","sourceRoot":"","sources":["../../src/utils/is-object.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,YAAmE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/
|
|
3
|
+
"sources": ["../../src/utils/is-object.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Check if the given value is an object\n */\nexport const isObject = (obj: any) => typeof obj === 'object' && !Array.isArray(obj) && obj !== null\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,WAAW,CAAC,QAAa,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG,KAAK,QAAQ;",
|
|
6
6
|
"names": []
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isYaml(value: string): boolean;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=is-yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-yaml.d.ts","sourceRoot":"","sources":["../../src/utils/is-yaml.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,WAenC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/
|
|
3
|
+
"sources": ["../../src/utils/is-yaml.ts"],
|
|
4
4
|
"sourcesContent": ["import { parse } from 'yaml'\n\nexport function isYaml(value: string) {\n // Line breaks\n if (!value.includes('\\n')) {\n return false\n }\n\n try {\n parse(value, {\n maxAliasCount: 10000,\n })\n\n return true\n } catch (_error) {\n return false\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,aAAa;AAEf,SAAS,OAAO,OAAe;AAEpC,MAAI,CAAC,MAAM,SAAS,IAAI,GAAG;AACzB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,OAAO;AAAA,MACX,eAAe;AAAA,IACjB,CAAC;AAED,WAAO;AAAA,EACT,SAAS,QAAQ;AACf,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { load, type LoadPlugin, type LoadOptions } from './load.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/load/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/load/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
package/dist/utils/load/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/load/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export { load, type LoadPlugin, type LoadOptions } from './load'\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAA+C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAGtB,UAAU,EACV,UAAU,EACV,kBAAkB,EACnB,MAAM,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EAGtB,UAAU,EACV,UAAU,EACV,kBAAkB,EACnB,MAAM,eAAe,CAAA;AAMtB,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACvD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,kBAAkB,CAAA;AAEtB;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAyHpG"}
|
package/dist/utils/load/load.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ERRORS } from "../../configuration/index.js";
|
|
2
|
-
import { getEntrypoint } from "
|
|
3
|
-
import { getListOfReferences } from "
|
|
4
|
-
import { makeFilesystem } from "
|
|
5
|
-
import { normalize } from "
|
|
2
|
+
import { getEntrypoint } from "../../utils/get-entrypoint.js";
|
|
3
|
+
import { getListOfReferences } from "../../utils/get-list-of-references.js";
|
|
4
|
+
import { makeFilesystem } from "../../utils/make-filesystem.js";
|
|
5
|
+
import { normalize } from "../../utils/normalize.js";
|
|
6
6
|
async function load(value, options) {
|
|
7
7
|
const errors = [];
|
|
8
8
|
if (options?.filesystem?.find((entry) => entry.filename === value)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/load/load.ts"],
|
|
4
|
-
"sourcesContent": ["import { ERRORS } from '
|
|
4
|
+
"sourcesContent": ["import { ERRORS } from '@/configuration'\nimport type {\n AnyApiDefinitionFormat,\n AnyObject,\n ErrorObject,\n Filesystem,\n LoadResult,\n ThrowOnErrorOption,\n} from '@/types/index'\nimport { getEntrypoint } from '@/utils/get-entrypoint'\nimport { getListOfReferences } from '@/utils/get-list-of-references'\nimport { makeFilesystem } from '@/utils/make-filesystem'\nimport { normalize } from '@/utils/normalize'\n\nexport type LoadPlugin = {\n check: (value?: any) => boolean\n get: (value: any) => any\n resolvePath?: (value: any, reference: string) => string\n getDir?: (value: any) => string\n getFilename?: (value: any) => string\n}\n\nexport type LoadOptions = {\n plugins?: LoadPlugin[]\n filename?: string\n filesystem?: Filesystem\n} & ThrowOnErrorOption\n\n/**\n * Loads an OpenAPI document, including any external references.\n *\n * This function handles loading content from various sources, normalizes the content,\n * and recursively loads any external references found within the definition.\n *\n * It builds a filesystem representation of all loaded content and collects any errors\n * encountered during the process.\n */\nexport async function load(value: AnyApiDefinitionFormat, options?: LoadOptions): Promise<LoadResult> {\n const errors: ErrorObject[] = []\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (options?.filesystem?.find((entry) => entry.filename === value)) {\n return {\n specification: getEntrypoint(options.filesystem)?.specification,\n filesystem: options.filesystem,\n errors,\n }\n }\n\n // Check whether the value is an URL or file path\n const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value))\n\n let content: AnyObject\n\n if (plugin) {\n try {\n content = normalize(await plugin.get(value))\n } catch (_error) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string))\n }\n\n errors.push({\n code: 'EXTERNAL_REFERENCE_NOT_FOUND',\n message: ERRORS.EXTERNAL_REFERENCE_NOT_FOUND.replace('%s', value as string),\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n } else {\n content = normalize(value)\n }\n\n // No content\n if (content === undefined) {\n if (options?.throwOnError) {\n throw new Error('No content to load')\n }\n\n errors.push({\n code: 'NO_CONTENT',\n message: ERRORS.NO_CONTENT,\n })\n\n return {\n specification: null,\n filesystem: [],\n errors,\n }\n }\n\n let filesystem = makeFilesystem(content, {\n filename: options?.filename ?? null,\n })\n\n // Get references from file system entry, or from the content\n const newEntry = options?.filename\n ? filesystem.find((entry) => entry.filename === options?.filename)\n : getEntrypoint(filesystem)\n\n const listOfReferences = newEntry.references ?? getListOfReferences(content)\n\n // No other references\n if (listOfReferences.length === 0) {\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n }\n\n // Load other external references\n for (const reference of listOfReferences) {\n // Find a matching plugin\n const otherPlugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(reference))\n\n // Skip if no plugin is found (internal references don\u2019t need a plugin for example)\n if (!otherPlugin) {\n continue\n }\n\n const target =\n otherPlugin.check(reference) && otherPlugin.resolvePath ? otherPlugin.resolvePath(value, reference) : reference\n\n // Don\u2019t load a reference twice, check the filesystem before fetching something\n if (filesystem.find((entry) => entry.filename === reference)) {\n continue\n }\n\n const { filesystem: referencedFiles, errors: newErrors } = await load(target, {\n ...options,\n // Make the filename the exact same value as the $ref\n // TODO: This leads to problems, if there are multiple references with the same file name but in different folders\n filename: reference,\n })\n\n errors.push(...newErrors)\n\n filesystem = [\n ...filesystem,\n ...referencedFiles.map((file) => {\n return {\n ...file,\n isEntrypoint: false,\n }\n }),\n ]\n }\n\n return {\n specification: getEntrypoint(filesystem)?.specification,\n filesystem,\n errors,\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,cAAc;AASvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAyB1B,eAAsB,KAAK,OAA+B,SAA4C;AACpG,QAAM,SAAwB,CAAC;AAG/B,MAAI,SAAS,YAAY,KAAK,CAAC,UAAU,MAAM,aAAa,KAAK,GAAG;AAClE,WAAO;AAAA,MACL,eAAe,cAAc,QAAQ,UAAU,GAAG;AAAA,MAClD,YAAY,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAGA,QAAM,SAAS,SAAS,SAAS,KAAK,CAAC,eAAe,WAAW,MAAM,KAAK,CAAC;AAE7E,MAAI;AAEJ,MAAI,QAAQ;AACV,QAAI;AACF,gBAAU,UAAU,MAAM,OAAO,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,QAAQ;AACf,UAAI,SAAS,cAAc;AACzB,cAAM,IAAI,MAAM,OAAO,6BAA6B,QAAQ,MAAM,KAAe,CAAC;AAAA,MACpF;AAEA,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,SAAS,OAAO,6BAA6B,QAAQ,MAAM,KAAe;AAAA,MAC5E,CAAC;AAED,aAAO;AAAA,QACL,eAAe;AAAA,QACf,YAAY,CAAC;AAAA,QACb;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AACL,cAAU,UAAU,KAAK;AAAA,EAC3B;AAGA,MAAI,YAAY,QAAW;AACzB,QAAI,SAAS,cAAc;AACzB,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAEA,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,SAAS,OAAO;AAAA,IAClB,CAAC;AAED,WAAO;AAAA,MACL,eAAe;AAAA,MACf,YAAY,CAAC;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAEA,MAAI,aAAa,eAAe,SAAS;AAAA,IACvC,UAAU,SAAS,YAAY;AAAA,EACjC,CAAC;AAGD,QAAM,WAAW,SAAS,WACtB,WAAW,KAAK,CAAC,UAAU,MAAM,aAAa,SAAS,QAAQ,IAC/D,cAAc,UAAU;AAE5B,QAAM,mBAAmB,SAAS,cAAc,oBAAoB,OAAO;AAG3E,MAAI,iBAAiB,WAAW,GAAG;AACjC,WAAO;AAAA,MACL,eAAe,cAAc,UAAU,GAAG;AAAA,MAC1C;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,aAAW,aAAa,kBAAkB;AAExC,UAAM,cAAc,SAAS,SAAS,KAAK,CAAC,eAAe,WAAW,MAAM,SAAS,CAAC;AAGtF,QAAI,CAAC,aAAa;AAChB;AAAA,IACF;AAEA,UAAM,SACJ,YAAY,MAAM,SAAS,KAAK,YAAY,cAAc,YAAY,YAAY,OAAO,SAAS,IAAI;AAGxG,QAAI,WAAW,KAAK,CAAC,UAAU,MAAM,aAAa,SAAS,GAAG;AAC5D;AAAA,IACF;AAEA,UAAM,EAAE,YAAY,iBAAiB,QAAQ,UAAU,IAAI,MAAM,KAAK,QAAQ;AAAA,MAC5E,GAAG;AAAA;AAAA;AAAA,MAGH,UAAU;AAAA,IACZ,CAAC;AAED,WAAO,KAAK,GAAG,SAAS;AAExB,iBAAa;AAAA,MACX,GAAG;AAAA,MACH,GAAG,gBAAgB,IAAI,CAAC,SAAS;AAC/B,eAAO;AAAA,UACL,GAAG;AAAA,UACH,cAAc;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe,cAAc,UAAU,GAAG;AAAA,IAC1C;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AnyObject, Filesystem, FilesystemEntry } from '../types/index.js';
|
|
2
2
|
export declare function makeFilesystem(value: string | AnyObject | Filesystem, overwrites?: Partial<FilesystemEntry>): Filesystem;
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=make-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/make-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAK3E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,UAAU,GAAE,OAAO,CAAC,eAAe,CAAM,GACxC,UAAU,CAoBZ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getListOfReferences } from "./
|
|
2
|
-
import { isFilesystem } from "./
|
|
1
|
+
import { getListOfReferences } from "./get-list-of-references.js";
|
|
2
|
+
import { isFilesystem } from "./is-filesystem.js";
|
|
3
3
|
import { normalize } from "./normalize.js";
|
|
4
4
|
function makeFilesystem(value, overwrites = {}) {
|
|
5
5
|
if (isFilesystem(value)) {
|
|
@@ -20,4 +20,4 @@ function makeFilesystem(value, overwrites = {}) {
|
|
|
20
20
|
export {
|
|
21
21
|
makeFilesystem
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=make-filesystem.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/make-filesystem.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnyObject, Filesystem, FilesystemEntry } from '@/types/index'\nimport { getListOfReferences } from './get-list-of-references'\nimport { isFilesystem } from './is-filesystem'\nimport { normalize } from './normalize'\n\nexport function makeFilesystem(\n value: string | AnyObject | Filesystem,\n overwrites: Partial<FilesystemEntry> = {},\n): Filesystem {\n // Keep as is\n if (isFilesystem(value)) {\n return value as Filesystem\n }\n\n // Make an object\n const specification = normalize(value)\n\n // Create fake filesystem\n return [\n {\n isEntrypoint: true,\n specification,\n filename: null,\n dir: './',\n references: getListOfReferences(specification),\n ...overwrites,\n },\n ]\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAEnB,SAAS,eACd,OACA,aAAuC,CAAC,GAC5B;AAEZ,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,UAAU,KAAK;AAGrC,SAAO;AAAA,IACL;AAAA,MACE,cAAc;AAAA,MACd;AAAA,MACA,UAAU;AAAA,MACV,KAAK;AAAA,MACL,YAAY,oBAAoB,aAAa;AAAA,MAC7C,GAAG;AAAA,IACL;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,5 +5,5 @@ import type { Filesystem } from '../types/index.js';
|
|
|
5
5
|
*
|
|
6
6
|
* Doesn’t modify the object if it’s a `Filesystem` (multiple files) already.
|
|
7
7
|
*/
|
|
8
|
-
export declare function normalize(
|
|
8
|
+
export declare function normalize(content: string | UnknownObject | Filesystem): UnknownObject | Filesystem;
|
|
9
9
|
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAgClG"}
|
package/dist/utils/normalize.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { parse } from "yaml";
|
|
2
|
-
import { isFilesystem } from "./
|
|
3
|
-
function normalize(
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
2
|
+
import { isFilesystem } from "./is-filesystem.js";
|
|
3
|
+
function normalize(content) {
|
|
4
|
+
if (content === null) {
|
|
5
|
+
return void 0;
|
|
6
6
|
}
|
|
7
|
-
if (typeof
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
7
|
+
if (typeof content === "string") {
|
|
8
|
+
if (content.trim() === "") {
|
|
9
|
+
return void 0;
|
|
10
10
|
}
|
|
11
11
|
try {
|
|
12
|
-
return JSON.parse(
|
|
12
|
+
return JSON.parse(content);
|
|
13
13
|
} catch (_error) {
|
|
14
|
-
|
|
14
|
+
const hasColon = /^[^:]+:/.test(content);
|
|
15
|
+
const isMultiLine = content.includes("\n");
|
|
16
|
+
if (!hasColon || !isMultiLine) {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
return parse(content, {
|
|
15
20
|
maxAliasCount: 1e4
|
|
16
21
|
});
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
|
-
if (isFilesystem(
|
|
20
|
-
return
|
|
24
|
+
if (isFilesystem(content)) {
|
|
25
|
+
return content;
|
|
21
26
|
}
|
|
22
|
-
return
|
|
27
|
+
return content;
|
|
23
28
|
}
|
|
24
29
|
export {
|
|
25
30
|
normalize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/normalize.ts"],
|
|
4
|
-
"sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport { parse } from 'yaml'\n\nimport type { Filesystem } from '
|
|
5
|
-
"mappings": "AACA,SAAS,aAAa;AAGtB,SAAS,oBAAoB;AAOtB,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import type { UnknownObject } from '@scalar/types/utils'\nimport { parse } from 'yaml'\n\nimport type { Filesystem } from '@/types/index'\nimport { isFilesystem } from './is-filesystem'\n\n/**\n * Normalize the OpenAPI document (YAML, JSON, object) to a JavaScript object.\n *\n * Doesn\u2019t modify the object if it\u2019s a `Filesystem` (multiple files) already.\n */\nexport function normalize(content: string | UnknownObject | Filesystem): UnknownObject | Filesystem {\n if (content === null) {\n return undefined\n }\n\n if (typeof content === 'string') {\n if (content.trim() === '') {\n return undefined\n }\n\n try {\n return JSON.parse(content)\n } catch (_error) {\n // Does it look like YAML?\n const hasColon = /^[^:]+:/.test(content)\n const isMultiLine = content.includes('\\n')\n\n if (!hasColon || !isMultiLine) {\n return undefined\n }\n\n return parse(content, {\n maxAliasCount: 10000,\n })\n }\n }\n\n if (isFilesystem(content)) {\n return content\n }\n\n return content\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa;AAGtB,SAAS,oBAAoB;AAOtB,SAAS,UAAU,SAA0E;AAClG,MAAI,YAAY,MAAM;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,QAAI,QAAQ,KAAK,MAAM,IAAI;AACzB,aAAO;AAAA,IACT;AAEA,QAAI;AACF,aAAO,KAAK,MAAM,OAAO;AAAA,IAC3B,SAAS,QAAQ;AAEf,YAAM,WAAW,UAAU,KAAK,OAAO;AACvC,YAAM,cAAc,QAAQ,SAAS,IAAI;AAEzC,UAAI,CAAC,YAAY,CAAC,aAAa;AAC7B,eAAO;AAAA,MACT;AAEA,aAAO,MAAM,SAAS;AAAA,QACpB,eAAe;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,aAAa,OAAO,GAAG;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,4 +20,4 @@ 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
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=resolve-references.d.ts.map
|
|
@@ -0,0 +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;AAgB5G,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,12 +1,23 @@
|
|
|
1
1
|
import { ERRORS } from "../configuration/index.js";
|
|
2
|
-
import { getEntrypoint } from "./
|
|
3
|
-
import { getSegmentsFromPath } from "./
|
|
4
|
-
import {
|
|
2
|
+
import { getEntrypoint } from "./get-entrypoint.js";
|
|
3
|
+
import { getSegmentsFromPath } from "./get-segments-from-path.js";
|
|
4
|
+
import { isObject } from "./is-object.js";
|
|
5
|
+
import { makeFilesystem } from "./make-filesystem.js";
|
|
5
6
|
function resolveReferences(input, options, file, errors = []) {
|
|
6
7
|
const clonedInput = structuredClone(input);
|
|
7
8
|
const filesystem = makeFilesystem(clonedInput);
|
|
8
9
|
const entrypoint = getEntrypoint(filesystem);
|
|
9
10
|
const finalInput = file?.specification ?? entrypoint.specification;
|
|
11
|
+
if (!isObject(finalInput)) {
|
|
12
|
+
if (options?.throwOnError) {
|
|
13
|
+
throw new Error(ERRORS.NO_CONTENT);
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
valid: false,
|
|
17
|
+
errors,
|
|
18
|
+
schema: finalInput
|
|
19
|
+
};
|
|
20
|
+
}
|
|
10
21
|
dereference(finalInput, filesystem, file ?? entrypoint, /* @__PURE__ */ new WeakSet(), errors, options);
|
|
11
22
|
errors = errors.filter(
|
|
12
23
|
(error, index, self) => index === self.findIndex((t) => t.message === error.message && t.code === error.code)
|
|
@@ -99,4 +110,4 @@ function resolveUri(uri, options, file, filesystem, resolve, errors) {
|
|
|
99
110
|
export {
|
|
100
111
|
resolveReferences
|
|
101
112
|
};
|
|
102
|
-
//# sourceMappingURL=
|
|
113
|
+
//# sourceMappingURL=resolve-references.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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'\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\u2019s 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 duplicats (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
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-json.d.ts","sourceRoot":"","sources":["../../src/utils/to-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,MAAM,UAAW,SAAS,WAAmC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/to-json.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnyObject } from '@/types/index'\n\nexport const toJson = (value: AnyObject) => JSON.stringify(value, null, 2)\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,SAAS,CAAC,UAAqB,KAAK,UAAU,OAAO,MAAM,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-yaml.d.ts","sourceRoot":"","sources":["../../src/utils/to-yaml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,eAAO,MAAM,MAAM,UAAW,SAAS,WAAqB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/
|
|
4
|
-
"sourcesContent": ["import { stringify } from 'yaml'\n\nimport type { AnyObject } from '
|
|
3
|
+
"sources": ["../../src/utils/to-yaml.ts"],
|
|
4
|
+
"sourcesContent": ["import { stringify } from 'yaml'\n\nimport type { AnyObject } from '@/types/index'\n\nexport const toYaml = (value: AnyObject) => stringify(value)\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAInB,MAAM,SAAS,CAAC,UAAqB,UAAU,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,6 +4,8 @@ export { DEFAULT_OPENAPI_VERSION } from './utils/addLatestOpenApiVersion.js';
|
|
|
4
4
|
export { DEFAULT_TITLE, DEFAULT_VERSION } from './utils/addInfoObject.js';
|
|
5
5
|
/**
|
|
6
6
|
* Make an OpenAPI document a valid and clean OpenAPI document
|
|
7
|
+
*
|
|
8
|
+
* @deprecated We’re about to drop this from the package.
|
|
7
9
|
*/
|
|
8
10
|
export declare function sanitize(definition: AnyObject): OpenAPI.Document;
|
|
9
11
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -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,
|
|
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,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 '
|
|
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;
|
|
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\u2019re 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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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,
|
|
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,eAAgB,SAAS;;CAOjD,CAAA"}
|