ErikWittern / openapi-snippet

Generates code snippets for given Swagger / Open API documents
MIT License
115 stars 66 forks source link

update httpsnippet to v3.0.1 to allow node v20 #98

Open noghartt opened 7 months ago

noghartt commented 7 months ago

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

MaximeCheramy commented 7 months ago

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) {