@automatons/validator 2.0.1 → 2.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/README.md CHANGED
@@ -2,11 +2,14 @@
2
2
 
3
3
  The validator of openapi schema.
4
4
 
5
+ Since v2 this package is **ESM-only** and requires **Node.js >= 22**.
6
+
5
7
  ## Usage
6
8
 
7
9
  ```typescript
8
10
  import {validator} from "@automatons/validator";
9
- import {readSync} from "fs";
11
+ import {readFileSync} from "node:fs";
10
12
 
11
- const result = validator(readSync('path/to/openapi.json'))
13
+ const result = await validator(JSON.parse(readFileSync("path/to/openapi.json", "utf-8")));
14
+ // result.valid: boolean, result.errors: { keyword, rule, location }[]
12
15
  ```
package/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
+ type Validate = {
2
+ keyword: string;
3
+ rule: string;
4
+ location: string;
5
+ };
1
6
  declare const validator: (openapi: {
2
7
  openapi: string;
3
- [key: string]: any;
8
+ [key: string]: unknown;
4
9
  }) => Promise<{
5
10
  valid: boolean;
6
11
  errors: Validate[];
7
12
  }>;
8
- type Validate = {
9
- keyword: string;
10
- rule: string;
11
- location: string;
12
- };
13
13
 
14
14
  export { type Validate, validator };