Last active
October 12, 2022 09:29
-
-
Save smoya/895956043828f7ae1b75c0669d062afc to your computer and use it in GitHub Desktop.
AsyncAPI Parser-JS example coded in the CCOSS 2022 Workshop: "Vamos a Generar Código y Documentación con AsyncAPI" - https://www.youtube.com/watch?v=qdHymBvBLZQ
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
const parser = require('@asyncapi/parser'); | |
const fs = require('fs'); | |
const path = require('path'); | |
async function parse(content) { | |
const doc = await parser.parse(content); | |
console.log("Hola! Bienvenida/o a", doc.info().title()); | |
console.log("Servers:"); | |
Object.entries(doc.servers()).forEach((server) => { | |
console.log(`- ${server[0]}`, `(${server[1].url()})`); | |
}); | |
console.log("Channels:"); | |
Object.entries(doc.channels()).forEach((channel) => { | |
console.log(`- ${channel[0]}`); | |
}); | |
} | |
const doc = fs.readFileSync(path.resolve(__dirname, './asyncapi.yaml'), 'utf-8'); | |
parse(doc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment