@scalar/openapi-parser 0.7.2 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +1 -1
  3. package/README.md +193 -24
  4. package/dist/configuration/index.d.ts +2 -1
  5. package/dist/configuration/index.d.ts.map +1 -1
  6. package/dist/configuration/index.js +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/Validator/Validator.d.ts +1 -1
  9. package/dist/lib/Validator/Validator.d.ts.map +1 -1
  10. package/dist/lib/Validator/Validator.js +1 -1
  11. package/dist/polyfills/path.d.ts +3 -3
  12. package/dist/polyfills/path.d.ts.map +1 -1
  13. package/dist/polyfills/path.js +1 -1
  14. package/dist/types/index.d.ts +78 -9
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/utils/betterAjvErrors/helpers.d.ts.map +1 -1
  17. package/dist/utils/betterAjvErrors/helpers.js +1 -1
  18. package/dist/utils/dereference.d.ts +3 -2
  19. package/dist/utils/dereference.d.ts.map +1 -1
  20. package/dist/utils/filter.d.ts +3 -2
  21. package/dist/utils/filter.d.ts.map +1 -1
  22. package/dist/utils/getEntrypoint.d.ts +2 -2
  23. package/dist/utils/getEntrypoint.d.ts.map +1 -1
  24. package/dist/utils/getEntrypoint.js +1 -1
  25. package/dist/utils/getListOfReferences.d.ts +1 -1
  26. package/dist/utils/getListOfReferences.d.ts.map +1 -1
  27. package/dist/utils/index.d.ts +1 -1
  28. package/dist/utils/isFilesystem.js +1 -1
  29. package/dist/utils/load/load.d.ts +13 -3
  30. package/dist/utils/load/load.d.ts.map +1 -1
  31. package/dist/utils/load/load.js +1 -1
  32. package/dist/utils/load/plugins/fetchUrls.d.ts +1 -1
  33. package/dist/utils/load/plugins/fetchUrls.d.ts.map +1 -1
  34. package/dist/utils/load/plugins/readFiles.d.ts +1 -1
  35. package/dist/utils/load/plugins/readFiles.d.ts.map +1 -1
  36. package/dist/utils/normalize.d.ts +1 -1
  37. package/dist/utils/normalize.d.ts.map +1 -1
  38. package/dist/utils/openapi/actions/details.d.ts +7 -0
  39. package/dist/utils/openapi/actions/details.d.ts.map +1 -0
  40. package/dist/utils/openapi/actions/details.js +1 -0
  41. package/dist/utils/openapi/actions/files.d.ts +6 -0
  42. package/dist/utils/openapi/actions/files.d.ts.map +1 -0
  43. package/dist/utils/openapi/actions/files.js +1 -0
  44. package/dist/utils/openapi/actions/get.d.ts +6 -0
  45. package/dist/utils/openapi/actions/get.d.ts.map +1 -0
  46. package/dist/utils/openapi/actions/get.js +1 -0
  47. package/dist/utils/openapi/actions/toJson.d.ts +6 -0
  48. package/dist/utils/openapi/actions/toJson.d.ts.map +1 -0
  49. package/dist/utils/openapi/actions/toJson.js +1 -0
  50. package/dist/utils/openapi/actions/toYaml.d.ts +6 -0
  51. package/dist/utils/openapi/actions/toYaml.d.ts.map +1 -0
  52. package/dist/utils/openapi/actions/toYaml.js +1 -0
  53. package/dist/utils/openapi/commands/dereferenceCommand.d.ts +27 -0
  54. package/dist/utils/openapi/commands/dereferenceCommand.d.ts.map +1 -0
  55. package/dist/utils/openapi/commands/dereferenceCommand.js +1 -0
  56. package/dist/utils/openapi/commands/filterCommand.d.ts +41 -0
  57. package/dist/utils/openapi/commands/filterCommand.d.ts.map +1 -0
  58. package/dist/utils/openapi/commands/filterCommand.js +1 -0
  59. package/dist/utils/openapi/commands/loadCommand.d.ts +8321 -0
  60. package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -0
  61. package/dist/utils/openapi/commands/loadCommand.js +1 -0
  62. package/dist/utils/openapi/commands/upgradeCommand.d.ts +3406 -0
  63. package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -0
  64. package/dist/utils/openapi/commands/upgradeCommand.js +1 -0
  65. package/dist/utils/openapi/commands/validateCommand.d.ts +3451 -0
  66. package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -0
  67. package/dist/utils/openapi/commands/validateCommand.js +1 -0
  68. package/dist/utils/openapi/index.d.ts +2 -0
  69. package/dist/utils/openapi/index.d.ts.map +1 -0
  70. package/dist/utils/openapi/openapi.d.ts +1270 -0
  71. package/dist/utils/openapi/openapi.d.ts.map +1 -0
  72. package/dist/utils/openapi/openapi.js +1 -0
  73. package/dist/utils/openapi/openapi.test-d.d.ts +2 -0
  74. package/dist/utils/openapi/openapi.test-d.d.ts.map +1 -0
  75. package/dist/utils/openapi/utils/queueTask.d.ts +6 -0
  76. package/dist/utils/openapi/utils/queueTask.d.ts.map +1 -0
  77. package/dist/utils/openapi/utils/queueTask.js +1 -0
  78. package/dist/utils/openapi/utils/workThroughQueue.d.ts +6 -0
  79. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -0
  80. package/dist/utils/openapi/utils/workThroughQueue.js +1 -0
  81. package/dist/utils/resolveReferences.d.ts +1 -1
  82. package/dist/utils/resolveReferences.d.ts.map +1 -1
  83. package/dist/utils/toJson.d.ts +1 -1
  84. package/dist/utils/toJson.d.ts.map +1 -1
  85. package/dist/utils/toYaml.d.ts +1 -1
  86. package/dist/utils/toYaml.d.ts.map +1 -1
  87. package/dist/utils/traverse.d.ts +1 -1
  88. package/dist/utils/traverse.d.ts.map +1 -1
  89. package/dist/utils/upgrade.d.ts +2 -1
  90. package/dist/utils/upgrade.d.ts.map +1 -1
  91. package/dist/utils/upgrade.js +1 -1
  92. package/dist/utils/upgrade.test-d.d.ts +2 -0
  93. package/dist/utils/upgrade.test-d.d.ts.map +1 -0
  94. package/dist/utils/upgradeFromThreeToThreeOne.d.ts +1 -1
  95. package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +1 -1
  96. package/dist/utils/upgradeFromTwoToThree.d.ts +1 -1
  97. package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
  98. package/dist/utils/upgradeFromTwoToThree.js +1 -1
  99. package/dist/utils/validate.d.ts +2 -1
  100. package/dist/utils/validate.d.ts.map +1 -1
  101. package/package.json +37 -33
  102. package/dist/types/openapi-types.d.ts +0 -746
  103. package/dist/types/openapi-types.d.ts.map +0 -1
  104. package/dist/utils/openapi.d.ts +0 -183
  105. package/dist/utils/openapi.d.ts.map +0 -1
  106. package/dist/utils/openapi.js +0 -1
  107. package/dist/utils/workThroughQueue.d.ts +0 -11
  108. package/dist/utils/workThroughQueue.d.ts.map +0 -1
  109. package/dist/utils/workThroughQueue.js +0 -1
