@scalar/asyncapi-validator 0.1.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 +7 -0
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/detect-version.d.ts +16 -0
- package/dist/detect-version.d.ts.map +1 -0
- package/dist/detect-version.js +34 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/specifications.d.ts +23 -0
- package/dist/specifications.d.ts.map +1 -0
- package/dist/specifications.js +17 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/validate.d.ts +17 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +29 -0
- package/package.json +63 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @scalar/asyncapi-validator
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9967](https://github.com/scalar/scalar/pull/9967): Add `@scalar/asyncapi-validator`, a package that validates AsyncAPI documents (2.x and 3.x) against the AsyncAPI Specification. It is built on `@scalar/json-schema-validator` and uses the official schemas from `@asyncapi/specs`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Scalar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Scalar AsyncAPI Validator
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@scalar/asyncapi-validator)
|
|
4
|
+
[](https://www.npmjs.com/package/@scalar/asyncapi-validator)
|
|
5
|
+
[](https://www.npmjs.com/package/@scalar/asyncapi-validator)
|
|
6
|
+
[](https://discord.gg/scalar)
|
|
7
|
+
|
|
8
|
+
Validate AsyncAPI documents against the AsyncAPI Specification. Supports AsyncAPI 2.x and 3.x.
|
|
9
|
+
|
|
10
|
+
Built on [`@scalar/json-schema-validator`](https://www.npmjs.com/package/@scalar/json-schema-validator), using the official schemas from [`@asyncapi/specs`](https://www.npmjs.com/package/@asyncapi/specs).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Scalar is an open-source API platform for teams who want beautiful developer interfaces without vendor lock-in.
|
|
15
|
+
|
|
16
|
+
- **[API References](https://scalar.com/products/api-references/getting-started)** — Interactive API documentation from OpenAPI and AsyncAPI specs.
|
|
17
|
+
- **[Developer Docs](https://scalar.com/products/docs/getting-started)** — Write in Markdown/MDX, generate API references, sync with two-way Git.
|
|
18
|
+
- **[SDK Generator](https://scalar.com/products/sdk-generator/getting-started)** — Type-safe SDKs and CLIs in TypeScript, Python, Go, PHP, Java, and Ruby.
|
|
19
|
+
- **[API Client](https://scalar.com/products/api-client/getting-started)** — Open-source, offline-first Postman alternative built on OpenAPI.
|
|
20
|
+
|
|
21
|
+
20M+ monthly npm installs · 15,500+ GitHub stars · MIT licensed · [scalar.com](https://scalar.com)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm add @scalar/asyncapi-validator
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Pass a JSON string, a YAML string, or an object:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { validate } from '@scalar/asyncapi-validator'
|
|
37
|
+
|
|
38
|
+
const result = validate({
|
|
39
|
+
asyncapi: '3.0.0',
|
|
40
|
+
info: {
|
|
41
|
+
title: 'Hello World',
|
|
42
|
+
version: '1.0.0',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
console.log(result.valid)
|
|
47
|
+
|
|
48
|
+
if (!result.valid) {
|
|
49
|
+
console.log(result.errors)
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The AsyncAPI version is read from the document's `asyncapi` field, and the matching schema is chosen automatically.
|
|
54
|
+
|
|
55
|
+
### Schema-level validation
|
|
56
|
+
|
|
57
|
+
This is schema-level validation. As the AsyncAPI project notes, JSON Schema alone cannot express every rule of the specification, so a valid result here does not guarantee a semantically complete document.
|
|
58
|
+
|
|
59
|
+
### Throw on error
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { validate } from '@scalar/asyncapi-validator'
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
validate(document, { throwOnError: true })
|
|
66
|
+
} catch (error) {
|
|
67
|
+
// Handle the first validation error
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Community
|
|
72
|
+
|
|
73
|
+
We are API nerds. You too? Let's chat on Discord: <https://discord.gg/scalar>
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
The source code in this repository is licensed under [MIT](https://github.com/scalar/scalar/blob/main/LICENSE).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AsyncApiVersion } from './specifications.js';
|
|
2
|
+
/**
|
|
3
|
+
* Detects the AsyncAPI version of a document by reading its top-level `asyncapi`
|
|
4
|
+
* field (a version string like `"3.0.0"`).
|
|
5
|
+
*
|
|
6
|
+
* We keep one schema per minor version, so any patch release validates against
|
|
7
|
+
* its minor: `3.1.4` is checked against the `3.1.0` schema. Returns the matching
|
|
8
|
+
* supported version, or `undefined` when none exists.
|
|
9
|
+
*
|
|
10
|
+
* The fallback matches on major and minor only, so a prerelease like `3.0.0-rc1`
|
|
11
|
+
* also resolves to `3.0.0`. That is deliberate — there are no prerelease schemas
|
|
12
|
+
* to validate against — but it means the returned version can be more precise
|
|
13
|
+
* than the document's own `asyncapi` field.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectVersion(document: unknown): AsyncApiVersion | undefined;
|
|
16
|
+
//# sourceMappingURL=detect-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-version.d.ts","sourceRoot":"","sources":["../src/detect-version.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,kBAAkB,CAAA;AAEzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAwB5E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isObject } from '@scalar/helpers/object/is-object';
|
|
2
|
+
import { AsyncApiVersions } from './specifications.js';
|
|
3
|
+
/**
|
|
4
|
+
* Detects the AsyncAPI version of a document by reading its top-level `asyncapi`
|
|
5
|
+
* field (a version string like `"3.0.0"`).
|
|
6
|
+
*
|
|
7
|
+
* We keep one schema per minor version, so any patch release validates against
|
|
8
|
+
* its minor: `3.1.4` is checked against the `3.1.0` schema. Returns the matching
|
|
9
|
+
* supported version, or `undefined` when none exists.
|
|
10
|
+
*
|
|
11
|
+
* The fallback matches on major and minor only, so a prerelease like `3.0.0-rc1`
|
|
12
|
+
* also resolves to `3.0.0`. That is deliberate — there are no prerelease schemas
|
|
13
|
+
* to validate against — but it means the returned version can be more precise
|
|
14
|
+
* than the document's own `asyncapi` field.
|
|
15
|
+
*/
|
|
16
|
+
export function detectVersion(document) {
|
|
17
|
+
if (!isObject(document)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const version = document.asyncapi;
|
|
21
|
+
if (typeof version !== 'string') {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
// Exact match first (the common case).
|
|
25
|
+
if (AsyncApiVersions.includes(version)) {
|
|
26
|
+
return version;
|
|
27
|
+
}
|
|
28
|
+
// Otherwise fall back to the schema for the same major.minor.
|
|
29
|
+
const [major, minor] = version.split('.');
|
|
30
|
+
return AsyncApiVersions.find((supported) => {
|
|
31
|
+
const [supportedMajor, supportedMinor] = supported.split('.');
|
|
32
|
+
return supportedMajor === major && supportedMinor === minor;
|
|
33
|
+
});
|
|
34
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error messages used by the validator.
|
|
3
|
+
*
|
|
4
|
+
* Kept local to this package on purpose: error messages should live where they
|
|
5
|
+
* are used and be copied rather than imported across packages.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ERRORS: {
|
|
8
|
+
readonly EMPTY_OR_INVALID: "Can't find JSON, YAML or filename in data.";
|
|
9
|
+
readonly ASYNCAPI_VERSION_NOT_SUPPORTED: "Can't find a supported AsyncAPI version in the provided document, the `asyncapi` field must be a supported version string.";
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;CAIT,CAAA"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error messages used by the validator.
|
|
3
|
+
*
|
|
4
|
+
* Kept local to this package on purpose: error messages should live where they
|
|
5
|
+
* are used and be copied rather than imported across packages.
|
|
6
|
+
*/
|
|
7
|
+
export const ERRORS = {
|
|
8
|
+
EMPTY_OR_INVALID: "Can't find JSON, YAML or filename in data.",
|
|
9
|
+
ASYNCAPI_VERSION_NOT_SUPPORTED: "Can't find a supported AsyncAPI version in the provided document, the `asyncapi` field must be a supported version string.",
|
|
10
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AsyncApiVersions as supportedVersions } from './specifications.js';
|
|
2
|
+
export type { AsyncApiVersion, ErrorObject, ThrowOnErrorOption, ValidationOutcome } from './types.js';
|
|
3
|
+
export { type ValidateOptions, validate } from './validate.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAClG,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AsyncAPI versions supported by the validator.
|
|
3
|
+
*
|
|
4
|
+
* When `@asyncapi/specs` adds a new version, add it here and bump the dependency.
|
|
5
|
+
*/
|
|
6
|
+
export type AsyncApiVersion = '2.0.0' | '2.1.0' | '2.2.0' | '2.3.0' | '2.4.0' | '2.5.0' | '2.6.0' | '3.0.0' | '3.1.0';
|
|
7
|
+
/**
|
|
8
|
+
* The AsyncAPI JSON Schemas keyed by version, sourced from `@asyncapi/specs`.
|
|
9
|
+
*
|
|
10
|
+
* These are bundled and self-contained, so Ajv can compile each one without
|
|
11
|
+
* resolving external files.
|
|
12
|
+
*
|
|
13
|
+
* We use the "without $id" variant on purpose: the standard bundle embeds the
|
|
14
|
+
* draft-07 meta-schema with its own `$id`, which collides with Ajv's built-in
|
|
15
|
+
* draft-07 ("reference resolves to more than one schema"). The `$id`-free
|
|
16
|
+
* variant compiles cleanly while still resolving every internal reference.
|
|
17
|
+
*
|
|
18
|
+
* The cast keeps the emitted declarations from depending on `@asyncapi/specs`'
|
|
19
|
+
* transitive `@types/json-schema`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const AsyncApiSpecifications: Record<AsyncApiVersion, Record<string, unknown>>;
|
|
22
|
+
export declare const AsyncApiVersions: AsyncApiVersion[];
|
|
23
|
+
//# sourceMappingURL=specifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specifications.d.ts","sourceRoot":"","sources":["../src/specifications.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAErH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,EAAgD,MAAM,CACvF,eAAe,EACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACxB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAA0C,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import asyncapiSpecs from '@asyncapi/specs';
|
|
2
|
+
/**
|
|
3
|
+
* The AsyncAPI JSON Schemas keyed by version, sourced from `@asyncapi/specs`.
|
|
4
|
+
*
|
|
5
|
+
* These are bundled and self-contained, so Ajv can compile each one without
|
|
6
|
+
* resolving external files.
|
|
7
|
+
*
|
|
8
|
+
* We use the "without $id" variant on purpose: the standard bundle embeds the
|
|
9
|
+
* draft-07 meta-schema with its own `$id`, which collides with Ajv's built-in
|
|
10
|
+
* draft-07 ("reference resolves to more than one schema"). The `$id`-free
|
|
11
|
+
* variant compiles cleanly while still resolving every internal reference.
|
|
12
|
+
*
|
|
13
|
+
* The cast keeps the emitted declarations from depending on `@asyncapi/specs`'
|
|
14
|
+
* transitive `@types/json-schema`.
|
|
15
|
+
*/
|
|
16
|
+
export const AsyncApiSpecifications = asyncapiSpecs.schemasWithoutId;
|
|
17
|
+
export const AsyncApiVersions = Object.keys(AsyncApiSpecifications);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ValidationOutcome as GenericValidationOutcome } from '@scalar/json-schema-validator';
|
|
2
|
+
import type { AsyncApiVersion } from './specifications.js';
|
|
3
|
+
export type { ErrorObject } from '@scalar/json-schema-validator';
|
|
4
|
+
export type { AsyncApiVersion } from './specifications.js';
|
|
5
|
+
export type ThrowOnErrorOption = {
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, the function will throw an error if the document is invalid.
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
throwOnError?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The result of validating an AsyncAPI document.
|
|
15
|
+
*/
|
|
16
|
+
export type ValidationOutcome = GenericValidationOutcome<AsyncApiVersion>;
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,IAAI,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAElG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,YAAY,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAEhE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AnyObject } from '@scalar/types/utils';
|
|
2
|
+
import type { ThrowOnErrorOption, ValidationOutcome } from './types.js';
|
|
3
|
+
export type ValidateOptions = ThrowOnErrorOption;
|
|
4
|
+
/**
|
|
5
|
+
* Validates a single AsyncAPI document against the AsyncAPI Specification.
|
|
6
|
+
*
|
|
7
|
+
* Schema validation is delegated to `@scalar/json-schema-validator`; version
|
|
8
|
+
* detection is AsyncAPI-specific.
|
|
9
|
+
*
|
|
10
|
+
* This is schema-level validation. As the AsyncAPI project notes, JSON Schema
|
|
11
|
+
* alone cannot express every rule of the specification, so a valid result here
|
|
12
|
+
* does not guarantee a semantically complete document.
|
|
13
|
+
*
|
|
14
|
+
* @param document - A JSON string, a YAML string, or an object.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validate(document: string | AnyObject, options?: ValidateOptions): ValidationOutcome;
|
|
17
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAKpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEpE,MAAM,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAchD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAEnG"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createSpecificationValidator } from '@scalar/json-schema-validator';
|
|
2
|
+
import { detectVersion } from './detect-version.js';
|
|
3
|
+
import { ERRORS } from './errors.js';
|
|
4
|
+
import { AsyncApiSpecifications } from './specifications.js';
|
|
5
|
+
const validateDocument = createSpecificationValidator({
|
|
6
|
+
schemas: AsyncApiSpecifications,
|
|
7
|
+
detectVersion,
|
|
8
|
+
errors: { emptyOrInvalid: ERRORS.EMPTY_OR_INVALID, versionNotSupported: ERRORS.ASYNCAPI_VERSION_NOT_SUPPORTED },
|
|
9
|
+
// The AsyncAPI schema pins the `asyncapi` field to an exact version (a
|
|
10
|
+
// `const`), so a patch release (e.g. 3.1.4) has to be normalized to its minor
|
|
11
|
+
// before schema validation. Return a shallow copy so the caller's document is
|
|
12
|
+
// left untouched.
|
|
13
|
+
prepareDocument: (specification, version) => specification.asyncapi === version ? specification : { ...specification, asyncapi: version },
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Validates a single AsyncAPI document against the AsyncAPI Specification.
|
|
17
|
+
*
|
|
18
|
+
* Schema validation is delegated to `@scalar/json-schema-validator`; version
|
|
19
|
+
* detection is AsyncAPI-specific.
|
|
20
|
+
*
|
|
21
|
+
* This is schema-level validation. As the AsyncAPI project notes, JSON Schema
|
|
22
|
+
* alone cannot express every rule of the specification, so a valid result here
|
|
23
|
+
* does not guarantee a semantically complete document.
|
|
24
|
+
*
|
|
25
|
+
* @param document - A JSON string, a YAML string, or an object.
|
|
26
|
+
*/
|
|
27
|
+
export function validate(document, options) {
|
|
28
|
+
return validateDocument(document, options);
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scalar/asyncapi-validator",
|
|
3
|
+
"description": "Validate AsyncAPI documents against the AsyncAPI Specification",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "Scalar (https://github.com/scalar)",
|
|
6
|
+
"homepage": "https://github.com/scalar/scalar",
|
|
7
|
+
"bugs": "https://github.com/scalar/scalar/issues/new/choose",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
|
+
"directory": "packages/asyncapi-validator"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"asyncapi",
|
|
15
|
+
"scalar",
|
|
16
|
+
"validator",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"version": "0.1.0",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"CHANGELOG.md"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@asyncapi/specs": "^6.11.1",
|
|
41
|
+
"yaml": "^2.9.0",
|
|
42
|
+
"@scalar/helpers": "0.11.2",
|
|
43
|
+
"@scalar/json-schema-validator": "0.1.0",
|
|
44
|
+
"@scalar/types": "0.18.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
48
|
+
"@types/node": "^24.1.0",
|
|
49
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
50
|
+
"tailwindcss": "^4.3.3",
|
|
51
|
+
"vite": "8.1.5",
|
|
52
|
+
"vue": "^3.5.40",
|
|
53
|
+
"@scalar/use-codemirror": "0.14.15",
|
|
54
|
+
"@scalar/themes": "0.17.4"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
58
|
+
"dev": "pnpm playground",
|
|
59
|
+
"playground": "cd playground && vite",
|
|
60
|
+
"test": "vitest --run",
|
|
61
|
+
"types:check": "tsgo --noEmit"
|
|
62
|
+
}
|
|
63
|
+
}
|