Skip to content

Commit 8b1ffe8

Browse files
authored
fix: $ref not being rendered correctly (#240)
1 parent a7a2568 commit 8b1ffe8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/PreviewWebPanel.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from 'vscode';
22
import * as path from 'path';
3+
import * as fs from 'fs';
34

45
let position : {x:0,y:0} = {
56
x: 0,
@@ -105,6 +106,8 @@ function getWebviewContent(context: vscode.ExtensionContext, webview: vscode.Web
105106
);
106107
const asyncapiWebviewUri = webview.asWebviewUri(asyncapiFile);
107108
const asyncapiBasePath = asyncapiWebviewUri.toString().replace('%2B', '+'); // this is loaded by a different library so it requires unescaping the + character
109+
const asyncapiContent = fs.readFileSync(asyncapiFile.fsPath, 'utf-8');
110+
108111
const html = `
109112
<!DOCTYPE html>
110113
<html>
@@ -131,11 +134,9 @@ function getWebviewContent(context: vscode.ExtensionContext, webview: vscode.Web
131134
<script src="${asyncapiComponentJs}"></script>
132135
<script>
133136
const vscode = acquireVsCodeApi();
137+
const schema = ${JSON.stringify(asyncapiContent)};
134138
AsyncApiStandalone.render({
135-
schema: {
136-
url: '${asyncapiWebviewUri}',
137-
options: { method: "GET", mode: "cors" },
138-
},
139+
schema: schema,
139140
config: {
140141
show: {
141142
sidebar: true,

0 commit comments

Comments
 (0)