@@ -0,0 +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,aAAa,CAAA;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;GAEG;AACH,wBAAgB,OAAO,CAAC,aAAa,CAAC,EAAE,cAAc;kBASpC,sBAAsB,YAAY,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG9D"}
@@ -0,0 +1 @@
1
+ import{loadCommand as o}from"./commands/loadCommand.js";function n(n){const t={input:null,options:n,tasks:[]};return{load:(n,m)=>o(t,n,m)}}export{n as openapi};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=openapi.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.test-d.d.ts","sourceRoot":"","sources":["../../../src/utils/openapi/openapi.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { Queue, Task } from '../../../types';
2
+ /**
3
+ * Add a new task to the existing queue
4
+ */
5
+ export declare function queueTask<T extends Task[]>(queue: Queue, task: Task): Queue<T>;
6
+ //# sourceMappingURL=queueTask.d.ts.map
@@ -0,0 +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,gBAAgB,CAAA;AAEjD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAI7D,KAAK,CAAC,CAAC,CAAC,CACd"}
@@ -0,0 +1 @@
1
+ function t(t,s){return{...t,tasks:[...t.tasks,s]}}export{t as queueTask};
@@ -0,0 +1,6 @@
1
+ import type { CommandChain, Queue, Task } from '../../../types';
2
+ /**
3
+ * Takes a queue of tasks and works through them
4
+ */
5
+ export declare function workThroughQueue<T extends Task[]>(queue: Queue<T>): Promise<CommandChain<T>>;
6
+ //# sourceMappingURL=workThroughQueue.d.ts.map
@@ -0,0 +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,gBAAgB,CAAA;AAOtE;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,IAAI,EAAE,EACrD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GACd,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CA4E1B"}
@@ -0,0 +1 @@
1
+ import{dereference as o}from"../../dereference.js";import{filter as t}from"../../filter.js";import{load as e}from"../../load/load.js";import{upgrade as i}from"../../upgrade.js";import{validate as r}from"../../validate.js";async function a(a){const{input:n}={...a};let s={};for(const f of a.tasks){const a=f.name,p="options"in f?f.options:void 0,c=s.specification?s.specification:"object"==typeof n?structuredClone(n):n;"load"===a?s={...s,...await e(n,p)}:"filter"===a?s={...s,...t(c,p)}:"dereference"===a?s={...s,...await o(c,p)}:"upgrade"===a?s={...s,...i(c)}:"validate"===a&&(s={...s,...await r(c,p)})}return s}export{a as workThroughQueue};
@@ -1,4 +1,4 @@
1
- import { OpenAPI } from '../types';
1
+ import type { OpenAPI } from '@scalar/openapi-types';
2
2
  import type { AnyObject, ErrorObject, Filesystem, FilesystemEntry, ThrowOnErrorOption } from '../types';
