UNPKG

@asyncapi/generator

Version:

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

13 lines (10 loc) 1.31 kB
## Dart 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/dart` 4. Install with `npm install` and run test with `npm run test` 5. Navigate to the generated Hoppscotch client folder with `cd test/temp/snapshotTestResult/custom_client_hoppscotch` 6. Install dependencies of the generated client: `dart pub get` 7. Start an example script that uses a client library generated by the test: `dart run --packages=.dart_tool/package_config.json ../../../../example.dart` > By default, this is testing against Hoppscotch Echo service. You can modify `packages/templates/clients/websocket/dart/example.dart` and change first line to `import 'test/temp/snapshotTestResult/client_postman/client.dart';` and line 15 `final wsClient = PostmanEchoWebSocketClientClient();` and run `dart run --packages=.dart_tool/package_config.json ../../../../example.dart` again. You will see the example still works but against a different API. This is possible as both AsyncAPI documents have the same name of operation for sending messages: `sendEchoMessage` so each client generated has the same API.