openapi-snippet icon indicating copy to clipboard operation
openapi-snippet copied to clipboard

update httpsnippet to v3.0.1 to allow node v20

Open noghartt opened this issue 1 year ago • 2 comments

related to this issue https://github.com/ErikWittern/openapi-snippet/issues/99

noghartt avatar Jan 16 '24 13:01 noghartt

I'm surprised that this would work. I use this patch on one of my projects:

diff --git a/node_modules/openapi-snippet/index.js b/node_modules/openapi-snippet/index.js
index ea07bdf..b71ab0b 100644
--- a/node_modules/openapi-snippet/index.js
+++ b/node_modules/openapi-snippet/index.js
@@ -9,7 +9,7 @@
 'use strict';

 const OpenAPIToHar = require('./openapi-to-har.js');
-const HTTPSnippet = require('httpsnippet');
+const { HTTPSnippet, availableTargets } = require('httpsnippet');

 /**
  * Return snippets for endpoint identified using path and method in the given
@@ -147,7 +147,7 @@ const formatTarget = function (targetStr) {
   const title = capitalizeFirstLetter(language);
   let library = targetStr.split('_')[1];

-  const validTargets = HTTPSnippet.availableTargets();
+  const validTargets = availableTargets();
   let validLanguage = false;
   let validLibrary = false;
   for (let i in validTargets) {

MaximeCheramy avatar Jan 31 '24 12:01 MaximeCheramy