3
3
  export type ResolveReferencesResult = {
4
4
  valid: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveReferences.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAejB,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA;CACzB,CAAA;AAOD;;GAEG;AACH,wBAAgB,iBAAiB,CAE/B,KAAK,EAAE,SAAS,GAAG,UAAU,EAE7B,OAAO,CAAC,EAAE,kBAAkB,EAE5B,IAAI,CAAC,EAAE,eAAe,EAEtB,MAAM,CAAC,EAAE,WAAW,EAAE,GACrB,uBAAuB,CA+FzB"}
1
+ {"version":3,"file":"resolveReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAejB,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAA;CACzB,CAAA;AAOD;;GAEG;AACH,wBAAgB,iBAAiB,CAE/B,KAAK,EAAE,SAAS,GAAG,UAAU,EAE7B,OAAO,CAAC,EAAE,kBAAkB,EAE5B,IAAI,CAAC,EAAE,eAAe,EAEtB,MAAM,CAAC,EAAE,WAAW,EAAE,GACrB,uBAAuB,CA+FzB"}
@@ -1,3 +1,3 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  export declare const toJson: (value: AnyObject) => string;
3
3
  //# sourceMappingURL=toJson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/utils/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,eAAO,MAAM,MAAM,UAAW,SAAS,WAAmC,CAAA"}
1
+ {"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../src/utils/toJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,eAAO,MAAM,MAAM,UAAW,SAAS,WAAmC,CAAA"}
@@ -1,3 +1,3 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  export declare const toYaml: (value: AnyObject) => string;
3
3
  //# sourceMappingURL=toYaml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toYaml.d.ts","sourceRoot":"","sources":["../../src/utils/toYaml.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,eAAO,MAAM,MAAM,UAAW,SAAS,WAAqB,CAAA"}
1
+ {"version":3,"file":"toYaml.d.ts","sourceRoot":"","sources":["../../src/utils/toYaml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,eAAO,MAAM,MAAM,UAAW,SAAS,WAAqB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  /**
3
3
  * Recursively traverses the specification and applies the transform function to each node.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/utils/traverse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC;;GAEG;AACH,wBAAgB,QAAQ,CACtB,aAAa,EAAE,SAAS,EACxB,SAAS,EAAE,CAAC,aAAa,EAAE,SAAS,KAAK,SAAS,aAqBnD"}
1
+ {"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/utils/traverse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;;GAEG;AACH,wBAAgB,QAAQ,CACtB,aAAa,EAAE,SAAS,EACxB,SAAS,EAAE,CAAC,aAAa,EAAE,SAAS,KAAK,SAAS,aAqBnD"}
@@ -1,6 +1,7 @@
1
+ import type { OpenAPIV3_1 } from '@scalar/openapi-types';
1
2
  import type { AnyObject, Filesystem, UpgradeResult } from '../types';
2
3
  /**
3
4
  * Upgrade specification to OpenAPI 3.1.0
4
5
  */
5
- export declare function upgrade(specification: AnyObject | Filesystem, _options?: AnyObject): UpgradeResult;
6
+ export declare function upgrade(value: string | AnyObject | Filesystem): UpgradeResult<OpenAPIV3_1.Document>;
6
7
  //# sourceMappingURL=upgrade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAMpE;;GAEG;AACH,wBAAgB,OAAO,CACrB,aAAa,EAAE,SAAS,GAAG,UAAU,EACrC,QAAQ,CAAC,EAAE,SAAS,GACnB,aAAa,CAcf"}
1
+ {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAMpE;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GACrC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAcrC"}
@@ -1 +1 @@
1
- import{getEntrypoint as r}from"./getEntrypoint.js";import{makeFilesystem as e}from"./makeFilesystem.js";import{upgradeFromThreeToThreeOne as o}from"./upgradeFromThreeToThreeOne.js";import{upgradeFromTwoToThree as i}from"./upgradeFromTwoToThree.js";function t(t,m){return{specification:[i,o].reduce(((r,e)=>e(r)),r(e(t)).specification),version:"3.1"}}export{t as upgrade};
1
+ import{getEntrypoint as r}from"./getEntrypoint.js";import{makeFilesystem as e}from"./makeFilesystem.js";import{upgradeFromThreeToThreeOne as o}from"./upgradeFromThreeToThreeOne.js";import{upgradeFromTwoToThree as i}from"./upgradeFromTwoToThree.js";function t(t){return{specification:[i,o].reduce(((r,e)=>e(r)),r(e(t)).specification),version:"3.1"}}export{t as upgrade};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=upgrade.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.test-d.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.test-d.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  /**
3
3
  * Upgrade from OpenAPI 3.0.x to 3.1.0
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,SAAS,aAkGlE"}
1
+ {"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,SAAS,aAkGlE"}
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  /**
3
3
  * Upgrade Swagger 2.0 to OpenAPI 3.0
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,aAG7D"}
1
+ {"version":3,"file":"upgradeFromTwoToThree.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromTwoToThree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,SAAS,aAoJ7D"}
@@ -1 +1 @@
1
- function n(n){return n}export{n as upgradeFromTwoToThree};
1
+ import{traverse as e}from"./traverse.js";function t(t){if(!t.swagger?.startsWith("2.0"))return t;if(t.openapi="3.0.3",delete t.swagger,console.warn("[upgradeFromTwoToThree] The upgrade from Swagger 2.0 to OpenAPI 3.0 documents is experimental and lacks features."),t.host){const e=t.schemes?.length?t.schemes:["http"];t.servers=e.map((e=>({url:`${e}://${t.host}${t.basePath??""}`}))),delete t.basePath,delete t.schemes,delete t.host}if(t.definitions&&("object"!=typeof t.components&&(t.components={}),t.components.schemas=t.definitions,delete t.definitions,t=e(t,(e=>(e.$ref?.startsWith("#/definitions/")&&(e.$ref=e.$ref.replace(/^#\/definitions\//,"#/components/schemas/")),e)))),t.paths)for(const e in t.paths)if(Object.hasOwn(t.paths,e)){const s=t.paths[e];for(const e in s)if(Object.hasOwn(s,e)){const o=s[e];if(o.parameters){const e=structuredClone(o.parameters.find((e=>"body"===e.in))??{});if(e&&Object.keys(e).length){delete e.name,delete e.in;const s=t.consumes??o.consumes??["application/json"];"object"!=typeof o.requestBody&&(o.requestBody={}),"object"!=typeof o.requestBody.content&&(o.requestBody.content={});const{schema:n,...r}=e;o.requestBody={...o.requestBody,...r};for(const e of s)o.requestBody.content[e]={schema:n}}o.parameters=o.parameters.filter((e=>"body"!==e.in)),delete o.consumes}if(o.responses)for(const e in o.responses)if(Object.hasOwn(o.responses,e)){const s=o.responses[e];if(s.schema){const e=t.produces??o.produces??["application/json"];"object"!=typeof s.content&&(s.content={});for(const t of e)s.content[t]={schema:s.schema};delete s.schema}}delete o.produces,0===o.parameters?.length&&delete o.parameters}}return t}export{t as upgradeFromTwoToThree};
@@ -1,6 +1,7 @@
1
1
  import type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../types';
2
+ export type ValidateOptions = ThrowOnErrorOption;
2
3
  /**
3
4
  * Validates an OpenAPI schema.
4
5
  */
5
- export declare function validate(value: string | AnyObject | Filesystem, options?: ThrowOnErrorOption): Promise<ValidateResult>;
6
+ export declare function validate(value: string | AnyObject | Filesystem, options?: ValidateOptions): Promise<ValidateResult>;
6
7
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,kBAAkB,EAClB,cAAc,EACf,MAAM,UAAU,CAAA;AAGjB;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAWzB"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/utils/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,UAAU,CAAA;AAGjB,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAEhD;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC,CAWzB"}
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@scalar/openapi-parser",
3
3
  "description": "modern OpenAPI parser written in TypeScript",
4
+ "license": "MIT",
5
+ "author": "Scalar (https://github.com/scalar)",
6
+ "homepage": "https://github.com/scalar/scalar",
7
+ "bugs": "https://github.com/scalar/scalar/issues/new/choose",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/scalar/scalar.git",
11
+ "directory": "packages/openapi-parser"
12
+ },
4
13
  "keywords": [
5
14
  "openapi",
6
15
  "scalar",
@@ -8,22 +17,12 @@
8
17
  "parser",
9
18
  "typescript"
10
19
  ],
11
- "license": "MIT",
12
- "author": "Scalar (https://github.com/scalar)",
13
- "homepage": "https://github.com/scalar/scalar",
14
- "bugs": "https://github.com/scalar/scalar/issues/new/choose",
15
- "version": "0.7.2",
20
+ "version": "0.8.2",
16
21
  "engines": {
17
22
  "node": ">=18"
18
23
  },
19
24
  "type": "module",
20
- "files": [
21
- "dist",
22
- "!dist/webpack-stats.json",
23
- "CHANGELOG.md"
24
- ],
25
25
  "main": "./dist/index.js",
26
- "module": "./dist/index.js",
27
26
  "types": "./dist/index.d.ts",
28
27
  "exports": {
29
28
  ".": {
@@ -36,40 +35,45 @@
36
35
  "import": "./dist/utils/load/plugins/readFiles.js"
37
36
  }
38
37
  },
38
+ "files": [
39
+ "dist",
40
+ "CHANGELOG.md"
41
+ ],
42
+ "module": "./dist/index.js",
39
43
  "sideEffects": false,
40
- "repository": {
41
- "type": "git",
42
- "url": "https://github.com/scalar/openapi-parser.git",
43
- "directory": "packages/openapi-parser"
44
+ "dependencies": {
45
+ "ajv": "^8.17.1",
46
+ "ajv-draft-04": "^1.0.0",
47
+ "ajv-formats": "^3.0.1",
48
+ "jsonpointer": "^5.0.1",
49
+ "leven": "^4.0.0",
50
+ "yaml": "^2.4.5"
44
51
  },
45
52
  "devDependencies": {
46
53
  "@apidevtools/swagger-parser": "^10.1.0",
54
+ "@babel/code-frame": "^7.24.7",
55
+ "@google-cloud/storage": "^7.12.1",
47
56
  "@rollup/plugin-json": "^6.1.0",
48
57
  "@rollup/plugin-terser": "^0.4.4",
49
58
  "@rollup/plugin-typescript": "^11.1.6",
50
- "@types/node": "^20.14.9",
51
- "glob": "^10.4.2",
59
+ "@types/node": "^20.14.10",
60
+ "glob": "^10.3.10",
61
+ "json-to-ast": "^2.1.0",
52
62
  "just-diff": "^6.0.2",
53
- "rollup": "^4.18.0",
54
- "rollup-plugin-output-size": "^1.4.0",
55
- "rollup-plugin-webpack-stats": "^1.0.1",
63
+ "rollup": "^4.16.4",
64
+ "rollup-plugin-output-size": "^1.4.1",
56
65
  "tinybench": "^2.8.0",
57
- "tsc-alias": "^1.8.10",
58
- "tslib": "^2.6.3",
59
- "typescript": "^5.5.3"
60
- },
61
- "dependencies": {
62
- "ajv": "^8.16.0",
63
- "ajv-draft-04": "^1.0.0",
64
- "ajv-formats": "^3.0.1",
65
- "jsonpointer": "^5.0.1",
66
- "leven": "^4.0.0",
67
- "yaml": "^2.4.5"
66
+ "@scalar/openapi-types": "0.1.1"
68
67
  },
69
68
  "scripts": {
70
- "types:check": "tsc --noEmit --skipLibCheck",
71
69
  "build": "pnpm types:check && rollup -c --configPlugin typescript && pnpm types:build",
70
+ "format": "prettier --write .",
71
+ "lint:check": "eslint .",
72
+ "lint:fix": "eslint . --fix",
73
+ "test": "vitest",
74
+ "test:prepare": "vite-node scripts/load-files.ts",
75
+ "test:unit": "vite-node scripts/load-files.ts && vitest",
72
76
  "types:build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
73
- "test": "vitest"
77
+ "types:check": "tsc --noEmit --skipLibCheck"
74
78
  }
75
79
  }