Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 5706b18

Browse files
authored
feat!: new @scalar/openapi-types package (#175)
* feat: add new @scalar/openapi-types package * docs(changeset): feat: new @scalar/openapi-types package * chore: reset version * chore: clean up, add type tests * chore: mark @scalar/openapi-types as external * test: add custom extensions
1 parent aec9f22 commit 5706b18

18 files changed

+312
-2491
lines changed

.changeset/rude-rivers-smell.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@scalar/openapi-parser': minor
3+
'@scalar/openapi-types': minor
4+
---
5+
6+
feat: new @scalar/openapi-types package

README.md

+24-7
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ Modern OpenAPI parser written in TypeScript with support for OpenAPI 3.1, OpenAP
1616
- [ ] Amazing error output
1717
- [ ] Support for OpenAPI 4.0 👀
1818

19-
## Limitations
20-
21-
References are hard and the following features aren’t implemented yet (but will be in the future):
22-
23-
- URLs
24-
2519
## Installation
2620

27-
```
21+
```bash
2822
npm add @scalar/openapi-parser
2923
```
3024

@@ -148,6 +142,29 @@ validate(specification, {
148142
})
149143
```
150144

145+
### TypeScript
146+
147+
If you just look for our types, you can install the package separately:
148+
149+
```bash
150+
npm add @scalar/openapi-types
151+
```
152+
153+
And use it like this:
154+
155+
```ts
156+
import type { OpenAPI } from '@scalar/openapi-types'
157+
158+
const file: OpenAPI.Document = {
159+
openapi: '3.1.0',
160+
info: {
161+
title: 'Hello World',
162+
version: '1.0.0',
163+
},
164+
paths: {},
165+
}
166+
```
167+
151168
### Advanced: URL and file references
152169

153170
You can reference other files, too. To do that, the parser needs to know what files are available.

packages/openapi-parser/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Modern OpenAPI parser written in TypeScript, with support for Swagger 2.0, OpenA
1010

1111
## Installation
1212

13-
```
13+
```bash
1414
npm add @scalar/openapi-parser
1515
```
1616

packages/openapi-parser/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"rollup": "^4.19.2",
5959
"rollup-plugin-output-size": "^1.4.1",
6060
"rollup-plugin-webpack-stats": "^1.0.1",
61-
"tinybench": "^2.8.0"
61+
"tinybench": "^2.8.0",
62+
"@scalar/openapi-types": "workspace:*"
6263
},
6364
"dependencies": {
6465
"ajv": "^8.17.1",

0 commit comments

Comments
 (0)