Skip to content

Commit

Permalink
add support for AVRO
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkalburgi committed Jun 2, 2024
1 parent e1072e0 commit 6f7304e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
13 changes: 5 additions & 8 deletions src/PreviewMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import * as fs from 'fs';
import { isAsyncAPIFile } from './PreviewWebPanel';
import Diagnostics from './Diagnostics';
import { Parser, fromFile, AsyncAPIDocumentInterface } from '@asyncapi/parser';
import { AvroSchemaParser } from '@asyncapi/avro-schema-parser';
import Asyncapi from './Asyncapi';
import { ISpectralDiagnostic } from '@stoplight/spectral-core';
import { parse } from 'yaml';

function delay(ms: number | undefined) {
return new Promise(resolve => setTimeout(resolve, ms));
}

function parsedAsyncapiPreview(){
const editor: any = vscode.window.activeTextEditor;
if(!editor) {return;}
Expand All @@ -35,7 +32,7 @@ function delay(ms: number | undefined) {


const parser = new Parser();

parser.registerSchemaParser(AvroSchemaParser());

async function buildMarkdown(document: any, diagnostics: ISpectralDiagnostic[], context: vscode.ExtensionContext){

Expand Down Expand Up @@ -83,8 +80,7 @@ export const openAsyncapiMdFiles: { [id: string]: vscode.WebviewPanel } = {}; //
export async function openAsyncAPIMarkdown(context: vscode.ExtensionContext, uri: vscode.Uri) {
const localResourceRoots = [
vscode.Uri.file(path.dirname(uri.fsPath)),
vscode.Uri.joinPath(context.extensionUri, 'dist/node_modules/mermaid/dist/mermaid.min.js'),
vscode.Uri.joinPath(context.extensionUri, 'dist/globals.css')
vscode.Uri.joinPath(context.extensionUri, 'dist')
];
if (vscode.workspace.workspaceFolders) {
vscode.workspace.workspaceFolders.forEach(folder => {
Expand All @@ -99,7 +95,8 @@ export async function openAsyncAPIMarkdown(context: vscode.ExtensionContext, uri
localResourceRoots,
});

const { document, diagnostics } = await fromFile(parser, uri.fsPath).parse();
const { document, diagnostics } = await fromFile(parser, uri.fsPath).parse();

let result = await buildMarkdown(document, diagnostics, context);


Expand Down
6 changes: 2 additions & 4 deletions src/components/Message.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<% } %>
<% if(showInfoList) { %>
<div>
<ul>
<% if(messageId) { %>
<li>Message ID: <%= messageId %></li>
<% } %>
Expand All @@ -33,17 +33,15 @@
</li>
<% } %>
<% if(correlationId) { %>
<ul>
<li>
Correlation ID: <%= correlationId?.location() %>
</li>
<% if(correlationId?.hasDescription()) { %>
<br />
<%- md.render(correlationId?.description()) %>
<% } %>
</ul>
<% } %>
</div>
</ul>
<% } %>
<% if(message.hasDescription()) { %>
<%- md.render(message.description()) %>
Expand Down
2 changes: 1 addition & 1 deletion src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ h1 {
}
.container {
display: flex;
overflow-x: hidden;
overflow: hidden;
}
.section {
flex: 0 0 100%;
Expand Down

0 comments on commit 6f7304e

Please sign in to comment.