Skip to content

Commit

Permalink
Better support for swagger import (#87)
Browse files Browse the repository at this point in the history
* Better support for swagger2/3 import

* bump axios version to 0.21.2 (security update)

* axios integrity

* npm publish is taking forever
  • Loading branch information
cedric05 authored Sep 11, 2021
1 parent 50d5014 commit e111d44
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [0.0.29]

- [**Improvement**] Better support for swagger import

## [0.0.28]

- [**Improvement**] export postman now generates filename with suffix ".postmancollection.json"
Expand Down
50 changes: 36 additions & 14 deletions package-lock.json

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

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dothttp-code",
"displayName": "Dothttp Http Client",
"description": "A Http Client for sending to and receiving from http endpoints (dothttp)",
"version": "0.0.28",
"version": "0.0.29",
"license": "Apache-2.0",
"publisher": "shivaprasanth",
"repository": {
Expand Down Expand Up @@ -520,11 +520,12 @@
"vscode-codicons": "0.0.14",
"vscode-test": "^1.5.0",
"webpack": "^5.26.3",
"webpack-cli": "^4.5.0"
"webpack-cli": "^4.5.0",
"@stoplight/json-schema-sampler": "0.2.0"
},
"dependencies": {
"@types/vscode": "^1.59.0",
"axios": "^0.21.1",
"axios": "^0.21.2",
"curl-to-har": "^1.0.1",
"curl-to-postmanv2": "^0.5.1",
"dateformat": "^4.5.1",
Expand All @@ -534,10 +535,10 @@
"mime-types": "^2.1.30",
"preact": "^10.5.13",
"semver": "^7.3.4",
"swagger2har": "^1.0.1",
"swagger-to-har2": "^1.0.3",
"tingodb": "^0.6.1",
"unzipper": "^0.10.11",
"uuid": "^8.3.2",
"whatwg-url": "^8.5.0"
}
}
}
12 changes: 6 additions & 6 deletions src/extension/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { load as loadYaml } from "js-yaml";
import { zip } from 'lodash';
import { platform } from 'os';
// @ts-expect-error
import { swagger2har } from 'swagger2har';
import { swagger2har } from 'swagger-to-har2';
import { promisify } from 'util';
import * as vscode from 'vscode';
import { ImportHarResult, TargetSymbolInfo } from '../lib/client';
Expand Down Expand Up @@ -200,20 +200,20 @@ export async function importRequests() {
}
const linkOrFile = await vscode.window.showQuickPick([{
label: "link",
description: "postman collection link",
description: pickType === importoptions.postman ? "postman collection link" : "swagger schema (json/yaml) link",
picked: true,
alwaysShow: true,
}, {
label: "file",
description: "file exists in local system",
description: pickType === importoptions.postman ? "postman collection (have <filename>.postman_collection.json file?)" : "swagger schema (have <swagger schema 2/3>.<yaml/json> file?)",
picked: false,
alwaysShow: true,
}]);
var filenameToimport: string | undefined;
if (linkOrFile) {
if (linkOrFile['label'] === 'link') {
filenameToimport = await vscode.window.showInputBox({
prompt: "postman link",
prompt: `${pickType === importoptions.postman ? "postman collection" : "swagger schema (json/yaml)"} link`,
ignoreFocusOut: true,
// validateInput: (value) => {
// if (value.startsWith("https://www.getpostman.com/collections") ||
Expand Down Expand Up @@ -274,8 +274,6 @@ or raise bug`);
vscode.window.showErrorMessage(`import ${pickType} failed with error ${error}. create bug`);
return;
}
} else if (pickType === importoptions.har) {
const swaggerInStr = await getFileOrLink(linkOrFile, filenameToimport);
}
}

Expand Down Expand Up @@ -308,6 +306,8 @@ async function importSwagger(data: any, filename: string, directory: string, pic
} else {
hardata = loadYaml(data);
}
} else {
hardata = data;
}
// figure file name from swagger info
var saveFilename;
Expand Down
2 changes: 1 addition & 1 deletion src/extension/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export enum Constants {
NOTEBOOK_ID = 'dothttp-book',

// download stuff
EXTENSION_VERSION = "0.0.28",
EXTENSION_VERSION = "0.0.29",

dothttpNotebook = "dothttp-book",

Expand Down

0 comments on commit e111d44

Please sign in to comment.