-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dieter Stinglhamber
committed
Dec 19, 2023
1 parent
8d0c2d9
commit bc3231c
Showing
17 changed files
with
1,185 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: 'monthly' | ||
versioning-strategy: increase | ||
ignore: | ||
- dependency-name: '*' | ||
update-types: ['version-update:semver-major', 'version-update:semver-patch'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Check types | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
check-types: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.3 | ||
cache: 'pnpm' | ||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm check:types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
prettier: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.3 | ||
cache: 'pnpm' | ||
- run: pnpm lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Unit tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.3 | ||
cache: 'pnpm' | ||
- run: pnpm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
src | ||
tests | ||
jest.config.js | ||
tsconfig.json | ||
.husky | ||
.editorconfig | ||
.github | ||
.prettierrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# AsyncAPI validation | ||
|
||
Message validation package for AsyncAPI documents. | ||
|
||
This package is compatible with AsyncAPI documents v2.x.x and v3.0.0. | ||
|
||
## Installation | ||
|
||
```bash | ||
# NPM | ||
npm install asyncapi-validation | ||
# Yarn | ||
yarn add asyncapi-validation | ||
# PNPM | ||
pnpm install asyncapi-validation | ||
``` | ||
|
||
## Usage | ||
|
||
### Using a remote schema | ||
|
||
```ts | ||
import asyncAPIValidation from 'asyncapi-validation'; | ||
|
||
const validator = await asyncAPIValidation.fromUrl('https://example.org/schema.yaml'); | ||
validator('messageName', { foo: 'bar' }); | ||
validator('messageId', { foo: 'bar' }); | ||
``` | ||
|
||
# Using a local schema | ||
```ts | ||
const validator = await asyncAPIValidation.fromUrl('./schema.yaml'); | ||
validator('messageName', { foo: 'bar' }); | ||
validator('messageId', { foo: 'bar' }); | ||
``` | ||
|
||
# Using an in-line schema | ||
```ts | ||
const validator = await asyncAPIValidation.fromSchema(`asyncapi: 3.0.0 | ||
info: | ||
title: Account Service | ||
version: 1.0.0 | ||
description: This service is in charge of processing user signups | ||
channels: | ||
userSignedup: | ||
address: user/signedup | ||
messages: | ||
UserSignedUp: | ||
$ref: '#/components/messages/UserSignedUp' | ||
operations: | ||
sendUserSignedup: | ||
action: send | ||
channel: | ||
$ref: '#/channels/userSignedup' | ||
messages: | ||
- $ref: '#/channels/userSignedup/messages/UserSignedUp' | ||
components: | ||
messages: | ||
UserSignedUp: | ||
payload: | ||
type: object | ||
properties: | ||
displayName: | ||
type: string | ||
description: Name of the user | ||
email: | ||
type: string | ||
format: email | ||
description: Email of the user | ||
`) | ||
validator('messageName', { foo: 'bar' }); | ||
validator('messageId', { foo: 'bar' }); | ||
``` | ||
|
||
## Contributing | ||
|
||
### Tests | ||
|
||
The test suite can be run using pnpm scripts: | ||
|
||
```bash | ||
pnpm test | ||
``` | ||
|
||
Tests can be found in the (tests)[./tests] folder. | ||
|
||
### Linting | ||
|
||
The following pnpm script can be used to find out about the possible linting errors: | ||
|
||
```bash | ||
pnpm lint | ||
``` | ||
|
||
### Linting error prevention | ||
|
||
[Husky](https://github.com/typicode/husky) and [lint-staged](https://github.com/okonet/lint-staged) are set up to check staged files for linting issues. When new changes are commited all the updated files will be checked. If the linting fails for one of them the operation will be cancelled. | ||
|
||
## Built with | ||
|
||
- [NodeJs](https://nodejs.org/) | ||
- [TypeScript](https://www.typescriptlang.org/) | ||
- [AsyncAPI parser](https://www.asyncapi.com/tools/parsers) | ||
- [Ajv js](https://ajv.js.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.