@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @scalar/openapi-parser
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 6bb85a5: feat: `openapi()` returns dynamic types based on the chained commands
8
+
9
+ ## 0.8.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 5bd8337: feat: upgrade from Swagger 2.0 (experimental)
14
+
15
+ ## 0.8.0
16
+
17
+ ### Minor Changes
18
+
19
+ - b4f9f97: feat: new @scalar/openapi-types package
20
+
21
+ ### Patch Changes
22
+
23
+ - b4f9f97: feat: add literal versions to OpenAPI.Document types
24
+ - b4f9f97: feat: types: allow to type custom extensions
25
+ - b4f9f97: feat: types: allow any attribute in schemas
26
+ - b231e7d: fix: upgrade returns correct OpenAPI document version type
27
+ - b4f9f97: feat: expose more types under the OpenAPI namespace
28
+
3
29
  ## 0.7.2
4
30
 
5
31
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Scalar
3
+ Copyright (c) 2023-present Scalar
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,25 +1,32 @@
1
1
  # Scalar OpenAPI Parser
2
2
 
3
- [![CI](https://github.com/scalar/openapi-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/scalar/openapi-parser/actions/workflows/ci.yml)
4
- [![Release](https://github.com/scalar/openapi-parser/actions/workflows/release.yml/badge.svg)](https://github.com/scalar/openapi-parser/actions/workflows/release.yml)
5
- [![Contributors](https://img.shields.io/github/contributors/scalar/openapi-parser)](https://github.com/scalar/openapi-parser/graphs/contributors)
6
- [![GitHub License](https://img.shields.io/github/license/scalar/openapi-parser)](https://github.com/scalar/openapi-parser/blob/main/LICENSE)
3
+ [![Version](https://img.shields.io/npm/v/%40scalar/openapi-parser)](https://www.npmjs.com/package/@scalar/openapi-parser)
4
+ [![Downloads](https://img.shields.io/npm/dm/%40scalar/openapi-parser)](https://www.npmjs.com/package/@scalar/openapi-parser)
5
+ [![License](https://img.shields.io/npm/l/%40scalar%2Fopenapi-parser)](https://www.npmjs.com/package/@scalar/openapi-parser)
7
6
  [![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)](https://discord.gg/scalar)
8
7
 
9
- Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1
8
+ Modern OpenAPI parser written in TypeScript with support for OpenAPI 3.1, OpenAPI 3.0 and Swagger 2.0.
9
+
10
+ ## Goals
11
+
12
+ - [x] Written in TypeScript
13
+ - [x] Runs in Node.js and in the browser (without any polyfills or configuration)
14
+ - [x] Tested with hundreds of real world examples
15
+ - [ ] Amazing error output
16
+ - [ ] Support for OpenAPI 4.0 👀
10
17
 
11
18
  ## Installation
12
19
 
13
- ```
20
+ ```bash
14
21
  npm add @scalar/openapi-parser
15
22
  ```
16
23
 
17
24
  ## Usage
18
25
 
19
- ### Parse
26
+ ### Validate
20
27
 
21
28
  ```ts
22
- import { dereference } from '@scalar/openapi-parser'
29
+ import { validate } from '@scalar/openapi-parser'
23
30
 
24
31
  const file = `{
25
32
  "openapi": "3.1.0",
@@ -30,15 +37,21 @@ const file = `{
30
37
  "paths": {}
31
38
  }`
32
39
 
33
- const result = await dereference(file)
40
+ const { valid, errors } = await validate(file)
41
+
42
+ console.log(valid)
43
+
44
+ if (!valid) {
45
+ console.log(errors)
46
+ }
34
47
  ```
35
48
 
36
- ### Validate
49
+ ### Resolve references
37
50
 
38
51
  ```ts
39
- import { validate } from '@scalar/openapi-parser'
52
+ import { dereference } from '@scalar/openapi-parser'
40
53
 
41
- const file = `{
54
+ const specification = `{
42
55
  "openapi": "3.1.0",
43
56
  "info": {
44
57
  "title": "Hello World",
@@ -47,21 +60,15 @@ const file = `{
47
60
  "paths": {}
48
61
  }`
49
62
 
50
- const { valid, errors } = await validate(file)
51
-
52
- console.log(valid)
53
-
54
- if (!valid) {
55
- console.log(errors)
56
- }
63
+ const { schema, errors } = await dereference(specification)
57
64
  ```
58
65
 
59
- ### Version
66
+ ### Modify an OpenAPI specification
60
67
 
61
68
  ```ts
62
- import { dereference } from '@scalar/openapi-parser'
69
+ import { filter } from '@scalar/openapi-parser'
63
70
 
64
- const file = `{
71
+ const specification = `{
65
72
  "openapi": "3.1.0",
66
73
  "info": {
67
74
  "title": "Hello World",
@@ -70,7 +77,169 @@ const file = `{
70
77
  "paths": {}
71
78
  }`
72
79
 
73
- const { version } = await dereference(file)
80
+ const { specification } = filter(specification, (schema) => !schema?.['x-internal'])
81
+ ```
82
+
83
+ ### Upgrade your OpenAPI specification
84
+
85
+ There’s an `upgrade` command to upgrade all your OpenAPI specifications to the latest OpenAPI version.
86
+
87
+ > ⚠️ The upgrade from Swagger 2.0 is still experimental and probably lacks features.
88
+
89
+ ```ts
90
+ import { upgrade } from '@scalar/openapi-parser'
91
+
92
+ const { specification } = upgrade({
93
+ swagger: '2.0',
94
+ info: {
95
+ title: 'Hello World',
96
+ version: '1.0.0',
97
+ },
98
+ paths: {},
99
+ })
100
+
101
+ console.log(specification.openapi)
102
+ // Output: 3.1.0
103
+ ```
74
104
 
75
- console.log(version)
105
+ ### Pipeline syntax
106
+
107
+ ```ts
108
+ import { openapi } from '@scalar/openapi-parser'
109
+
110
+ const specification = …
111
+
112
+ // New pipeline …
113
+ const result = openapi()
114
+ // loads the specification …
115
+ .load(specification)
116
+ // upgrades to OpenAPI 3.1 …
117
+ .upgrade()
118
+ // removes all internal operations …
119
+ .filter((schema) => !schema?.['x-internal'])
120
+ // done!
121
+ .get()
76
122
  ```
123
+
124
+ ### Then/Catch syntax
125
+
126
+ If you’re more the then/catch type of guy, that’s fine:
127
+
128
+ ```ts
129
+ import { validate } from '@scalar/openapi-parser'
130
+
131
+ const specification = …
132
+
133
+ validate(specification, {
134
+ throwOnError: true,
135
+ })
136
+ .then(result => {
137
+ // Success
138
+ })
139
+ .catch(error => {
140
+ // Failure
141
+ })
142
+ ```
143
+
144
+ ### TypeScript
145
+
146
+ If you just look for our types, you can install the package separately:
147
+
148
+ ```bash
149
+ npm add @scalar/openapi-types
150
+ ```
151
+
152
+ And use it like this:
153
+
154
+ ```ts
155
+ import type { OpenAPI } from '@scalar/openapi-types'
156
+
157
+ const file: OpenAPI.Document = {
158
+ openapi: '3.1.0',
159
+ info: {
160
+ title: 'Hello World',
161
+ version: '1.0.0',
162
+ },
163
+ paths: {},
164
+ }
165
+ ```
166
+
167
+ ### Advanced: URL and file references
168
+
169
+ You can reference other files, too. To do that, the parser needs to know what files are available.
170
+
171
+ ```ts
172
+ import { dereference, load } from '@scalar/openapi-parser'
173
+ import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls'
174
+ import { readFiles } from '@scalar/openapi-parser/plugins/read-files'
175
+
176
+ // Load a file and all referenced files
177
+ const { filesystem } = await load('./openapi.yaml', {
178
+ plugins: [
179
+ readFiles(),
180
+ fetchUrls({
181
+ limit: 5,
182
+ }),
183
+ ],
184
+ })
185
+
186
+ // Instead of just passing a single specification, pass the whole “filesystem”
187
+ const result = await dereference(filesystem)
188
+ ```
189
+
190
+ As you see, `load()` supports plugins. You can write your own plugin, if you’d like to fetch API defintions from another data source, for example your database. Look at the source code of the `readFiles` to learn how this could look like.
191
+
192
+ #### Directly load URLs
193
+
194
+ Once the `fetchUrls` plugin is loaded, you can also just pass an URL:
195
+
196
+ ```ts
197
+ import { dereference, load } from '@scalar/openapi-parser'
198
+ import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls'
199
+
200
+ // Load a file and all referenced files
201
+ const { filesystem } = await load(
202
+ 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml',
203
+ {
204
+ plugins: [fetchUrls()],
205
+ },
206
+ )
207
+ ```
208
+
209
+ #### Intercept HTTP requests
210
+
211
+ If you’re using the package in a browser environment, you may run into CORS issues when fetching from URLs. You can intercept the requests, for example to use a proxy, though:
212
+
213
+ ```ts
214
+ import { dereference, load } from '@scalar/openapi-parser'
215
+ import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls'
216
+
217
+ // Load a file and all referenced files
218
+ const { filesystem } = await load(
219
+ 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.yaml',
220
+ {
221
+ plugins: [
222
+ fetchUrls({
223
+ fetch: (url) => fetch(url.replace('BANANA.net', 'jsdelivr.net')),
224
+ }).get('https://cdn.BANANA.net/npm/@scalar/galaxy/dist/latest.yaml'),
225
+ ],
226
+ },
227
+ )
228
+ ```
229
+
230
+ ## Community
231
+
232
+ We are API nerds. You too? Let’s chat on Discord: <https://discord.gg/scalar>
233
+
234
+ ## Thank you!
235
+
236
+ Thanks a ton for all the help and inspiration:
237
+
238
+ - [@philsturgeon](https://github.com/philsturgeon) to make sure we build something we won’t hate.
239
+ - We took a lot of inspiration from [@seriousme](https://github.com/seriousme) and his package [openapi-schema-validator](https://github.com/seriousme/openapi-schema-validator) early-on.
240
+ - You could consider this package the modern successor of [@apidevtools/swagger-parser](https://github.com/APIDevTools/swagger-parser), we even test against it to make sure we’re getting the same results (where intended).
241
+ - We stole a lot of example specification from [@mermade](https://github.com/mermade) to test against.
242
+
243
+ ## License
244
+
245
+ The source code in this repository is licensed under [MIT](https://github.com/scalar/openapi-parser/blob/main/LICENSE).
@@ -3903,6 +3903,7 @@ export declare const ERRORS: {
3903
3903
  readonly INVALID_REFERENCE: "Can’t resolve reference: %s";
3904
3904
  readonly EXTERNAL_REFERENCE_NOT_FOUND: "Can’t resolve external reference: %s";
3905
3905
  readonly FILE_DOES_NOT_EXIST: "File does not exist: %s";
3906
+ readonly NO_CONTENT: "No content found";
3906
3907
  };
3907
- export type VALIDATOR_ERROR = keyof typeof ERRORS;
3908
+ export type ValidationError = keyof typeof ERRORS;
3908
3909
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIjC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,qBAAqB,CAAA;AAE/D,eAAO,MAAM,eAAe,EAEvB,cAAc,EAAE,CAAA;AAErB;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;CAST,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,MAAM,CAAA"}
@@ -1 +1 @@
1
- import e from"../schemas/v2.0/schema.json.js";import s from"../schemas/v3.0/schema.json.js";import n from"../schemas/v3.1/schema.json.js";const o={"2.0":e,"3.0":s,3.1:n},r=Object.keys(o),t={EMPTY_OR_INVALID:"Can’t find JSON, YAML or filename in data",OPENAPI_VERSION_NOT_SUPPORTED:"Can’t find supported Swagger/OpenAPI version in specification, version must be a string.",INVALID_REFERENCE:"Can’t resolve reference: %s",EXTERNAL_REFERENCE_NOT_FOUND:"Can’t resolve external reference: %s",FILE_DOES_NOT_EXIST:"File does not exist: %s"};export{t as ERRORS,o as OpenApiSpecifications,r as OpenApiVersions};
1
+ import e from"../schemas/v2.0/schema.json.js";import s from"../schemas/v3.0/schema.json.js";import n from"../schemas/v3.1/schema.json.js";const o={"2.0":e,"3.0":s,3.1:n},r=Object.keys(o),t={EMPTY_OR_INVALID:"Can’t find JSON, YAML or filename in data",OPENAPI_VERSION_NOT_SUPPORTED:"Can’t find supported Swagger/OpenAPI version in specification, version must be a string.",INVALID_REFERENCE:"Can’t resolve reference: %s",EXTERNAL_REFERENCE_NOT_FOUND:"Can’t resolve external reference: %s",FILE_DOES_NOT_EXIST:"File does not exist: %s",NO_CONTENT:"No content found"};export{t as ERRORS,o as OpenApiSpecifications,r as OpenApiVersions};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{ERRORS,OpenApiSpecifications,OpenApiVersions}from"./configuration/index.js";export{Validator,jsonSchemaVersions}from"./lib/Validator/Validator.js";export{resolveReferences}from"./utils/resolveReferences.js";export{dereference}from"./utils/dereference.js";export{details}from"./utils/details.js";export{escapeJsonPointer}from"./utils/escapeJsonPointer.js";export{filter}from"./utils/filter.js";export{getEntrypoint}from"./utils/getEntrypoint.js";export{getListOfReferences}from"./utils/getListOfReferences.js";export{getSegmentsFromPath}from"./utils/getSegmentsFromPath.js";export{isFilesystem}from"./utils/isFilesystem.js";export{isJson}from"./utils/isJson.js";export{isObject}from"./utils/isObject.js";export{isYaml}from"./utils/isYaml.js";export{load}from"./utils/load/load.js";export{normalize}from"./utils/normalize.js";export{openapi}from"./utils/openapi.js";export{toJson}from"./utils/toJson.js";export{toYaml}from"./utils/toYaml.js";export{transformErrors}from"./utils/transformErrors.js";export{traverse}from"./utils/traverse.js";export{unescapeJsonPointer}from"./utils/unescapeJsonPointer.js";export{upgrade}from"./utils/upgrade.js";export{upgradeFromThreeToThreeOne}from"./utils/upgradeFromThreeToThreeOne.js";export{upgradeFromTwoToThree}from"./utils/upgradeFromTwoToThree.js";export{validate}from"./utils/validate.js";
1
+ export{ERRORS,OpenApiSpecifications,OpenApiVersions}from"./configuration/index.js";export{Validator,jsonSchemaVersions}from"./lib/Validator/Validator.js";export{resolveReferences}from"./utils/resolveReferences.js";export{dereference}from"./utils/dereference.js";export{details}from"./utils/details.js";export{escapeJsonPointer}from"./utils/escapeJsonPointer.js";export{filter}from"./utils/filter.js";export{getEntrypoint}from"./utils/getEntrypoint.js";export{getListOfReferences}from"./utils/getListOfReferences.js";export{getSegmentsFromPath}from"./utils/getSegmentsFromPath.js";export{isFilesystem}from"./utils/isFilesystem.js";export{isJson}from"./utils/isJson.js";export{isObject}from"./utils/isObject.js";export{isYaml}from"./utils/isYaml.js";export{load}from"./utils/load/load.js";export{normalize}from"./utils/normalize.js";export{openapi}from"./utils/openapi/openapi.js";export{toJson}from"./utils/toJson.js";export{toYaml}from"./utils/toYaml.js";export{transformErrors}from"./utils/transformErrors.js";export{traverse}from"./utils/traverse.js";export{unescapeJsonPointer}from"./utils/unescapeJsonPointer.js";export{upgrade}from"./utils/upgrade.js";export{upgradeFromThreeToThreeOne}from"./utils/upgradeFromThreeToThreeOne.js";export{upgradeFromTwoToThree}from"./utils/upgradeFromTwoToThree.js";export{validate}from"./utils/validate.js";
@@ -10,7 +10,7 @@ export declare const jsonSchemaVersions: {
10
10
  'https://json-schema.org/draft/2020-12/schema': typeof Ajv2020;
11
11
  };
12
12
  export declare class Validator {
13
- version: string;
13
+ version: '2.0' | '3.0' | '3.1';
14
14
  static supportedVersions: ("2.0" | "3.0" | "3.1")[];
15
15
  protected ajvValidators: Record<string, ((specification: AnyObject) => boolean) & {
16
16
  errors: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,OAAO,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,aAAa,CAAA;AAKpB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,qBAAa,SAAS;IACb,OAAO,EAAE,MAAM,CAAA;IAEtB,OAAc,iBAAiB,4BAAkB;IAGjD,SAAS,CAAC,aAAa,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,CAAC,aAAa,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG;QACxC,MAAM,EAAE,MAAM,CAAA;KACf,CACF,CAAK;IAEN,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAEtC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAE5B,aAAa,EAAE,SAAS,CAAA;IAE/B;;OAEG;IACG,QAAQ,CACZ,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC;IAgF1B;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc;CA8B9C"}
1
+ {"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,OAAO,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,aAAa,CAAA;AAKpB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,qBAAa,SAAS;IACb,OAAO,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;IAErC,OAAc,iBAAiB,4BAAkB;IAGjD,SAAS,CAAC,aAAa,EAAE,MAAM,CAC7B,MAAM,EACN,CAAC,CAAC,aAAa,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG;QACxC,MAAM,EAAE,MAAM,CAAA;KACf,CACF,CAAK;IAEN,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAEtC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAE5B,aAAa,EAAE,SAAS,CAAA;IAE/B;;OAEG;IACG,QAAQ,CACZ,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,cAAc,CAAC;IAwF1B;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc;CA8B9C"}
@@ -1 +1 @@
1
- import r from"ajv-draft-04";import i from"ajv-formats";import s from"ajv/dist/2020.js";import{OpenApiVersions as t,ERRORS as o,OpenApiSpecifications as e}from"../../configuration/index.js";import{details as a}from"../../utils/details.js";import{resolveReferences as n}from"../../utils/resolveReferences.js";import{transformErrors as c}from"../../utils/transformErrors.js";const f={"http://json-schema.org/draft-04/schema#":r,"https://json-schema.org/draft/2020-12/schema":s};class p{version;static supportedVersions=t;ajvValidators={};errors;specificationVersion;specificationType;specification;async validate(r,i){const s=r.find((r=>r.isEntrypoint)),t=s?.specification;this.specification=t,this.specification?.info&&!this.specification.info.version&&(this.specification.info.version="0.0.1");try{if(null==t){if(i?.throwOnError)throw new Error(o.EMPTY_OR_INVALID);return{valid:!1,errors:c(s,o.EMPTY_OR_INVALID)}}const{version:e,specificationType:f,specificationVersion:p}=a(t);if(this.version=e,this.specificationVersion=p,this.specificationType=f,!e)return{valid:!1,errors:c(s,o.OPENAPI_VERSION_NOT_SUPPORTED)};const m=await this.getAjvValidator(e),h=m(t);if(m.errors&&m.errors.length>0)return{valid:!1,errors:c(s,m.errors)};const d=n(r,i);return{valid:h&&d.valid,errors:[...h.errors??[],...d.errors],schema:d.schema}}catch(r){if(i?.throwOnError)throw r;return{valid:!1,errors:c(s,r.message??r)}}}async getAjvValidator(r){if(this.ajvValidators[r])return this.ajvValidators[r];const s=e[r],t=new(0,f[s.$schema])({strict:!1});return i(t),"3.1"===r&&t.addFormat("media-range",!0),this.ajvValidators[r]=t.compile(s)}}export{p as Validator,f as jsonSchemaVersions};
1
+ import r from"ajv-draft-04";import i from"ajv-formats";import o from"ajv/dist/2020.js";import{OpenApiVersions as s,ERRORS as t,OpenApiSpecifications as e}from"../../configuration/index.js";import{details as a}from"../../utils/details.js";import{resolveReferences as n}from"../../utils/resolveReferences.js";import{transformErrors as c}from"../../utils/transformErrors.js";const f={"http://json-schema.org/draft-04/schema#":r,"https://json-schema.org/draft/2020-12/schema":o};class h{version;static supportedVersions=s;ajvValidators={};errors;specificationVersion;specificationType;specification;async validate(r,i){const o=r.find((r=>r.isEntrypoint)),s=o?.specification;this.specification=s,this.specification?.info&&!this.specification.info.version&&(this.specification.info.version="0.0.1");try{if(null==s){if(i?.throwOnError)throw new Error(t.EMPTY_OR_INVALID);return{valid:!1,errors:c(o,t.EMPTY_OR_INVALID)}}const{version:e,specificationType:f,specificationVersion:h}=a(s);if(this.version=e,this.specificationVersion=h,this.specificationType=f,!e){if(i?.throwOnError)throw new Error(t.OPENAPI_VERSION_NOT_SUPPORTED);return{valid:!1,errors:c(o,t.OPENAPI_VERSION_NOT_SUPPORTED)}}const p=await this.getAjvValidator(e),m=p(s);if(p.errors&&p.errors.length>0){if(i?.throwOnError)throw new Error(p.errors[0]);return{valid:!1,errors:c(o,p.errors)}}const d=n(r,i);return{valid:m&&d.valid,errors:[...m.errors??[],...d.errors],schema:d.schema}}catch(r){if(i?.throwOnError)throw r;return{valid:!1,errors:c(o,r.message??r)}}}async getAjvValidator(r){if(this.ajvValidators[r])return this.ajvValidators[r];const o=e[r],s=new(0,f[o.$schema])({strict:!1});return i(s),"3.1"===r&&s.addFormat("media-range",!0),this.ajvValidators[r]=s.compile(o)}}export{h as Validator,f as jsonSchemaVersions};
@@ -1,10 +1,10 @@
1
- export declare function resolve(): string;
1
+ export declare function resolve(...parameters: any[]): string;
2
2
  export declare function normalize(path: any): string;
3
3
  export declare function isAbsolute(path: any): boolean;
4
4
  export declare function join(...paths: string[]): string;
5
5
  export declare function relative(from: any, to: any): string;
6
- export declare var sep: string;
7
- export declare var delimiter: string;
6
+ export declare const sep = "/";
7
+ export declare const delimiter = ":";
8
8
  export declare function dirname(path: any): string;
9
9
  export declare function basename(path: any, ext: any): string;
10
10
  export declare function extname(path: any): string;
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"AA+DA,wBAAgB,OAAO,WA8BtB;AAID,wBAAgB,SAAS,CAAC,IAAI,KAAA,UAoB7B;AAGD,wBAAgB,UAAU,CAAC,IAAI,KAAA,WAE9B;AAGD,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,UAStC;AAID,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,EAAE,KAAA,UAuChC;AAED,eAAO,IAAI,GAAG,QAAM,CAAA;AACpB,eAAO,IAAI,SAAS,QAAM,CAAA;AAE1B,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAgB3B;AAED,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,UAOjC;AAED,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAE3B;;;;;;;;;;;;;AACD,wBAWC"}
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"AA8DA,wBAAgB,OAAO,CAAC,GAAG,UAAU,OAAA,UA8BpC;AAID,wBAAgB,SAAS,CAAC,IAAI,KAAA,UAoB7B;AAGD,wBAAgB,UAAU,CAAC,IAAI,KAAA,WAE9B;AAGD,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,UAStC;AAID,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,EAAE,KAAA,UAuChC;AAED,eAAO,MAAM,GAAG,MAAM,CAAA;AACtB,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAiB3B;AAED,wBAAgB,QAAQ,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,UAOjC;AAED,wBAAgB,OAAO,CAAC,IAAI,KAAA,UAE3B;;;;;;;;;;;;;AACD,wBAWC"}
@@ -1 +1 @@
1
- var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;function n(r){var n=t(r),e="/"===o(r,-1);return(r=function(r,n){for(var t=0,e=r.length-1;e>=0;e--){var u=r[e];"."===u?r.splice(e,1):".."===u?(r.splice(e,1),t++):t&&(r.splice(e,1),t--)}if(n)for(;t--;t)r.unshift("..");return r}(i(r.split("/"),(function(r){return!!r})),!n).join("/"))||n||(r="."),r&&e&&(r+="/"),(n?"/":"")+r}function t(r){return"/"===r.charAt(0)}function e(...r){return n(i(r,(function(r,n){if("string"!=typeof r)throw new TypeError("Arguments to path.join must be strings");return r})).join("/"))}function u(n){var t,e=(t=n,r.exec(t).slice(1)),u=e[0],i=e[1];return u||i?(i&&(i=i.substr(0,i.length-1)),u+i):"."}function i(r,n){if(r.filter)return r.filter(n);for(var t=[],e=0;e<r.length;e++)n(r[e],e,r)&&t.push(r[e]);return t}var o="b"==="ab".substr(-1)?function(r,n,t){return r.substr(n,t)}:function(r,n,t){return n<0&&(n=r.length+n),r.substr(n,t)};export{u as dirname,t as isAbsolute,e as join,n as normalize};
1
+ const t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/;function n(t){const n=r(t),e="/"===s(t,-1);return(t=function(t,n){let r=0;for(let n=t.length-1;n>=0;n--){const e=t[n];"."===e?t.splice(n,1):".."===e?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(n)for(;r--;r)t.unshift("..");return t}(o(t.split("/"),(function(t){return!!t})),!n).join("/"))||n||(t="."),t&&e&&(t+="/"),(n?"/":"")+t}function r(t){return"/"===t.charAt(0)}function e(...t){return n(o(t,(function(t,n){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))}function u(n){const r=(u=n,t.exec(u).slice(1)),e=r[0];var u;let o=r[1];return e||o?(o&&(o=o.substr(0,o.length-1)),e+o):"."}function o(t,n){if(t.filter)return t.filter(n);const r=[];for(let e=0;e<t.length;e++)n(t[e],e,t)&&r.push(t[e]);return r}const s="b"==="ab".substr(-1)?function(t,n,r){return t.substr(n,r)}:function(t,n,r){return n<0&&(n=t.length+n),t.substr(n,r)};export{u as dirname,r as isAbsolute,e as join,n as normalize};
@@ -1,23 +1,32 @@
1
- import { ERRORS, OpenApiVersion } from '../configuration/index.js';
2
- import type { OpenAPI } from './openapi-types';
3
- export type { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, } from './openapi-types';
1
+ import type { OpenAPI } from '@scalar/openapi-types';
2
+ import type { ERRORS, OpenApiVersion } from '../configuration/index.js';
3
+ /**
4
+ * Merge types with each other
5
+ */
6
+ export type Merge<A, B> = A & Omit<B, keyof A>;
4
7
  export type AnyObject = Record<string, any>;
8
+ /**
9
+ * JSON, YAML or object representation of an OpenAPI API definition
10
+ */
11
+ export type AnyApiDefinitionFormat = string | AnyObject;
5
12
  export type LoadResult = {
6
13
  filesystem: Filesystem;
14
+ specification: AnyObject;
15
+ errors?: ErrorObject[];
7
16
  };
8
17
  export type ValidateResult = {
9
18
  valid: boolean;
10
19
  specification?: OpenAPI.Document;
11
- version?: string;
20
+ version?: OpenApiVersion;
12
21
  errors?: ErrorObject[];
13
22
  schema?: OpenAPI.Document;
14
23
  };
15
- export type UpgradeResult = {
16
- specification: OpenAPI.Document;
17
- version: string;
24
+ export type UpgradeResult<T extends OpenAPI.Document = OpenAPI.Document> = {
25
+ specification: T;
26
+ version: '3.1';
18
27
  };
19
28
  export type FilterResult = {
20
- specification: OpenAPI.Document;
29
+ specification: AnyObject;
21
30
  };
22
31
  export type DetailsResult = {
23
32
  version: OpenApiVersion;
@@ -25,7 +34,7 @@ export type DetailsResult = {
25
34
  specificationVersion: string;
26
35
  };
27
36
  export type DereferenceResult = {
28
- version: string | undefined;
37
+ version?: OpenApiVersion;
29
38
  specification?: OpenAPI.Document;
30
39
  schema?: OpenAPI.Document;
31
40
  errors?: ErrorObject[];
@@ -52,6 +61,10 @@ export type FilesystemEntry = {
52
61
  filename: string;
53
62
  specification: AnyObject;
54
63
  };
64
+ /**
65
+ * Options, that can apply to all commands
66
+ */
67
+ export type OpenApiOptions = ThrowOnErrorOption;
55
68
  export type ThrowOnErrorOption = {
56
69
  /**
57
70
  * If `true`, the function will throw an error if the document is invalid.
@@ -60,4 +73,60 @@ export type ThrowOnErrorOption = {
60
73
  */
61
74
  throwOnError?: boolean;
62
75
  };
76
+ declare global {
77
+ /**
78
+ * Available commands, can be extended dynamically
79
+ */
80
+ interface Commands {
81
+ }
82
+ }
83
+ /**
84
+ * Input and a list of tasks to pipe the input through.
85
+ */
86
+ export type Queue<T extends readonly Task[] = readonly Task[]> = {
87
+ /** The original input, can be a JSON or YAML string or an object */
88
+ input: AnyApiDefinitionFormat;
89
+ /** The current OpenAPI document, but as an object */
90
+ specification: AnyObject;
91
+ /** Global options */
92
+ options?: OpenApiOptions;
93
+ /** Queued tasks */
94
+ tasks: T;
95
+ };
96
+ /**
97
+ * Available tasks, populated from the global Commands interface
98
+ */
99
+ export type Task = Commands[keyof Commands]['task'];
100
+ export type EmptyCommandChainResult = {
101
+ filesystem: Filesystem;
102
+ specification: AnyObject;
103
+ };
104
+ /**
105
+ * Command chain magic
106
+ *
107
+ * This type recursively builds a merged type based on the sequence of tasks.
108
+ *
109
+ * How it works:
110
+ * 1. It uses a conditional type with recursion to process the task array.
111
+ * 2. For each iteration:
112
+ * a. It extracts the first task (First) and the rest of the tasks (Rest).
113
+ * b. It checks if First is a valid Task and Rest is a Task array.
114
+ * c. If valid, it merges the Command type for the First task with the
115
+ * result of recursively processing the Rest of the tasks.
116
+ * 3. The recursion continues until the task array is empty.
117
+ * 4. When empty, it returns NonNullable<unknown> (equivalent to {}).
118
+ *
119
+ * Example:
120
+ * For tasks ['load', 'validate']:
121
+ * 1st iteration: Merge<Commands['load'], CommandChain<['validate']>>
122
+ * 2nd iteration: Merge<Commands['load'], Merge<Commands['validate'], NonNullable<unknown>>>
123
+ * Result: LoadResult & ValidateResult
124
+ *
125
+ * This type enables the API to correctly infer the return type based on
126
+ * the sequence of method calls in the fluent interface.
127
+ */
128
+ export type CommandChain<T extends Task[]> = T extends [
129
+ infer First,
130
+ ...infer Rest
131
+ ] ? First extends Task ? Rest extends Task[] ? Merge<Commands[First['name']]['result'], CommandChain<Rest>> : never : never : EmptyCommandChainResult;
63
132
  //# sourceMappingURL=index.d.ts.map
@@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":"","sources":["../../../src/utils/betterAjvErrors/helpers.ts"],"names":[],"mappings":"AAwBA,wBAAgB,QAAQ,CAAC,SAAS,QAAK;;EAsBtC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,GAAG,KAAA,QA+CtD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,OAmCjD;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,OAKlD"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/betterAjvErrors/helpers.ts"],"names":[],"mappings":"AAuBA,wBAAgB,QAAQ,CAAC,SAAS,QAAK;;EAsBtC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,GAAG,KAAA,QA+CtD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,OAmCjD;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,OAKlD"}
@@ -1 +1 @@
1
- import{getErrors as r,isRequiredError as e,isAnyOfError as t,isEnumError as n,getSiblings as o,notUndefined as a,concatAll as i,getChildren as c}from"./utils.js";import s from"./validation-errors/additional-prop.js";import d from"./validation-errors/default.js";import l from"./validation-errors/enum.js";import u from"./validation-errors/pattern.js";import h from"./validation-errors/required.js";import m from"./validation-errors/unevaluated-prop.js";const p=/\/[\w_-]+(\/\d+)?/g;function f(r=[]){const e={children:{}};return r.forEach((r=>{const t=void 0!==r.instancePath?r.instancePath:r.dataPath,n=""===t?[""]:t.match(p);n&&n.reduce(((e,t,o)=>(e.children[t]=e.children[t]||{children:{},errors:[]},o===n.length-1&&e.children[t].errors.push(r),e.children[t])),e)})),e}function w(i,c,s){r(i).forEach((r=>{e(r)&&(i.errors=[r],i.children={})})),r(i).some(t)&&Object.keys(i.children).length>0&&delete i.errors,i.errors&&i.errors.length&&r(i).every(n)&&o(c)(i).filter(a).some(r)&&delete c.children[s],Object.entries(i.children).forEach((([r,e])=>w(e,i,r)))}function v(e,t){const o=r(e);if(o.length&&o.every(n)){const r=[...new Set(i([])(o.map((r=>r.params.allowedValues))))],e=o[0];return[new l({...e,params:{allowedValues:r}},t)]}return i(o.reduce(((r,e)=>{switch(e.keyword){case"additionalProperties":return r.concat(new s(e,t));case"pattern":return r.concat(new u(e,t));case"required":return r.concat(new h(e,t));case"unevaluatedProperties":return r.concat(new m(e,t));default:return r.concat(new d(e,t))}}),[]))(c(e).map((r=>v(r,t))))}function j(r,e){const t=f(r||[]);return w(t),v(t,e)}export{v as createErrorInstances,j as default,w as filterRedundantErrors,f as makeTree};
1
+ import{getErrors as r,isRequiredError as e,isAnyOfError as t,isEnumError as n,getSiblings as o,notUndefined as a,concatAll as i,getChildren as c}from"./utils.js";import s from"./validation-errors/additional-prop.js";import d from"./validation-errors/default.js";import l from"./validation-errors/enum.js";import u from"./validation-errors/pattern.js";import h from"./validation-errors/required.js";import m from"./validation-errors/unevaluated-prop.js";const p=/\/[\w_-]+(\/\d+)?/g;function f(r=[]){const e={children:{}};return r.forEach((r=>{const t=void 0!==r.instancePath?r.instancePath:r.dataPath,n=""===t?[""]:t.match(p);n&&n.reduce(((e,t,o)=>(e.children[t]=e.children[t]||{children:{},errors:[]},o===n.length-1&&e.children[t].errors.push(r),e.children[t])),e)})),e}function w(i,c,s){r(i).forEach((r=>{e(r)&&(i.errors=[r],i.children={})})),r(i).some(t)&&Object.keys(i.children).length>0&&delete i.errors,i.errors?.length&&r(i).every(n)&&o(c)(i).filter(a).some(r)&&delete c.children[s],Object.entries(i.children).forEach((([r,e])=>w(e,i,r)))}function v(e,t){const o=r(e);if(o.length&&o.every(n)){const r=[...new Set(i([])(o.map((r=>r.params.allowedValues))))],e=o[0];return[new l({...e,params:{allowedValues:r}},t)]}return i(o.reduce(((r,e)=>{switch(e.keyword){case"additionalProperties":return r.concat(new s(e,t));case"pattern":return r.concat(new u(e,t));case"required":return r.concat(new h(e,t));case"unevaluatedProperties":return r.concat(new m(e,t));default:return r.concat(new d(e,t))}}),[]))(c(e).map((r=>v(r,t))))}function j(r,e){const t=f(r||[]);return w(t),v(t,e)}export{v as createErrorInstances,j as default,w as filterRedundantErrors,f as makeTree};
@@ -1,6 +1,7 @@
1
- import type { AnyObject, DereferenceResult, Filesystem, ThrowOnErrorOption } from '../types';
1
+ import type { AnyApiDefinitionFormat, DereferenceResult, Filesystem, ThrowOnErrorOption } from '../types';
2
+ export type DereferenceOptions = ThrowOnErrorOption;
2
3
  /**
3
4
  * Validates an OpenAPI schema and resolves all references.
4
5
  */
5
- export declare function dereference(value: string | AnyObject | Filesystem, options?: ThrowOnErrorOption): Promise<DereferenceResult>;
6
+ export declare function dereference(value: AnyApiDefinitionFormat | Filesystem, options?: DereferenceOptions): Promise<DereferenceResult>;
6
7
  //# sourceMappingURL=dereference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dereference.d.ts","sourceRoot":"","sources":["../../src/utils/dereference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAMjB;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,EACtC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
1
+ {"version":3,"file":"dereference.d.ts","sourceRoot":"","sources":["../../src/utils/dereference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EAEtB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAMjB,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAA;AAEnD;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,sBAAsB,GAAG,UAAU,EAC1C,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
@@ -1,6 +1,7 @@
1
- import type { AnyObject, FilterResult } from '../types';
1
+ import type { AnyApiDefinitionFormat, AnyObject, FilterResult } from '../types';
2
+ export type FilterCallback = (schema: AnyObject) => boolean;
2
3
  /**
3
4
  * Filter the specification based on the callback
4
5
  */
5
- export declare function filter(specification: AnyObject, callback: (schema: AnyObject) => boolean): FilterResult;
6
+ export declare function filter(specification: AnyApiDefinitionFormat, callback: FilterCallback): FilterResult;
6
7
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAKvD;;GAEG;AACH,wBAAgB,MAAM,CACpB,aAAa,EAAE,SAAS,EACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,GACvC,YAAY,CAWd"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAK/E,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAA;AAE3D;;GAEG;AACH,wBAAgB,MAAM,CACpB,aAAa,EAAE,sBAAsB,EACrC,QAAQ,EAAE,cAAc,GACvB,YAAY,CAWd"}
@@ -1,6 +1,6 @@
1
- import type { Filesystem } from '../types';
1
+ import type { Filesystem, FilesystemEntry } from '../types';
2
2
  /**
3
3
  * Return just the entrypoint of the filesystem.
4
4
  */
5
- export declare function getEntrypoint(filesystem: Filesystem): import("../types").FilesystemEntry;
5
+ export declare function getEntrypoint(filesystem?: Filesystem): FilesystemEntry | undefined;
6
6
  //# sourceMappingURL=getEntrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEntrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/getEntrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,sCAEnD"}
1
+ {"version":3,"file":"getEntrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/getEntrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE3D;;GAEG;AACH,wBAAgB,aAAa,CAC3B,UAAU,CAAC,EAAE,UAAU,GACtB,eAAe,GAAG,SAAS,CAE7B"}
@@ -1 +1 @@
1
- function n(n){return n.find((n=>n.isEntrypoint))}export{n as getEntrypoint};
1
+ function n(n){return n?.find((n=>n.isEntrypoint))}export{n as getEntrypoint};
@@ -1,4 +1,4 @@
1
- import { AnyObject } from '../types';
1
+ import type { AnyObject } from '../types';
2
2
  /**
3
3
  * Walks through the specification and returns all references as an array.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"getListOfReferences.d.ts","sourceRoot":"","sources":["../../src/utils/getListOfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,YAuB3D"}
1
+ {"version":3,"file":"getListOfReferences.d.ts","sourceRoot":"","sources":["../../src/utils/getListOfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,YAuB3D"}