@scalar/openapi-parser 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +21 -11
- package/dist/index.d.ts +1326 -0
- package/dist/index.js +9379 -5476
- package/package.json +10 -11
- /package/dist/{schema-7A4Uwe4k.js → schema-BQQoKgNw.js} +0 -0
- /package/dist/{schema-Oq6-IuPi.js → schema-BjykgtPd.js} +0 -0
- /package/dist/{schema-IrONjwxQ.js → schema-ZROhtp0X.js} +0 -0
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -8,15 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenAPI 3.0 and OpenAPI 3.1
|
|
10
10
|
|
|
11
|
-
## Goals
|
|
12
|
-
|
|
13
|
-
- [x] TypeScript FTW
|
|
14
|
-
- [x] No Node.js polyfills required
|
|
15
|
-
- [x] Well tested
|
|
16
|
-
- [x] Small bundlesize
|
|
17
|
-
- [x] Better errors
|
|
18
|
-
- [ ] Support for OpenAPI 4.0 👀
|
|
19
|
-
|
|
20
11
|
## Installation
|
|
21
12
|
|
|
22
13
|
```
|
|
@@ -28,7 +19,7 @@ npm add @scalar/openapi-parser
|
|
|
28
19
|
### Parse
|
|
29
20
|
|
|
30
21
|
```ts
|
|
31
|
-
import {
|
|
22
|
+
import { resolve } from '@scalar/openapi-parser'
|
|
32
23
|
|
|
33
24
|
const file = `{
|
|
34
25
|
"openapi": "3.1.0",
|
|
@@ -39,7 +30,7 @@ const file = `{
|
|
|
39
30
|
"paths": {}
|
|
40
31
|
}`
|
|
41
32
|
|
|
42
|
-
const result = await
|
|
33
|
+
const result = await resolve(file)
|
|
43
34
|
```
|
|
44
35
|
|
|
45
36
|
### Validate
|
|
@@ -64,3 +55,22 @@ if (!result.valid) {
|
|
|
64
55
|
console.log(result.errors)
|
|
65
56
|
}
|
|
66
57
|
```
|
|
58
|
+
|
|
59
|
+
### Version
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { resolve } from '@scalar/openapi-parser'
|
|
63
|
+
|
|
64
|
+
const file = `{
|
|
65
|
+
"openapi": "3.1.0",
|
|
66
|
+
"info": {
|
|
67
|
+
"title": "Hello World",
|
|
68
|
+
"version": "1.0.0"
|
|
69
|
+
},
|
|
70
|
+
"paths": {}
|
|
71
|
+
}`
|
|
72
|
+
|
|
73
|
+
const result = await resolve(file)
|
|
74
|
+
|
|
75
|
+
console.log(result.version)
|
|
76
|
+
```
|