Skip to content

Commit

Permalink
Support Avro schemaFormat in AsyncApi rendering (#980)
Browse files Browse the repository at this point in the history
* feat: add `@asyncapi/avro-schema-parser` to support Avro schemaFormat in AsyncAPI rendering

Closes #976

* Create wet-pianos-crash.md

---------

Co-authored-by: David Boyne <[email protected]>
  • Loading branch information
carlosallexandre and boyney123 authored Dec 2, 2024
1 parent 8c2c171 commit 95ed136
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-pianos-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/core": patch
---

feat(core): added support for rendering avro schema formats in AsyncApi page
6 changes: 4 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@astrojs/mdx": "^3.1.8",
"@astrojs/react": "^3.6.2",
"@astrojs/tailwind": "^5.1.2",
"@asyncapi/avro-schema-parser": "^3.0.24",
"@asyncapi/react-component": "^2.4.3",
"@headlessui/react": "^2.0.3",
"@heroicons/react": "^2.1.3",
Expand Down
3 changes: 2 additions & 1 deletion src/pages/docs/[type]/[id]/[version]/asyncapi/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { readFileSync } from 'fs';
import { createElement } from 'react';
import { renderToString } from 'react-dom/server';
import { Parser } from '@asyncapi/parser';
import { AvroSchemaParser } from '@asyncapi/avro-schema-parser';
import type { CollectionTypes, PageTypes } from '@types';
Expand Down Expand Up @@ -46,7 +47,7 @@ const fileContent = readFileSync(pathOnDisk, 'utf-8');
// AsyncAPI parser will parser schemas for users, they can turn this off.
const parseSchemas = Config?.asyncAPI?.renderParsedSchemas ?? true;
const parsed = await new Parser().parse(fileContent, { parseSchemas });
const parsed = await new Parser({ schemaParsers: [AvroSchemaParser()] }).parse(fileContent, { parseSchemas });
const stringified = parsed.document?.json();
const config: ConfigInterface = { show: { sidebar: true, errors: true } };
Expand Down

0 comments on commit 95ed136

Please sign in to comment.