@scalar/openapi-parser 0.7.2 → 0.8.1
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 +20 -0
- package/LICENSE +1 -1
- package/README.md +193 -24
- package/dist/configuration/index.d.ts +2 -1
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +1 -1
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +1 -1
- package/dist/polyfills/path.d.ts +3 -3
- package/dist/polyfills/path.d.ts.map +1 -1
- package/dist/polyfills/path.js +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/helpers.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/helpers.js +1 -1
- package/dist/utils/getListOfReferences.d.ts +1 -1
- package/dist/utils/getListOfReferences.d.ts.map +1 -1
- package/dist/utils/isFilesystem.js +1 -1
- package/dist/utils/load/load.d.ts +2 -2
- package/dist/utils/load/load.d.ts.map +1 -1
- package/dist/utils/load/load.js +1 -1
- package/dist/utils/load/plugins/fetchUrls.d.ts +1 -1
- package/dist/utils/load/plugins/fetchUrls.d.ts.map +1 -1
- package/dist/utils/load/plugins/readFiles.d.ts +1 -1
- package/dist/utils/load/plugins/readFiles.d.ts.map +1 -1
- package/dist/utils/normalize.d.ts +1 -1
- package/dist/utils/normalize.d.ts.map +1 -1
- package/dist/utils/resolveReferences.d.ts +1 -1
- package/dist/utils/resolveReferences.d.ts.map +1 -1
- package/dist/utils/toJson.d.ts +1 -1
- package/dist/utils/toJson.d.ts.map +1 -1
- package/dist/utils/toYaml.d.ts +1 -1
- package/dist/utils/toYaml.d.ts.map +1 -1
- package/dist/utils/traverse.d.ts +1 -1
- package/dist/utils/traverse.d.ts.map +1 -1
- package/dist/utils/upgrade.d.ts +2 -1
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/upgrade.test-d.d.ts +2 -0
- package/dist/utils/upgrade.test-d.d.ts.map +1 -0
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts +1 -1
- package/dist/utils/upgradeFromThreeToThreeOne.d.ts.map +1 -1
- package/dist/utils/upgradeFromTwoToThree.d.ts +1 -1
- package/dist/utils/upgradeFromTwoToThree.d.ts.map +1 -1
- package/dist/utils/upgradeFromTwoToThree.js +1 -1
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/workThroughQueue.js +1 -1
- package/package.json +37 -33
- package/dist/types/openapi-types.d.ts +0 -746
- package/dist/types/openapi-types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @scalar/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5bd8337: feat: upgrade from Swagger 2.0 (experimental)
|
|
8
|
+
|
|
9
|
+
## 0.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b4f9f97: feat: new @scalar/openapi-types package
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- b4f9f97: feat: add literal versions to OpenAPI.Document types
|
|
18
|
+
- b4f9f97: feat: types: allow to type custom extensions
|
|
19
|
+
- b4f9f97: feat: types: allow any attribute in schemas
|
|
20
|
+
- b231e7d: fix: upgrade returns correct OpenAPI document version type
|
|
21
|
+
- b4f9f97: feat: expose more types under the OpenAPI namespace
|
|
22
|
+
|
|
3
23
|
## 0.7.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
# Scalar OpenAPI Parser
|
|
2
2
|
|
|
3
|
-
[](https://github.com/scalar/openapi-parser/blob/main/LICENSE)
|
|
3
|
+
[](https://www.npmjs.com/package/@scalar/openapi-parser)
|
|
4
|
+
[](https://www.npmjs.com/package/@scalar/openapi-parser)
|
|
5
|
+
[](https://www.npmjs.com/package/@scalar/openapi-parser)
|
|
7
6
|
[](https://discord.gg/scalar)
|
|
8
7
|
|
|
9
|
-
Modern OpenAPI parser written in TypeScript
|
|
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
|
-
###
|
|
26
|
+
### Validate
|
|
20
27
|
|
|
21
28
|
```ts
|
|
22
|
-
import {
|
|
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
|
|
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
|
-
###
|
|
49
|
+
### Resolve references
|
|
37
50
|
|
|
38
51
|
```ts
|
|
39
|
-
import {
|
|
52
|
+
import { dereference } from '@scalar/openapi-parser'
|
|
40
53
|
|
|
41
|
-
const
|
|
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 {
|
|
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
|
-
###
|
|
66
|
+
### Modify an OpenAPI specification
|
|
60
67
|
|
|
61
68
|
```ts
|
|
62
|
-
import {
|
|
69
|
+
import { filter } from '@scalar/openapi-parser'
|
|
63
70
|
|
|
64
|
-
const
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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};
|
|
@@ -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;
|
|
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;IAwF1B;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc;CA8B9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"ajv-draft-04";import i from"ajv-formats";import
|
|
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};
|
package/dist/polyfills/path.d.ts
CHANGED
|
@@ -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
|
|
7
|
-
export declare
|
|
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":"
|
|
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"}
|
package/dist/polyfills/path.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
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';
|
|
4
3
|
export type AnyObject = Record<string, any>;
|
|
5
4
|
export type LoadResult = {
|
|
6
5
|
filesystem: Filesystem;
|
|
6
|
+
errors?: ErrorObject[];
|
|
7
7
|
};
|
|
8
8
|
export type ValidateResult = {
|
|
9
9
|
valid: boolean;
|
|
@@ -12,8 +12,8 @@ export type ValidateResult = {
|
|
|
12
12
|
errors?: ErrorObject[];
|
|
13
13
|
schema?: OpenAPI.Document;
|
|
14
14
|
};
|
|
15
|
-
export type UpgradeResult = {
|
|
16
|
-
specification:
|
|
15
|
+
export type UpgradeResult<T extends OpenAPI.Document = OpenAPI.Document> = {
|
|
16
|
+
specification: T;
|
|
17
17
|
version: string;
|
|
18
18
|
};
|
|
19
19
|
export type FilterResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE9D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,OAAO,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,MAAM,C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,CAAA;CACvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/betterAjvErrors/helpers.ts"],"names":[],"mappings":"
|
|
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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListOfReferences.d.ts","sourceRoot":"","sources":["../../src/utils/getListOfReferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function r(r){return void 0!==
|
|
1
|
+
function r(r){return void 0!==r&&Array.isArray(r)&&r.length>0&&r.some((r=>!0===r.isEntrypoint))}export{r as isFilesystem};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Filesystem, LoadResult } from '../../types';
|
|
1
|
+
import type { Filesystem, LoadResult, ThrowOnErrorOption } from '../../types';
|
|
2
2
|
export type LoadPlugin = {
|
|
3
3
|
check: (value?: any) => boolean;
|
|
4
4
|
get: (value: any) => any;
|
|
@@ -10,5 +10,5 @@ export declare function load(value: any, options?: {
|
|
|
10
10
|
plugins?: LoadPlugin[];
|
|
11
11
|
filename?: string;
|
|
12
12
|
filesystem?: Filesystem;
|
|
13
|
-
}): Promise<LoadResult>;
|
|
13
|
+
} & ThrowOnErrorOption): Promise<LoadResult>;
|
|
14
14
|
//# sourceMappingURL=load.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,EACV,UAAU,EACV,kBAAkB,EACnB,MAAM,aAAa,CAAA;AAMpB,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACvD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,wBAAsB,IAAI,CACxB,KAAK,EAAE,GAAG,EACV,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,kBAAkB,GACrB,OAAO,CAAC,UAAU,CAAC,CA6HrB"}
|
package/dist/utils/load/load.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ERRORS as e}from"../../configuration/index.js";import{getEntrypoint as r}from"../getEntrypoint.js";import{getListOfReferences as s}from"../getListOfReferences.js";import{makeFilesystem as t}from"../makeFilesystem.js";import{normalize as n}from"../normalize.js";async function i(o,f){const m=[];if(f?.filesystem?.find((e=>e.filename===o)))return{filesystem:f.filesystem,errors:m};const l=f?.plugins?.find((e=>e.check(o)));let c;if(l)try{c=n(await l.get(o))}catch(r){if(f?.throwOnError)throw new Error(e.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s",o));return m.push({code:"EXTERNAL_REFERENCE_NOT_FOUND",message:e.EXTERNAL_REFERENCE_NOT_FOUND.replace("%s",o)}),{filesystem:[],errors:m}}else c=n(o);if(void 0===c){if(f?.throwOnError)throw new Error("No content to load");return m.push({code:"NO_CONTENT",message:e.NO_CONTENT}),{filesystem:[],errors:m}}let E=t(c,{filename:f?.filename??null});const a=(f?.filename?E.find((e=>e.filename===f?.filename)):r(E)).references??s(c);if(0===a.length)return{filesystem:E,errors:m};for(const e of a){const r=f?.plugins?.find((r=>r.check(e)));if(!r)continue;const s=r.check(e)&&r.resolvePath?r.resolvePath(o,e):e;if(E.find((r=>r.filename===e)))continue;const{filesystem:t,errors:n}=await i(s,{...f,filename:e});m.push(...n),E=[...E,...t.map((e=>({...e,isEntrypoint:!1})))]}return{filesystem:E,errors:m}}export{i as load};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchUrls.d.ts","sourceRoot":"","sources":["../../../../src/utils/load/plugins/fetchUrls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchUrls.d.ts","sourceRoot":"","sources":["../../../../src/utils/load/plugins/fetchUrls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,6BAA6B;;CAEzC,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,CAAC,mBAAmB,CAAC,EAAE;IAC7C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC3C,KAAK,UAiDL,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../../src/utils/load/plugins/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"readFiles.d.ts","sourceRoot":"","sources":["../../../../src/utils/load/plugins/readFiles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,SAAS,EAAE,MAAM,UAoD7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAGrD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAC7C,SAAS,GAAG,UAAU,CAgBxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveReferences.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/utils/toJson.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/utils/toYaml.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/utils/traverse.d.ts
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/utils/upgrade.d.ts
CHANGED
|
@@ -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(
|
|
6
|
+
export declare function upgrade(value: string | AnyObject | Filesystem, _options?: AnyObject): 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,
|
|
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,EACtC,QAAQ,CAAC,EAAE,SAAS,GACnB,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAcrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.test-d.d.ts","sourceRoot":"","sources":["../../src/utils/upgrade.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -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;
|
|
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"}
|