Skip to content

Commit

Permalink
Issue fix - "External refs not working #45"
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun-g committed Mar 26, 2019
1 parent 054da91 commit 0b080d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Swagger Viewer validates your documents against Swagger 2.0 and OpenAPI specific

## Releases

**v2.2.1 Changes**
* Fixed the external refs issue #45

Known Issue
* Validator still gives a warning on relative paths. Will be fixed in next version.

**v2.2.0 Changes**
* Support to configure default preview host (instead of localhost) - By [@beastoin](https://github.com/beastoin) [https://github.com/arjun-g/vs-swagger-viewer/pull/41](https://github.com/arjun-g/vs-swagger-viewer/pull/41)

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"theme": "dark"
},
"license": "SEE LICENSE IN LICENSE.md",
"version": "2.2.0",
"version": "2.2.1",
"publisher": "Arjun",
"engines": {
"vscode": "^1.23.0"
Expand Down Expand Up @@ -102,8 +102,8 @@
"@types/js-yaml": "^3.11.2",
"@types/node": "^10.5.5",
"@types/socket.io": "^1.4.36",
"@types/swagger-parser": "^4.0.2",
"typescript": "^2.8.3"
"@types/swagger-parser": "^4.0.3",
"typescript": "^3.3.4000"
},
"dependencies": {
"express": "^4.16.3",
Expand Down
4 changes: 2 additions & 2 deletions src/preview/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function activate(context: vscode.ExtensionContext){
let fileName = document.fileName;
let fileHash = hashString(fileName.toLowerCase());
let fileContent = getParsedContent(document);
previewServer.update(fileHash, fileContent);
previewServer.update(fileName, fileHash, fileContent);
const previewInBrowser: boolean = !!vscode.workspace.getConfiguration('swaggerViewer').previewInBrowser;
if(previewInBrowser){
new BrowserPreview(previewServer.getUrl(fileHash), fileName);
Expand All @@ -102,7 +102,7 @@ export function activate(context: vscode.ExtensionContext){
if (e.document === vscode.window.activeTextEditor.document) {
let fileName = e.document.fileName;
let fileHash = hashString(fileName.toLowerCase());
previewServer.update(fileHash, getParsedContent(e.document));
previewServer.update(fileName, fileHash, getParsedContent(e.document));
}
});
context.subscriptions.push(disposable);
Expand Down
7 changes: 5 additions & 2 deletions src/preview/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as vscode from 'vscode';
import * as express from 'express';
import * as http from 'http';
import * as socketio from 'socket.io';
import * as SwaggerParser from 'swagger-parser';

const SERVER_HOST = vscode.workspace.getConfiguration('swaggerViewer').defaultHost || 'localhost';

Expand Down Expand Up @@ -62,8 +63,10 @@ export class PreviewServer {
}
}

update(fileHash:string, content: any){
FILE_CONTENT[fileHash] = content;
async update(filePath: string, fileHash:string, content: any){
FILE_CONTENT[fileHash] = await SwaggerParser.bundle(filePath, content, {

} as any);
this.io.to(fileHash).emit('TEXT_UPDATE', content);
}

Expand Down

0 comments on commit 0b080d6

Please sign in to comment.