You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

autocomplete-openapi

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocomplete-openapi - npm Package Compare versions

Comparing version

to
0.1.5

src/snippets.js

2

package.json
{
"name": "autocomplete-openapi",
"version": "0.1.4",
"version": "0.1.5",
"description": "Autocompletes different parts of an OpenAPI spec",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,2 +7,3 @@ "use strict";

import { tokenizeHeader } from "./parse-request-header.js";
import { generateRequestHeader, generateResponseBody } from './snippets.js';

@@ -81,20 +82,44 @@ export class OpenapiAutocomplete {

let result = this.extractor.allProperties(
dataRef,
jsonParsedResult.path,
editingChunk.key || ""
);
if (editingChunk.editing === "key") {
let result = this.extractor.allProperties(
dataRef,
jsonParsedResult.path,
editingChunk.key || ""
);
if (editingChunk.key === null) {
// If there is no key, then we should autocomplete with open quote
if (editingChunk.key === null) {
// If there is no key, then we should autocomplete with open quote
result = result.map((s) => '"' + s + '": ');
} else {
// If there is a key, then we should autocomplete with closing quote only
result = result.map((s) => '"' + s + '": ');
} else {
// If there is a key, then we should autocomplete with closing quote only
result = result.map((s) => s + '": ');
result = result.map((s) => s + '": ');
}
return result;
}
return [];
}
return result;
getSnippets() {
let completions = [];
for (let method of this.methods) {
let [insertText, completionCount] = generateRequestHeader(method);
const dataRef = method.body;
if (dataRef) {
let current = this.extractor.objectByRef(dataRef);
const generatedBody = generateResponseBody(current, completionCount);
insertText += "\n" + generatedBody;
}
completions.push({
label: method.operationId,
documentation: method.summary,
insertText: insertText,
});
}
return completions;
}
}
export class OpenAPIMethod {
constructor(method, path, body, operationId, tags) {
constructor(method, path, body, operationId, tags, parameters,summary) {
this.method = method;

@@ -8,2 +8,4 @@ this.path = path;

this.tags = tags;
this.parameters = parameters;
this.summary = summary;
}

@@ -30,3 +32,5 @@ }

this.openapi.paths[path][method].operationId,
this.openapi.paths[path][method].tags
this.openapi.paths[path][method].tags,
this.openapi.paths[path][method]?.parameters,
this.openapi.paths[path][method].summary
)

@@ -33,0 +37,0 @@ );

@@ -24,3 +24,3 @@ "use strict";

if (method.path == '/telemetry'){
assert.equal(method.tags[0], 'service')
assert.equal(method.tags[0], "Service");
}

@@ -27,0 +27,0 @@ }

Sorry, the diff of this file is too big to display