UNPKG

@asyncapi/generator

Version:

The AsyncAPI generator. It can generate documentation, code, anything!

10 lines (8 loc) 984 B
## JavaScript WebSocket Client You can test this template: 1. Clone the project and run `npm install` 2. Navigate to `packages/templates/clients/websocket/test/integration-test` and run the tests with `npm run test` to generate WebSocket clients 3. Navigate to `packages/templates/clients/websocket/javascript` 4. Install with `npm install` and run test with `npm run test` 5. Start example script that uses a client library generated by the test: `node example.js` > By default this is testing against Hoppscotch echo service. You can modify `packages/templates/clients/websocket/javascript/example.js` and change first line to `const WSClient = require('./test/temp/snapshotTestResult/client_postman/client.js');` and run `node example.js` again. You will see example still works but now it is using a different API. This is possible since both AsyncAPI documents define the same name of operation for sending messages: `sendEchoMessage` so each client generated has the same API.