Skip to content

docs: rewrite tutorial for template based on AsyncAPI v3 #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
35f93fe
chore: remove broken lint:tpl:validator script and its references
Aditya08Vashisht Apr 11, 2025
6978868
temp: save current docs state before regenerating
Aditya08Vashisht Apr 30, 2025
7c86f18
Delete .eslintignore
Aditya08Vashisht Apr 30, 2025
764a165
Delete apps/generator/package.json
Aditya08Vashisht Apr 30, 2025
17ba123
Delete packages/templates/clients/websocket/python/example.py
Aditya08Vashisht Apr 30, 2025
e5a9958
Delete turbo.json
Aditya08Vashisht Apr 30, 2025
6ebf9e2
your meaningful commit message here
Aditya08Vashisht May 2, 2025
08917b3
docs: add example AsyncAPI v3 file and update tutorial reference
Aditya08Vashisht May 3, 2025
e9516ba
Update docs and tutorial files
Aditya08Vashisht May 3, 2025
a67e69c
Your commit message here
Aditya08Vashisht May 4, 2025
e7f3eff
chore: clean up test files and fix path for asyncapi parser
Aditya08Vashisht May 5, 2025
704823d
Update asyncapi.yml
Aditya08Vashisht May 5, 2025
b4493f7
Update package.json
Aditya08Vashisht May 5, 2025
5afdc70
Delete test-parser.js
Aditya08Vashisht May 5, 2025
f26f4f7
Delete example-asyncapi.yml
Aditya08Vashisht May 5, 2025
282183d
Delete apps/generator/docs/comments-service.v3.yml
Aditya08Vashisht May 6, 2025
88da4a5
Delete apps/generator/docs/parser.md
Aditya08Vashisht May 6, 2025
fb68191
Delete apps/generator/lib/generator.js
Aditya08Vashisht May 6, 2025
1c73c3d
Delete apps/generator/lib/parser.js
Aditya08Vashisht May 6, 2025
1302852
Delete apps/generator/test/asyncapi.yml
Aditya08Vashisht May 6, 2025
1b2c24a
Delete apps/generator/test/docs/ws.yml
Aditya08Vashisht May 6, 2025
e857ea2
Delete apps/generator/test/test-project/package.json
Aditya08Vashisht May 6, 2025
323d8f9
Delete docs/css/global.min.css
Aditya08Vashisht May 6, 2025
f84fac2
Delete docs/js/app.js
Aditya08Vashisht May 6, 2025
9dd2ebc
Delete package.json
Aditya08Vashisht May 6, 2025
c699086
Update generator-template.md
Aditya08Vashisht May 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

60 changes: 40 additions & 20 deletions apps/generator/docs/generator-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,62 @@ Before you begin, make sure you have the following set up:
There is a list of [community maintained templates](https://www.asyncapi.com/docs/tools/generator/template#generator-templates-list), but what if you do not find what you need? In that case, you'll create a user-defined template that generates custom output from the generator.
Before you create the template, you'll need to have an [AsyncAPI document](https://www.asyncapi.com/docs/tools/generator/asyncapi-document) that defines the properties you want to use in your template to test against. In this tutorial, you'll use the following template saved in the **test/fixtures/asyncapi.yml** file in your template project directory.

``` yml

asyncapi: 2.6.0

```yaml
asyncapi: 3.0.0
info:
title: Temperature Service
version: 1.0.0
description: This service is in charge of processing all the events related to temperature.
description: Service that emits temperature changes from a bedroom sensor.

servers:
dev:
url: test.mosquitto.org #in case you're using local mosquitto instance, change this value to localhost.
production:
host: broker.example.com
protocol: mqtt

channels:
temperature/changed:
description: Updates the bedroom temperature in the database when the temperatures drops or goes up.
publish:
operationId: temperatureChange
message:
description: Message that is being sent when the temperature in the bedroom changes.
temperatureChanged:
address: temperature/changed
messages:
temperatureChange:
description: Message sent when the temperature in the bedroom changes.
payload:
type: object
additionalProperties: false
properties:
temperatureId:
type: string
$ref: '#/components/schemas/Temperature'

operations:
sendTemperatureChanged:
action: send
summary: Temperature changes are pushed to the broker
channel:
$ref: '#/channels/temperatureChanged'

components:
schemas:
temperatureId:
Temperature:
type: object
additionalProperties: false
properties:
temperatureId:
value:
type: number
unit:
type: string

```
> 🆕 This document uses the AsyncAPI 3.0.0 structure. Notable changes include `operations` now being top-level and the use of `address:` in `channels` instead of nested publish/subscribe.

## Handling Diagnostics (Warnings)

When using the latest AsyncAPI parser, it's important to handle not just errors but also diagnostics (warnings). These help identify non-critical issues, such as missing recommended fields like `license`, `contact`, or outdated spec versions.

```ts
const { parseFromFile } = require('@asyncapi/parser');

const result = await parseFromFile('example-asyncapi.yaml');

if (result.diagnostics && result.diagnostics.length > 0) {
console.warn('⚠️ Found diagnostics:');
console.dir(result.diagnostics, { depth: null });
}


## Overview of steps

Expand Down
96 changes: 0 additions & 96 deletions apps/generator/docs/parser.md

This file was deleted.

Loading