@scalar/openapi-parser 0.10.16 → 0.11.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 +17 -0
- package/README.md +0 -27
- package/dist/configuration/index.js +19 -22
- package/dist/configuration/index.js.map +7 -0
- package/dist/declarations.d.js +1 -0
- package/dist/declarations.d.js.map +7 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -29
- package/dist/index.js.map +7 -0
- package/dist/lib/Validator/Validator.d.ts +2 -2
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +99 -119
- package/dist/lib/Validator/Validator.js.map +7 -0
- package/dist/lib/Validator/Validator.test.js +8 -0
- package/dist/lib/Validator/Validator.test.js.map +7 -0
- package/dist/lib/Validator/index.d.ts +2 -2
- package/dist/lib/Validator/index.d.ts.map +1 -1
- package/dist/lib/Validator/index.js +3 -0
- package/dist/lib/Validator/index.js.map +7 -0
- package/dist/plugins/fetch-urls/fetchUrls.d.ts +1 -1
- package/dist/plugins/fetch-urls/fetchUrls.d.ts.map +1 -1
- package/dist/plugins/fetch-urls/fetchUrls.js +36 -39
- package/dist/plugins/fetch-urls/fetchUrls.js.map +7 -0
- package/dist/plugins/fetch-urls/fetchUrls.test.js +50 -0
- package/dist/plugins/fetch-urls/fetchUrls.test.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 +2 -1
- package/dist/plugins/fetch-urls/index.js.map +7 -0
- 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 +2 -1
- package/dist/plugins/read-files/index.js.map +7 -0
- package/dist/plugins/read-files/readFiles.d.ts +1 -1
- package/dist/plugins/read-files/readFiles.d.ts.map +1 -1
- package/dist/plugins/read-files/readFiles.js +50 -55
- package/dist/plugins/read-files/readFiles.js.map +7 -0
- package/dist/plugins/read-files/readFiles.test.js +20 -0
- package/dist/plugins/read-files/readFiles.test.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 +5 -0
- package/dist/polyfills/index.js.map +7 -0
- package/dist/polyfills/path.js +155 -98
- package/dist/polyfills/path.js.map +7 -0
- package/dist/schemas/v2.0/schema.d.ts +1405 -0
- package/dist/schemas/v2.0/schema.d.ts.map +1 -0
- package/dist/schemas/v2.0/schema.js +1463 -0
- package/dist/schemas/v2.0/schema.js.map +7 -0
- package/dist/schemas/v3.0/schema.d.ts +1264 -0
- package/dist/schemas/v3.0/schema.d.ts.map +1 -0
- package/dist/schemas/v3.0/schema.js +1493 -0
- package/dist/schemas/v3.0/schema.js.map +7 -0
- package/dist/schemas/v3.1/schema.d.ts +1225 -0
- package/dist/schemas/v3.1/schema.d.ts.map +1 -0
- package/dist/schemas/v3.1/schema.js +1296 -0
- package/dist/schemas/v3.1/schema.js.map +7 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/helpers.js +88 -93
- package/dist/utils/betterAjvErrors/helpers.js.map +7 -0
- package/dist/utils/betterAjvErrors/index.js +14 -13
- package/dist/utils/betterAjvErrors/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.js +27 -0
- package/dist/utils/betterAjvErrors/json/get-meta-from-path.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/index.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/index.js +5 -0
- package/dist/utils/betterAjvErrors/json/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/json/utils.d.ts +2 -0
- package/dist/utils/betterAjvErrors/json/utils.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/json/utils.js +11 -0
- package/dist/utils/betterAjvErrors/json/utils.js.map +7 -0
- package/dist/utils/betterAjvErrors/utils.js +21 -14
- package/dist/utils/betterAjvErrors/utils.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/additional-prop.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.d.ts +23 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/base.js +6 -10
- package/dist/utils/betterAjvErrors/validation-errors/base.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/default.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/default.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts +11 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/enum.js +19 -29
- package/dist/utils/betterAjvErrors/validation-errors/enum.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.d.ts +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.js +15 -0
- package/dist/utils/betterAjvErrors/validation-errors/index.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/pattern.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/required.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/required.js.map +7 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts +10 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.d.ts.map +1 -0
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js +8 -9
- package/dist/utils/betterAjvErrors/validation-errors/unevaluated-prop.js.map +7 -0
- package/dist/utils/dereference.d.ts +2 -2
- package/dist/utils/dereference.d.ts.map +1 -1
- package/dist/utils/dereference.js +17 -19
- package/dist/utils/dereference.js.map +7 -0
- package/dist/utils/dereference.test.js +300 -0
- package/dist/utils/dereference.test.js.map +7 -0
- package/dist/utils/details.d.ts +1 -1
- package/dist/utils/details.d.ts.map +1 -1
- package/dist/utils/details.js +26 -28
- package/dist/utils/details.js.map +7 -0
- package/dist/utils/errors.test.js +48 -0
- package/dist/utils/errors.test.js.map +7 -0
- package/dist/utils/escapeJsonPointer.js +5 -8
- package/dist/utils/escapeJsonPointer.js.map +7 -0
- package/dist/utils/escapeJsonPointer.test.js +11 -0
- package/dist/utils/escapeJsonPointer.test.js.map +7 -0
- package/dist/utils/filter.d.ts +1 -1
- package/dist/utils/filter.d.ts.map +1 -1
- package/dist/utils/filter.js +13 -15
- package/dist/utils/filter.js.map +7 -0
- package/dist/utils/getEntrypoint.d.ts +1 -1
- package/dist/utils/getEntrypoint.d.ts.map +1 -1
- package/dist/utils/getEntrypoint.js +5 -6
- package/dist/utils/getEntrypoint.js.map +7 -0
- package/dist/utils/getEntrypoint.test.js +18 -0
- package/dist/utils/getEntrypoint.test.js.map +7 -0
- package/dist/utils/getListOfReferences.d.ts +1 -1
- package/dist/utils/getListOfReferences.d.ts.map +1 -1
- package/dist/utils/getListOfReferences.js +15 -22
- package/dist/utils/getListOfReferences.js.map +7 -0
- package/dist/utils/getSegmentsFromPath.js +8 -15
- package/dist/utils/getSegmentsFromPath.js.map +7 -0
- package/dist/utils/getSegmentsFromPath.test.js +13 -0
- package/dist/utils/getSegmentsFromPath.test.js.map +7 -0
- package/dist/utils/index.d.ts +26 -26
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/isFilesystem.d.ts +2 -1
- package/dist/utils/isFilesystem.d.ts.map +1 -1
- package/dist/utils/isFilesystem.js +5 -9
- package/dist/utils/isFilesystem.js.map +7 -0
- package/dist/utils/isJson.js +10 -9
- package/dist/utils/isJson.js.map +7 -0
- package/dist/utils/isObject.js +5 -6
- package/dist/utils/isObject.js.map +7 -0
- package/dist/utils/isObject.test.js +23 -0
- package/dist/utils/isObject.test.js.map +7 -0
- package/dist/utils/isYaml.js +16 -17
- package/dist/utils/isYaml.js.map +7 -0
- 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 +2 -0
- package/dist/utils/load/index.js.map +7 -0
- package/dist/utils/load/load.d.ts +1 -1
- package/dist/utils/load/load.d.ts.map +1 -1
- package/dist/utils/load/load.js +89 -110
- package/dist/utils/load/load.js.map +7 -0
- package/dist/utils/load/load.test.js +361 -0
- package/dist/utils/load/load.test.js.map +7 -0
- package/dist/utils/makeFilesystem.d.ts +1 -1
- package/dist/utils/makeFilesystem.d.ts.map +1 -1
- package/dist/utils/makeFilesystem.js +20 -22
- package/dist/utils/makeFilesystem.js.map +7 -0
- package/dist/utils/makeFilesystem.test.js +15 -0
- package/dist/utils/makeFilesystem.test.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 +22 -27
- package/dist/utils/normalize.js.map +7 -0
- package/dist/utils/normalize.test.js +88 -0
- package/dist/utils/normalize.test.js.map +7 -0
- package/dist/utils/openapi/actions/details.d.ts +2 -2
- package/dist/utils/openapi/actions/details.d.ts.map +1 -1
- package/dist/utils/openapi/actions/details.js +9 -11
- package/dist/utils/openapi/actions/details.js.map +7 -0
- package/dist/utils/openapi/actions/files.d.ts +1 -1
- package/dist/utils/openapi/actions/files.d.ts.map +1 -1
- package/dist/utils/openapi/actions/files.js +7 -9
- package/dist/utils/openapi/actions/files.js.map +7 -0
- package/dist/utils/openapi/actions/get.d.ts +1 -1
- package/dist/utils/openapi/actions/get.d.ts.map +1 -1
- package/dist/utils/openapi/actions/get.js +9 -11
- package/dist/utils/openapi/actions/get.js.map +7 -0
- package/dist/utils/openapi/actions/toJson.d.ts +1 -1
- package/dist/utils/openapi/actions/toJson.d.ts.map +1 -1
- package/dist/utils/openapi/actions/toJson.js +9 -11
- package/dist/utils/openapi/actions/toJson.js.map +7 -0
- package/dist/utils/openapi/actions/toYaml.d.ts +1 -1
- package/dist/utils/openapi/actions/toYaml.d.ts.map +1 -1
- package/dist/utils/openapi/actions/toYaml.js +9 -11
- package/dist/utils/openapi/actions/toYaml.js.map +7 -0
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts +5 -5
- package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/dereferenceCommand.js +25 -27
- package/dist/utils/openapi/commands/dereferenceCommand.js.map +7 -0
- package/dist/utils/openapi/commands/filterCommand.d.ts +9 -9
- package/dist/utils/openapi/commands/filterCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/filterCommand.js +24 -26
- package/dist/utils/openapi/commands/filterCommand.js.map +7 -0
- package/dist/utils/openapi/commands/loadCommand.d.ts +994 -994
- package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/loadCommand.js +40 -42
- package/dist/utils/openapi/commands/loadCommand.js.map +7 -0
- package/dist/utils/openapi/commands/upgradeCommand.d.ts +311 -311
- package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/upgradeCommand.js +27 -29
- package/dist/utils/openapi/commands/upgradeCommand.js.map +7 -0
- package/dist/utils/openapi/commands/validateCommand.d.ts +311 -311
- package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/validateCommand.js +31 -33
- package/dist/utils/openapi/commands/validateCommand.js.map +7 -0
- package/dist/utils/openapi/index.d.ts +1 -1
- package/dist/utils/openapi/index.d.ts.map +1 -1
- package/dist/utils/openapi/index.js +2 -0
- package/dist/utils/openapi/index.js.map +7 -0
- package/dist/utils/openapi/openapi.d.ts +702 -700
- package/dist/utils/openapi/openapi.d.ts.map +1 -1
- package/dist/utils/openapi/openapi.js +13 -16
- package/dist/utils/openapi/openapi.js.map +7 -0
- package/dist/utils/openapi/openapi.test-d.js +14 -0
- package/dist/utils/openapi/openapi.test-d.js.map +7 -0
- package/dist/utils/openapi/openapi.test.js +309 -0
- package/dist/utils/openapi/openapi.test.js.map +7 -0
- package/dist/utils/openapi/utils/queueTask.d.ts +1 -1
- package/dist/utils/openapi/utils/queueTask.d.ts.map +1 -1
- package/dist/utils/openapi/utils/queueTask.js +8 -9
- package/dist/utils/openapi/utils/queueTask.js.map +7 -0
- package/dist/utils/openapi/utils/workThroughQueue.d.ts +1 -1
- package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -1
- package/dist/utils/openapi/utils/workThroughQueue.js +49 -64
- package/dist/utils/openapi/utils/workThroughQueue.js.map +7 -0
- package/dist/utils/openapi/utils/workThroughQueue.test.js +244 -0
- package/dist/utils/openapi/utils/workThroughQueue.test.js.map +7 -0
- package/dist/utils/resolveReferences.d.ts +1 -1
- package/dist/utils/resolveReferences.d.ts.map +1 -1
- package/dist/utils/resolveReferences.js +91 -139
- package/dist/utils/resolveReferences.js.map +7 -0
- package/dist/utils/resolveReferences.test.js +567 -0
- package/dist/utils/resolveReferences.test.js.map +7 -0
- package/dist/utils/toJson.d.ts +1 -1
- package/dist/utils/toJson.d.ts.map +1 -1
- package/dist/utils/toJson.js +4 -2
- package/dist/utils/toJson.js.map +7 -0
- package/dist/utils/toYaml.d.ts +1 -1
- package/dist/utils/toYaml.d.ts.map +1 -1
- package/dist/utils/toYaml.js +5 -4
- package/dist/utils/toYaml.js.map +7 -0
- package/dist/utils/transform/index.d.ts +1 -1
- package/dist/utils/transform/index.d.ts.map +1 -1
- package/dist/utils/transform/index.js +2 -0
- package/dist/utils/transform/index.js.map +7 -0
- package/dist/utils/transform/sanitize.d.ts +3 -3
- package/dist/utils/transform/sanitize.d.ts.map +1 -1
- package/dist/utils/transform/sanitize.js +22 -21
- package/dist/utils/transform/sanitize.js.map +7 -0
- package/dist/utils/transform/sanitize.test.js +148 -0
- package/dist/utils/transform/sanitize.test.js.map +7 -0
- package/dist/utils/transform/utils/addInfoObject.d.ts +1 -1
- package/dist/utils/transform/utils/addInfoObject.d.ts.map +1 -1
- package/dist/utils/transform/utils/addInfoObject.js +14 -10
- package/dist/utils/transform/utils/addInfoObject.js.map +7 -0
- package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.d.ts.map +1 -1
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js +8 -5
- package/dist/utils/transform/utils/addLatestOpenApiVersion.js.map +7 -0
- package/dist/utils/transform/utils/addMissingTags.d.ts +1 -1
- package/dist/utils/transform/utils/addMissingTags.d.ts.map +1 -1
- package/dist/utils/transform/utils/addMissingTags.js +26 -27
- package/dist/utils/transform/utils/addMissingTags.js.map +7 -0
- package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.d.ts.map +1 -1
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js +36 -40
- package/dist/utils/transform/utils/normalizeSecuritySchemes.js.map +7 -0
- package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.d.ts.map +1 -1
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js +8 -6
- package/dist/utils/transform/utils/rejectSwaggerDocuments.js.map +7 -0
- package/dist/utils/transformErrors.d.ts +1 -1
- package/dist/utils/transformErrors.d.ts.map +1 -1
- package/dist/utils/transformErrors.js +18 -21
- package/dist/utils/transformErrors.js.map +7 -0
- package/dist/utils/transformErrors.test.js +17 -0
- package/dist/utils/transformErrors.test.js.map +7 -0
- package/dist/utils/traverse.d.ts +3 -3
- package/dist/utils/traverse.d.ts.map +1 -1
- package/dist/utils/traverse.js +22 -23
- package/dist/utils/traverse.js.map +7 -0
- package/dist/utils/traverse.test.js +68 -0
- package/dist/utils/traverse.test.js.map +7 -0
- package/dist/utils/unescapeJsonPointer.js +5 -9
- package/dist/utils/unescapeJsonPointer.js.map +7 -0
- package/dist/utils/unescapeJsonPointer.test.js +19 -0
- package/dist/utils/unescapeJsonPointer.test.js.map +7 -0
- package/dist/utils/upgrade.bench.d.ts +2 -0
- package/dist/utils/upgrade.bench.d.ts.map +1 -0
- package/dist/utils/upgrade.bench.js +31 -0
- package/dist/utils/upgrade.bench.js.map +7 -0
- package/dist/utils/upgrade.d.ts +1 -1
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/upgrade.js +28 -22
- package/dist/utils/upgrade.js.map +7 -0
- package/dist/utils/upgrade.test-d.js +16 -0
- package/dist/utils/upgrade.test-d.js.map +7 -0
- package/dist/utils/upgrade.test.js +57 -0
- package/dist/utils/upgrade.test.js.map +7 -0
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts +3 -3
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +1 -1
- package/dist/utils/upgradeFromThreeToThreeOne.js +107 -144
- package/dist/utils/upgradeFromThreeToThreeOne.js.map +7 -0
- package/dist/utils/upgradeFromThreeToThreeOne.test.js +462 -0
- package/dist/utils/upgradeFromThreeToThreeOne.test.js.map +7 -0
- package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
- package/dist/utils/upgradeFromTwoToThree.js +212 -219
- package/dist/utils/upgradeFromTwoToThree.js.map +7 -0
- package/dist/utils/upgradeFromTwoToThree.test.js +589 -0
- package/dist/utils/upgradeFromTwoToThree.test.js.map +7 -0
- package/dist/utils/validate.d.ts +1 -1
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/validate.js +14 -16
- package/dist/utils/validate.js.map +7 -0
- package/dist/utils/validate.test.js +64 -0
- package/dist/utils/validate.test.js.map +7 -0
- package/package.json +7 -8
- package/dist/schemas/v2.0/schema.json.js +0 -1623
- package/dist/schemas/v3.0/schema.json.js +0 -1673
- package/dist/schemas/v3.1/schema.json.js +0 -1451
|
@@ -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,
|
|
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,mBAAmB,CAAA;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,aAAa,CAAC,EAAE,cAAc;kBASpC,sBAAsB,YAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;EAE9D"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { loadCommand } from
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates a fluent OpenAPI pipeline
|
|
5
|
-
*/
|
|
1
|
+
import { loadCommand } from "./commands/loadCommand.js";
|
|
6
2
|
function openapi(globalOptions) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
3
|
+
const queue = {
|
|
4
|
+
input: null,
|
|
5
|
+
options: globalOptions,
|
|
6
|
+
tasks: []
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
load: (input, options) => loadCommand(queue, input, options)
|
|
10
|
+
};
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export {
|
|
13
|
+
openapi
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/openapi/openapi.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnyApiDefinitionFormat, OpenApiOptions, Queue } from '../../types/index'\nimport type { LoadOptions } from '../load/load'\nimport { loadCommand } from './commands/loadCommand'\n\n/**\n * Creates a fluent OpenAPI pipeline\n *\n * @deprecated We are about to drop the pipeline syntax. Use the individual utilities instead.\n */\nexport function openapi(globalOptions?: OpenApiOptions) {\n // Create a new queue\n const queue = {\n input: null,\n options: globalOptions,\n tasks: [],\n } as Queue<[]>\n\n return {\n load: (input: AnyApiDefinitionFormat, options?: LoadOptions) => loadCommand(queue, input, options),\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,mBAAmB;AAOrB,SAAS,QAAQ,eAAgC;AAEtD,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO,CAAC;AAAA,EACV;AAEA,SAAO;AAAA,IACL,MAAM,CAAC,OAA+B,YAA0B,YAAY,OAAO,OAAO,OAAO;AAAA,EACnG;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expectTypeOf, it } from "vitest";
|
|
2
|
+
import { openapi } from "./openapi.js";
|
|
3
|
+
describe("openapi", () => {
|
|
4
|
+
it("returns the correct type for load()", async () => {
|
|
5
|
+
const result = await openapi().load({}).get();
|
|
6
|
+
expectTypeOf(result.filesystem).toMatchTypeOf();
|
|
7
|
+
expectTypeOf(result.valid).toMatchTypeOf();
|
|
8
|
+
});
|
|
9
|
+
it("returns the correct type for validate()", async () => {
|
|
10
|
+
const result = await openapi().load({}).validate().get();
|
|
11
|
+
expectTypeOf(result.valid).toMatchTypeOf();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=openapi.test-d.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/openapi/openapi.test-d.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expectTypeOf, it } from 'vitest'\n\nimport type { Filesystem } from '../../types/index'\nimport { openapi } from './openapi'\n\ndescribe('openapi', () => {\n it('returns the correct type for load()', async () => {\n const result = await openapi().load({}).get()\n\n expectTypeOf(result.filesystem).toMatchTypeOf<Filesystem>()\n\n // @ts-expect-error `valid` should be undefined\n expectTypeOf(result.valid).toMatchTypeOf<boolean>()\n })\n\n it('returns the correct type for validate()', async () => {\n const result = await openapi().load({}).validate().get()\n\n expectTypeOf(result.valid).toMatchTypeOf<boolean>()\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,cAAc,UAAU;AAG3C,SAAS,eAAe;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,uCAAuC,YAAY;AACpD,UAAM,SAAS,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI;AAE5C,iBAAa,OAAO,UAAU,EAAE,cAA0B;AAG1D,iBAAa,OAAO,KAAK,EAAE,cAAuB;AAAA,EACpD,CAAC;AAED,KAAG,2CAA2C,YAAY;AACxD,UAAM,SAAS,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI;AAEvD,iBAAa,OAAO,KAAK,EAAE,cAAuB;AAAA,EACpD,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { stringify } from "yaml";
|
|
4
|
+
import { readFiles } from "../../plugins/read-files/readFiles.js";
|
|
5
|
+
import { openapi } from "./openapi.js";
|
|
6
|
+
const example = {
|
|
7
|
+
openapi: "3.1.0",
|
|
8
|
+
info: {
|
|
9
|
+
title: "Hello World",
|
|
10
|
+
version: "1.0.0"
|
|
11
|
+
},
|
|
12
|
+
paths: {}
|
|
13
|
+
};
|
|
14
|
+
const EXAMPLE_FILE = join(new URL(import.meta.url).pathname, "../../examples/openapi.yaml");
|
|
15
|
+
describe("pipeline", () => {
|
|
16
|
+
it("load object", async () => {
|
|
17
|
+
const { specification } = await openapi().load(example).get();
|
|
18
|
+
expect(specification.openapi).toBe("3.1.0");
|
|
19
|
+
});
|
|
20
|
+
it("load string", async () => {
|
|
21
|
+
const { specification } = await openapi().load(JSON.stringify(example)).get();
|
|
22
|
+
expect(specification.openapi).toBe("3.1.0");
|
|
23
|
+
});
|
|
24
|
+
it("load file", async () => {
|
|
25
|
+
const { specification } = await openapi().load(EXAMPLE_FILE, {
|
|
26
|
+
plugins: [readFiles()]
|
|
27
|
+
}).get();
|
|
28
|
+
expect(specification.openapi).toBe("3.1.0");
|
|
29
|
+
});
|
|
30
|
+
it("load file + validate", async () => {
|
|
31
|
+
const { specification } = await openapi().load(EXAMPLE_FILE, {
|
|
32
|
+
plugins: [readFiles()]
|
|
33
|
+
}).validate().get();
|
|
34
|
+
expect(specification.openapi).toBe("3.1.0");
|
|
35
|
+
});
|
|
36
|
+
it("files", async () => {
|
|
37
|
+
const filesystem = await openapi().load(EXAMPLE_FILE, {
|
|
38
|
+
plugins: [readFiles()]
|
|
39
|
+
}).files();
|
|
40
|
+
expect(filesystem).toMatchObject([
|
|
41
|
+
{
|
|
42
|
+
isEntrypoint: true,
|
|
43
|
+
specification: {
|
|
44
|
+
openapi: "3.1.0",
|
|
45
|
+
info: {
|
|
46
|
+
title: "Hello World",
|
|
47
|
+
version: "1.0.0"
|
|
48
|
+
},
|
|
49
|
+
paths: {}
|
|
50
|
+
},
|
|
51
|
+
filename: null,
|
|
52
|
+
references: []
|
|
53
|
+
}
|
|
54
|
+
]);
|
|
55
|
+
});
|
|
56
|
+
it("upgrade from 3.0 to 3.1", async () => {
|
|
57
|
+
const { specification } = await openapi().load({
|
|
58
|
+
...example,
|
|
59
|
+
openapi: "3.0.0"
|
|
60
|
+
}).upgrade().get();
|
|
61
|
+
expect(specification.openapi).toBe("3.1.1");
|
|
62
|
+
});
|
|
63
|
+
it("details", async () => {
|
|
64
|
+
const { version } = await openapi().load({
|
|
65
|
+
...example,
|
|
66
|
+
openapi: "3.0.0"
|
|
67
|
+
}).details();
|
|
68
|
+
expect(version).toBe("3.0");
|
|
69
|
+
});
|
|
70
|
+
it("upgrade > dereference", async () => {
|
|
71
|
+
const { version } = await openapi().load({
|
|
72
|
+
...example,
|
|
73
|
+
openapi: "3.0.0"
|
|
74
|
+
}).upgrade().dereference().get();
|
|
75
|
+
expect(version).toBe("3.1");
|
|
76
|
+
});
|
|
77
|
+
it("filter x-internal", async () => {
|
|
78
|
+
const otherExample = {
|
|
79
|
+
openapi: "3.1.0",
|
|
80
|
+
info: {
|
|
81
|
+
title: "Hello World",
|
|
82
|
+
version: "1.0.0"
|
|
83
|
+
},
|
|
84
|
+
paths: {
|
|
85
|
+
"/": {
|
|
86
|
+
get: {
|
|
87
|
+
"x-internal": true,
|
|
88
|
+
"responses": {
|
|
89
|
+
200: {
|
|
90
|
+
description: "OK"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"/foobar": {
|
|
96
|
+
get: {
|
|
97
|
+
responses: {
|
|
98
|
+
200: {
|
|
99
|
+
description: "OK"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const { specification } = await openapi().load(otherExample).filter((schema) => !schema?.["x-internal"]).get();
|
|
107
|
+
expect(specification.paths["/"].get).toBeUndefined();
|
|
108
|
+
expect(specification.paths["/foobar"].get).not.toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
it("filter tags", async () => {
|
|
111
|
+
const otherExample = {
|
|
112
|
+
openapi: "3.1.0",
|
|
113
|
+
info: {
|
|
114
|
+
title: "Hello World",
|
|
115
|
+
version: "1.0.0"
|
|
116
|
+
},
|
|
117
|
+
paths: {
|
|
118
|
+
"/": {
|
|
119
|
+
get: {
|
|
120
|
+
tags: ["Beta"],
|
|
121
|
+
responses: {
|
|
122
|
+
200: {
|
|
123
|
+
description: "OK"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"/foobar": {
|
|
129
|
+
get: {
|
|
130
|
+
responses: {
|
|
131
|
+
200: {
|
|
132
|
+
description: "OK"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const { specification } = await openapi().load(otherExample).filter((schema) => !schema?.tags?.includes("Beta")).get();
|
|
140
|
+
expect(specification.paths["/"].get).toBeUndefined();
|
|
141
|
+
expect(specification.paths["/foobar"].get).not.toBeUndefined();
|
|
142
|
+
});
|
|
143
|
+
it("upgrade > filter", async () => {
|
|
144
|
+
const otherExample = JSON.stringify({
|
|
145
|
+
openapi: "3.0.0",
|
|
146
|
+
info: {
|
|
147
|
+
title: "Hello World",
|
|
148
|
+
version: "1.0.0"
|
|
149
|
+
},
|
|
150
|
+
paths: {
|
|
151
|
+
"/": {
|
|
152
|
+
get: {
|
|
153
|
+
tags: ["Beta"],
|
|
154
|
+
responses: {
|
|
155
|
+
200: {
|
|
156
|
+
description: "OK"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"/foobar": {
|
|
162
|
+
get: {
|
|
163
|
+
responses: {
|
|
164
|
+
200: {
|
|
165
|
+
description: "OK"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const { specification } = await openapi().load(otherExample).upgrade().filter((schema) => !schema?.tags?.includes("Beta")).get();
|
|
173
|
+
expect(specification.openapi).toBe("3.1.1");
|
|
174
|
+
expect(specification.paths["/"].get).toBeUndefined();
|
|
175
|
+
expect(specification.paths["/foobar"].get).not.toBeUndefined();
|
|
176
|
+
});
|
|
177
|
+
it("validate", async () => {
|
|
178
|
+
const result = await openapi().load(example).validate().get();
|
|
179
|
+
expect(result).toMatchObject({
|
|
180
|
+
valid: true,
|
|
181
|
+
version: "3.1"
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
it("toJson", async () => {
|
|
185
|
+
const result = await openapi().load(example).toJson();
|
|
186
|
+
expect(result).toBe(JSON.stringify(example, null, 2));
|
|
187
|
+
});
|
|
188
|
+
it("toYaml", async () => {
|
|
189
|
+
const result = await openapi().load(example).toYaml();
|
|
190
|
+
expect(result).toBe(stringify(example));
|
|
191
|
+
});
|
|
192
|
+
it("dereference", async () => {
|
|
193
|
+
const result = await openapi().load(example).dereference().get();
|
|
194
|
+
expect(result.schema.info.title).toBe("Hello World");
|
|
195
|
+
});
|
|
196
|
+
it("validate > dereference", async () => {
|
|
197
|
+
const result = await openapi().load(example).validate().dereference().get();
|
|
198
|
+
expect(result.valid).toBe(true);
|
|
199
|
+
expect(result.errors).toStrictEqual([]);
|
|
200
|
+
expect(result.schema.info.title).toBe("Hello World");
|
|
201
|
+
});
|
|
202
|
+
it("throws an error when dereference fails (global)", async () => {
|
|
203
|
+
expect(async () => {
|
|
204
|
+
await openapi({
|
|
205
|
+
throwOnError: true
|
|
206
|
+
}).load({
|
|
207
|
+
openapi: "3.1.0",
|
|
208
|
+
info: {},
|
|
209
|
+
paths: {
|
|
210
|
+
"/foobar": {
|
|
211
|
+
post: {
|
|
212
|
+
requestBody: {
|
|
213
|
+
$ref: "#/components/requestBodies/DoesNotExist"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}).dereference().get();
|
|
219
|
+
}).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
|
|
220
|
+
});
|
|
221
|
+
it("throws an error when dereference fails (only dereference)", async () => {
|
|
222
|
+
expect(async () => {
|
|
223
|
+
await openapi().load({
|
|
224
|
+
openapi: "3.1.0",
|
|
225
|
+
info: {},
|
|
226
|
+
paths: {
|
|
227
|
+
"/foobar": {
|
|
228
|
+
post: {
|
|
229
|
+
requestBody: {
|
|
230
|
+
$ref: "#/components/requestBodies/DoesNotExist"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}).dereference({
|
|
236
|
+
throwOnError: true
|
|
237
|
+
}).get();
|
|
238
|
+
}).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
|
|
239
|
+
});
|
|
240
|
+
it("throws an error when validate fails (global)", async () => {
|
|
241
|
+
expect(async () => {
|
|
242
|
+
await openapi({
|
|
243
|
+
throwOnError: true
|
|
244
|
+
}).load({
|
|
245
|
+
openapi: "3.1.0",
|
|
246
|
+
info: {
|
|
247
|
+
title: "Hello World"
|
|
248
|
+
},
|
|
249
|
+
paths: {
|
|
250
|
+
"/foobar": {
|
|
251
|
+
post: {
|
|
252
|
+
requestBody: {
|
|
253
|
+
$ref: "#/components/requestBodies/DoesNotExist"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}).validate().get();
|
|
259
|
+
}).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
|
|
260
|
+
});
|
|
261
|
+
it("throws an error when validate fails (only validate)", async () => {
|
|
262
|
+
expect(async () => {
|
|
263
|
+
await openapi().load({
|
|
264
|
+
openapi: "3.1.0",
|
|
265
|
+
info: {
|
|
266
|
+
title: "Hello World"
|
|
267
|
+
},
|
|
268
|
+
paths: {
|
|
269
|
+
"/foobar": {
|
|
270
|
+
post: {
|
|
271
|
+
requestBody: {
|
|
272
|
+
$ref: "#/components/requestBodies/DoesNotExist"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}).validate({
|
|
278
|
+
throwOnError: true
|
|
279
|
+
}).get();
|
|
280
|
+
}).rejects.toThrowError("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
|
|
281
|
+
});
|
|
282
|
+
it("works with then & catch", async () => {
|
|
283
|
+
return new Promise((resolve, reject) => {
|
|
284
|
+
openapi().load({
|
|
285
|
+
openapi: "3.1.0",
|
|
286
|
+
info: {
|
|
287
|
+
title: "Hello World"
|
|
288
|
+
},
|
|
289
|
+
paths: {
|
|
290
|
+
"/foobar": {
|
|
291
|
+
post: {
|
|
292
|
+
requestBody: {
|
|
293
|
+
$ref: "#/components/requestBodies/DoesNotExist"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}).validate({
|
|
299
|
+
throwOnError: true
|
|
300
|
+
}).get().then(() => {
|
|
301
|
+
reject();
|
|
302
|
+
}).catch((error) => {
|
|
303
|
+
expect(error.message).toBe("Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist");
|
|
304
|
+
resolve(null);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
//# sourceMappingURL=openapi.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/openapi/openapi.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { join } from 'node:path'\nimport { describe, expect, it } from 'vitest'\nimport { stringify } from 'yaml'\n\nimport { readFiles } from '../../plugins/read-files/readFiles'\nimport { openapi } from './openapi'\n\nconst example = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n}\n\nconst EXAMPLE_FILE = join(new URL(import.meta.url).pathname, '../../examples/openapi.yaml')\n\ndescribe('pipeline', () => {\n it('load object', async () => {\n const { specification } = await openapi().load(example).get()\n\n expect(specification.openapi).toBe('3.1.0')\n })\n\n it('load string', async () => {\n const { specification } = await openapi().load(JSON.stringify(example)).get()\n\n expect(specification.openapi).toBe('3.1.0')\n })\n\n it('load file', async () => {\n const { specification } = await openapi()\n .load(EXAMPLE_FILE, {\n plugins: [readFiles()],\n })\n .get()\n\n expect(specification.openapi).toBe('3.1.0')\n })\n\n it('load file + validate', async () => {\n const { specification } = await openapi()\n .load(EXAMPLE_FILE, {\n plugins: [readFiles()],\n })\n .validate()\n .get()\n\n expect(specification.openapi).toBe('3.1.0')\n })\n\n it('files', async () => {\n const filesystem = await openapi()\n .load(EXAMPLE_FILE, {\n plugins: [readFiles()],\n })\n .files()\n\n expect(filesystem).toMatchObject([\n {\n isEntrypoint: true,\n specification: {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n },\n filename: null,\n references: [],\n },\n ])\n })\n\n it('upgrade from 3.0 to 3.1', async () => {\n const { specification } = await openapi()\n .load({\n ...example,\n openapi: '3.0.0',\n })\n .upgrade()\n .get()\n\n expect(specification.openapi).toBe('3.1.1')\n })\n\n it('details', async () => {\n const { version } = await openapi()\n .load({\n ...example,\n openapi: '3.0.0',\n })\n .details()\n\n expect(version).toBe('3.0')\n })\n\n it('upgrade > dereference', async () => {\n const { version } = await openapi()\n .load({\n ...example,\n openapi: '3.0.0',\n })\n .upgrade()\n .dereference()\n .get()\n\n expect(version).toBe('3.1')\n })\n\n it('filter x-internal', async () => {\n const otherExample = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {\n 'x-internal': true,\n 'responses': {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n '/foobar': {\n get: {\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n },\n }\n\n const { specification } = await openapi()\n .load(otherExample)\n .filter((schema) => !schema?.['x-internal'])\n .get()\n\n expect(specification.paths['/'].get).toBeUndefined()\n expect(specification.paths['/foobar'].get).not.toBeUndefined()\n })\n\n it('filter tags', async () => {\n const otherExample = {\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {\n tags: ['Beta'],\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n '/foobar': {\n get: {\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n },\n }\n\n const { specification } = await openapi()\n .load(otherExample)\n .filter((schema) => !schema?.tags?.includes('Beta'))\n .get()\n\n expect(specification.paths['/'].get).toBeUndefined()\n expect(specification.paths['/foobar'].get).not.toBeUndefined()\n })\n\n it('upgrade > filter', async () => {\n const otherExample = JSON.stringify({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {\n tags: ['Beta'],\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n '/foobar': {\n get: {\n responses: {\n 200: {\n description: 'OK',\n },\n },\n },\n },\n },\n })\n\n const { specification } = await openapi()\n .load(otherExample)\n .upgrade()\n .filter((schema) => !schema?.tags?.includes('Beta'))\n .get()\n\n expect(specification.openapi).toBe('3.1.1')\n expect(specification.paths['/'].get).toBeUndefined()\n expect(specification.paths['/foobar'].get).not.toBeUndefined()\n })\n\n it('validate', async () => {\n const result = await openapi().load(example).validate().get()\n\n expect(result).toMatchObject({\n valid: true,\n version: '3.1',\n })\n })\n\n it('toJson', async () => {\n const result = await openapi().load(example).toJson()\n\n expect(result).toBe(JSON.stringify(example, null, 2))\n })\n\n it('toYaml', async () => {\n const result = await openapi().load(example).toYaml()\n\n expect(result).toBe(stringify(example))\n })\n\n it('dereference', async () => {\n const result = await openapi().load(example).dereference().get()\n\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('validate > dereference', async () => {\n const result = await openapi().load(example).validate().dereference().get()\n\n expect(result.valid).toBe(true)\n expect(result.errors).toStrictEqual([])\n expect(result.schema.info.title).toBe('Hello World')\n })\n\n it('throws an error when dereference fails (global)', async () => {\n expect(async () => {\n await openapi({\n throwOnError: true,\n })\n .load({\n openapi: '3.1.0',\n info: {},\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n })\n .dereference()\n .get()\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('throws an error when dereference fails (only dereference)', async () => {\n expect(async () => {\n await openapi()\n .load({\n openapi: '3.1.0',\n info: {},\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n })\n .dereference({\n throwOnError: true,\n })\n .get()\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('throws an error when validate fails (global)', async () => {\n expect(async () => {\n await openapi({\n throwOnError: true,\n })\n .load({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n })\n .validate()\n .get()\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('throws an error when validate fails (only validate)', async () => {\n expect(async () => {\n await openapi()\n .load({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n })\n .validate({\n throwOnError: true,\n })\n .get()\n }).rejects.toThrowError('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n })\n\n it('works with then & catch', async () => {\n return new Promise((resolve, reject) => {\n openapi()\n .load({\n openapi: '3.1.0',\n info: {\n title: 'Hello World',\n },\n paths: {\n '/foobar': {\n post: {\n requestBody: {\n $ref: '#/components/requestBodies/DoesNotExist',\n },\n },\n },\n },\n })\n .validate({\n throwOnError: true,\n })\n .get()\n .then(() => {\n reject()\n })\n .catch((error) => {\n expect(error.message).toBe('Can\u2019t resolve reference: #/components/requestBodies/DoesNotExist')\n\n resolve(null)\n })\n })\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,iBAAiB;AAE1B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAExB,MAAM,UAAU;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA,OAAO,CAAC;AACV;AAEA,MAAM,eAAe,KAAK,IAAI,IAAI,YAAY,GAAG,EAAE,UAAU,6BAA6B;AAE1F,SAAS,YAAY,MAAM;AACzB,KAAG,eAAe,YAAY;AAC5B,UAAM,EAAE,cAAc,IAAI,MAAM,QAAQ,EAAE,KAAK,OAAO,EAAE,IAAI;AAE5D,WAAO,cAAc,OAAO,EAAE,KAAK,OAAO;AAAA,EAC5C,CAAC;AAED,KAAG,eAAe,YAAY;AAC5B,UAAM,EAAE,cAAc,IAAI,MAAM,QAAQ,EAAE,KAAK,KA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,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC,EACA,SAAS;AAAA,QACR,cAAc;AAAA,MAChB,CAAC,EACA,IAAI;AAAA,IACT,CAAC,EAAE,QAAQ,aAAa,uEAAkE;AAAA,EAC5F,CAAC;AAED,KAAG,2BAA2B,YAAY;AACxC,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,cAAQ,EACL,KAAK;AAAA,QACJ,SAAS;AAAA,QACT,MAAM;AAAA,UACJ,OAAO;AAAA,QACT;AAAA,QACA,OAAO;AAAA,UACL,WAAW;AAAA,YACT,MAAM;AAAA,cACJ,aAAa;AAAA,gBACX,MAAM;AAAA,cACR;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC,EACA,SAAS;AAAA,QACR,cAAc;AAAA,MAChB,CAAC,EACA,IAAI,EACJ,KAAK,MAAM;AACV,eAAO;AAAA,MACT,CAAC,EACA,MAAM,CAAC,UAAU;AAChB,eAAO,MAAM,OAAO,EAAE,KAAK,uEAAkE;AAE7F,gBAAQ,IAAI;AAAA,MACd,CAAC;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueTask.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/queueTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"queueTask.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/queueTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAI7D,KAAK,CAAC,CAAC,CAAC,CACd"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add a new task to the existing queue
|
|
3
|
-
*/
|
|
4
1
|
function queueTask(queue, task) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
return {
|
|
3
|
+
...queue,
|
|
4
|
+
tasks: [...queue.tasks, task]
|
|
5
|
+
};
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export {
|
|
8
|
+
queueTask
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=queueTask.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/utils/openapi/utils/queueTask.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Queue, Task } from '../../../types/index'\n\n/**\n * Add a new task to the existing queue\n */\nexport function queueTask<T extends Task[]>(queue: Queue, task: Task) {\n return {\n ...queue,\n tasks: [...queue.tasks, task],\n } as Queue<T>\n}\n"],
|
|
5
|
+
"mappings": "AAKO,SAAS,UAA4B,OAAc,MAAY;AACpE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,CAAC,GAAG,MAAM,OAAO,IAAI;AAAA,EAC9B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workThroughQueue.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/workThroughQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"workThroughQueue.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/workThroughQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAO5E;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAkElG"}
|
|
@@ -1,67 +1,52 @@
|
|
|
1
|
-
import { dereference } from
|
|
2
|
-
import { filter } from
|
|
3
|
-
import { load } from
|
|
4
|
-
import { upgrade } from
|
|
5
|
-
import { validate } from
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Takes a queue of tasks and works through them
|
|
9
|
-
*/
|
|
1
|
+
import { dereference } from "../../dereference.js";
|
|
2
|
+
import { filter } from "../../filter.js";
|
|
3
|
+
import { load } from "../../load/load.js";
|
|
4
|
+
import { upgrade } from "../../upgrade.js";
|
|
5
|
+
import { validate } from "../../validate.js";
|
|
10
6
|
async function workThroughQueue(queue) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
result = {
|
|
50
|
-
...result,
|
|
51
|
-
...upgrade(currentSpecification),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// validate
|
|
55
|
-
else if (name === 'validate') {
|
|
56
|
-
result = {
|
|
57
|
-
...result,
|
|
58
|
-
...(await validate(currentSpecification, options)),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
// Make TS complain when we forgot to handle a command.
|
|
62
|
-
else ;
|
|
7
|
+
const { input } = {
|
|
8
|
+
...queue
|
|
9
|
+
};
|
|
10
|
+
let result = {};
|
|
11
|
+
for (const task of queue.tasks) {
|
|
12
|
+
const name = task.name;
|
|
13
|
+
const options = "options" in task ? task.options : void 0;
|
|
14
|
+
const currentSpecification = result.specification ? result.specification : typeof input === "object" ? (
|
|
15
|
+
// Detach from the original object
|
|
16
|
+
structuredClone(input)
|
|
17
|
+
) : input;
|
|
18
|
+
if (name === "load") {
|
|
19
|
+
result = {
|
|
20
|
+
...result,
|
|
21
|
+
...await load(input, options)
|
|
22
|
+
};
|
|
23
|
+
} else if (name === "filter") {
|
|
24
|
+
result = {
|
|
25
|
+
...result,
|
|
26
|
+
...filter(currentSpecification, options)
|
|
27
|
+
};
|
|
28
|
+
} else if (name === "dereference") {
|
|
29
|
+
result = {
|
|
30
|
+
...result,
|
|
31
|
+
...await dereference(currentSpecification, options)
|
|
32
|
+
};
|
|
33
|
+
} else if (name === "upgrade") {
|
|
34
|
+
result = {
|
|
35
|
+
...result,
|
|
36
|
+
...upgrade(currentSpecification)
|
|
37
|
+
};
|
|
38
|
+
} else if (name === "validate") {
|
|
39
|
+
result = {
|
|
40
|
+
...result,
|
|
41
|
+
...await validate(currentSpecification, options)
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
const _ = name;
|
|
63
45
|
}
|
|
64
|
-
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
65
48
|
}
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
export {
|
|
50
|
+
workThroughQueue
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=workThroughQueue.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/utils/openapi/utils/workThroughQueue.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CommandChain, Merge, Queue, Task } from '../../../types/index'\nimport { dereference } from '../../dereference'\nimport { filter } from '../../filter'\nimport { load } from '../../load/load'\nimport { upgrade } from '../../upgrade'\nimport { validate } from '../../validate'\n\n/**\n * Takes a queue of tasks and works through them\n */\nexport async function workThroughQueue<T extends Task[]>(queue: Queue<T>): Promise<CommandChain<T>> {\n const { input } = {\n ...queue,\n }\n let result = {} as CommandChain<T>\n\n // Work through the whole queue\n for (const task of queue.tasks) {\n const name: keyof Commands = task.name\n const options: any = 'options' in task ? task.options : undefined\n\n // Use the result of the previous task, or fall back to the original input\n const currentSpecification = result.specification\n ? result.specification\n : typeof input === 'object'\n ? // Detach from the original object\n structuredClone(input)\n : input\n\n // load\n if (name === 'load') {\n result = {\n ...result,\n ...(await load(input, options as Commands['load']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof load>>\n }\n\n // validate\n else if (name === 'filter') {\n result = {\n ...result,\n ...filter(currentSpecification, options as Commands['filter']['task']['options']),\n } as Merge<typeof result, ReturnType<typeof filter>>\n }\n\n // dereference\n else if (name === 'dereference') {\n result = {\n ...result,\n ...(await dereference(currentSpecification, options as Commands['dereference']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof dereference>>\n }\n\n // upgrade\n else if (name === 'upgrade') {\n result = {\n ...result,\n ...upgrade(currentSpecification),\n } as Merge<typeof result, ReturnType<typeof upgrade>>\n }\n\n // validate\n else if (name === 'validate') {\n result = {\n ...result,\n ...(await validate(currentSpecification, options as Commands['validate']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof validate>>\n }\n\n // Make TS complain when we forgot to handle a command.\n else {\n const _: never = name\n }\n }\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAKzB,eAAsB,iBAAmC,OAA2C;AAClG,QAAM,EAAE,MAAM,IAAI;AAAA,IAChB,GAAG;AAAA,EACL;AACA,MAAI,SAAS,CAAC;AAGd,aAAW,QAAQ,MAAM,OAAO;AAC9B,UAAM,OAAuB,KAAK;AAClC,UAAM,UAAe,aAAa,OAAO,KAAK,UAAU;AAGxD,UAAM,uBAAuB,OAAO,gBAChC,OAAO,gBACP,OAAO,UAAU;AAAA;AAAA,MAEf,gBAAgB,KAAK;AAAA,QACrB;AAGN,QAAI,SAAS,QAAQ;AACnB,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,KAAK,OAAO,OAA8C;AAAA,MACtE;AAAA,IACF,WAGS,SAAS,UAAU;AAC1B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,OAAO,sBAAsB,OAAgD;AAAA,MAClF;AAAA,IACF,WAGS,SAAS,eAAe;AAC/B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,YAAY,sBAAsB,OAAqD;AAAA,MACnG;AAAA,IACF,WAGS,SAAS,WAAW;AAC3B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,QAAQ,oBAAoB;AAAA,MACjC;AAAA,IACF,WAGS,SAAS,YAAY;AAC5B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,SAAS,sBAAsB,OAAkD;AAAA,MAC7F;AAAA,IACF,OAGK;AACH,YAAM,IAAW;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|