Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to execute openapi-generator-cli version[BUG] #390

Open
ralphflat opened this issue Jun 22, 2021 · 22 comments
Open

Unable to execute openapi-generator-cli version[BUG] #390

ralphflat opened this issue Jun 22, 2021 · 22 comments
Assignees
Labels
bug Something isn't working

Comments

@ralphflat
Copy link

ralphflat commented Jun 22, 2021

Using version 2.3.5 of openapi-generator-cli in the Node environment, I am getting the error shown below. Googling, I found bug #130 in this issue database. This issue states that a solution was put in place, but does not provide any guidance on how to implement the solution.

[rflatau@localhost server]$ npx @openapitools/openapi-generator-cli version
Unable to query repository, because of: "Request failed with status code 501"

Response:
server squid/3.4.8
mime-version 1.0
date Tue, 22 Jun 2021 13:39:33 GMT
content-type text/html
content-length 3484
x-squid-error ERR_UNSUP_REQ 0
vary Accept-Language
content-language en
x-cache MISS from intergate2
x-cache-lookup NONE from intergate2:3132
via 1.1 intergate2 (squid/3.4.8)
connection close

(node:35812) UnhandledPromiseRejectionWarning: TypeError: error.response.data.on is not a function
    at VersionManagerService.printResponseError (/home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/main.js:922:33)
    at /home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/main.js:828:18
    at /home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:46
    at OperatorSubscriber._this._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:38:21)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:35812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:35812) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The referenced bug report seems to imply that proxy settings might be the problem. Investigating now how to deal with specifying the proxies. We are behind a corporate proxy. I have tried setting http_proxy and https_proxy environment parameters without success. I believe that there is a way to configure the openapi-generator-cli to deal with proxies, but I have not been able to find this.

I found two configurations within the referenced bug report: here and here. But no details on the structure of the configuration file.

What is the configuration needed to get the command below work? How do I augment the command to use the configuration file:

npx @openapitools/openapi-generator-cli version

@ralphflat ralphflat added the bug Something isn't working label Jun 22, 2021
@davesargrad
Copy link

davesargrad commented Jun 22, 2021

@ralphflat

I have this same problem. Thank you for taking the time to post this issue.

I think you will find that @kay-schecker provided you with the configuration that is closer to what you need. Notice his maven download.

"repository": {
      "downloadUrl": "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.0.0-beta2/openapi-generator-cli-5.0.0-beta2.jar?test123"
    },

5.1.1. seems to be the latest found here.

The 5.1.1 URL

@kay-schecker Could you please help us on this.

What is the minimal configuration that we need to specify the appropriate configuration?

@davesargrad
Copy link

davesargrad commented Jun 22, 2021

@ralphflat

I'm assuming that you can run with a command such as this:

npx @openapitools/openapi-generator-cli -c cfg.json version

Where cfg.json is the file containing something such as :

{
   "$schema":"node_modules/@openapitools/openapi-generator-cli/config.schema.json",
   "spaces":2,
   "generator-cli":{
      "version":"5.1.1",
      "repository":{
         "downloadUrl":"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123"
      }
   }
}

I've not actually tried this. I'm not sure what "test123" does.

Nor am I actually sure that the -c option is used to provide the configuration file seen above (I've not actually found a usage example).

I see -c referenced here, at this hyperlink for the generate directive. I'm not sure if this -c also works for the version directive.

@ralphflat
Copy link
Author

ralphflat commented Jun 22, 2021

I have tried the suggestion from @davesargrad above and get the following results (seems to be the same as original comment).
I also tried to use the help option on the command line with no result beyond an error very similar to below.

@kay-schecker please provide some guidance, as I am out of ideas as to what to try.

[rflatau@localhost server]$ npx @openapitools/openapi-generator-cli -c cfg.json version
Unable to query repository, because of: "Request failed with status code 501"

Response:
server squid/3.4.8
mime-version 1.0
date Tue, 22 Jun 2021 14:50:57 GMT
content-type text/html
content-length 3484
x-squid-error ERR_UNSUP_REQ 0
vary Accept-Language
content-language en
x-cache MISS from intergate2
x-cache-lookup NONE from intergate2:3132
via 1.1 intergate2 (squid/3.4.8)
connection close

(node:37076) UnhandledPromiseRejectionWarning: TypeError: error.response.data.on is not a function
    at VersionManagerService.printResponseError (/home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/main.js:922:33)
    at /home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/main.js:828:18
    at /home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:46
    at OperatorSubscriber._this._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:38:21)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
    at OperatorSubscriber.Subscriber.error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:80:18)
    at OperatorSubscriber.Subscriber._error (/home/rflatau/devel/learning_center-main/api/node_modules/rxjs/dist/cjs/internal/Subscriber.js:104:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37076) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:37076) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@davesargrad
Copy link

davesargrad commented Jun 22, 2021

@ralphflat

Actually you may need to simply edit openapitools.json as seen here. I think the -c option points to a yaml configuration that pertains only to the generator.

Other than that, I am not sure what to suggest at this point. Hopefully the author of the tool can help us.

@ralphflat
Copy link
Author

ralphflat commented Jun 22, 2021

Following the suggestion, I edited the openapitools.json, per @davesargrad's suggestion, and did not have the -c on the command line. The results are below.

[rflatau@localhost server]$ npx @openapitools/openapi-generator-cli version
Download 5.1.1 ...
Download failed, because of: "Request failed with status code 501"

Response:
server squid/3.4.8
mime-version 1.0
date Tue, 22 Jun 2021 15:17:14 GMT
content-type text/html
content-length 3444
x-squid-error ERR_UNSUP_REQ 0
vary Accept-Language
content-language en
x-cache MISS from intergate2
x-cache-lookup NONE from intergate2:3132
via 1.1 intergate2 (squid/3.4.8)
connection close

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!--
 /*
 Stylesheet for Squid Error pages
 Adapted from design by Free CSS Templates
 http://www.freecsstemplates.org
 Released for free under a Creative Commons Attribution 2.5 License
*/

/* Page basics */
* {
        font-family: verdana, sans-serif;
}

html body {
        margin: 0;
        padding: 0;
        background: #efefef;
        font-size: 12px;
        color: #1e1e1e;
}

/* Page displayed title area */
#titles {
        margin-left: 15px;
        padding: 10px;
        padding-left: 100px;
        background: url('http://www.squid-cache.org/Artwork/SN.png') no-repeat left;
}

/* initial title */
#titles h1 {
        color: #000000;
}
#titles h2 {
        color: #000000;
}

/* special event: FTP success page titles */
#titles ftpsuccess {
        background-color:#00ff00;
        width:100%;
}

/* Page displayed body content area */
#content {
        padding: 10px;
        background: #ffffff;
}

/* General text */
p {
}

/* error brief description */
#error p {
}

/* some data which may have caused the problem */
#data {
}

/* the error message received from the system or other software */
#sysmsg {
}

pre {
    font-family:sans-serif;
}

/* special event: FTP / Gopher directory listing */
#dirmsg {
    font-family: courier;
    color: black;
    font-size: 10pt;
}
#dirlisting {
    margin-left: 2%;
    margin-right: 2%;
}
#dirlisting tr.entry td.icon,td.filename,td.size,td.date {
    border-bottom: groove;
}
#dirlisting td.size {
    width: 50px;
    text-align: right;
    padding-right: 5px;
}

/* horizontal lines */
hr {
        margin: 0;
}

/* page displayed footer area */
#footer {
        font-size: 9px;
        padding-left: 10px;
}


body
:lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }
:lang(he) { direction: rtl; }
 --></style>
</head><body id=ERR_UNSUP_REQ>
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>

<div id="content">
<p>The following error was encountered while trying to retrieve the URL: <a href="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123">https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123</a></p>

<blockquote id="error">
<p><b>Unsupported Request Method and Protocol</b></p>
</blockquote>

<p>Squid does not support all request methods for all access protocols. For example, you can not POST a Gopher request.</p>

<p>Your cache administrator is <a href="mailto:Submit?subject=CacheErrorInfo%20-%20ERR_UNSUP_REQ&amp;body=CacheHost%3A%20intergate2%0D%0AErrPage%3A%20ERR_UNSUP_REQ%0D%0AErr%3A%20%5Bnone%5D%0D%0ATimeStamp%3A%20Tue,%2022%20Jun%202021%2015%3A17%3A14%20GMT%0D%0A%0D%0AClientIP%3A%2010.92.82.143%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2Fmaven2%2Forg%2Fopenapitools%2Fopenapi-generator-cli%2F5.1.1%2Fopenapi-generator-cli-5.1.1.jar%3Ftest123%20HTTP%2F1.1%0AAccept%3A%20application%2Fjson,%20text%2Fplain,%20*%2F*%0D%0AUser-Agent%3A%20axios%2F0.21.1%0D%0AConnection%3A%20close%0D%0AHost%3A%20repo1.maven.org%0D%0A%0D%0A%0D%0A">Submit</a>.</p>
<br>
</div>

<hr>
<div id="footer">
<p>Generated Tue, 22 Jun 2021 15:17:14 GMT by intergate2 (squid/3.4.8)</p>
<!-- ERR_UNSUP_REQ -->
</div>
</body></html>

(node:37381) UnhandledPromiseRejectionWarning: Error: Error: Unable to access jarfile /home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/versions/5.1.1.jar

    at /home/rflatau/devel/learning_center-main/api/node_modules/@openapitools/openapi-generator-cli/main.js:621:32
    at ChildProcess.exithandler (child_process.js:326:5)
    at ChildProcess.emit (events.js:376:20)
    at maybeClose (internal/child_process.js:1055:16)
    at Socket.<anonymous> (internal/child_process.js:441:11)
    at Socket.emit (events.js:376:20)
    at Pipe.<anonymous> (net.js:673:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37381) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:37381) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The original openapitools.json was empty. The openapitools.json, now, contains the following information:

[rflatau@localhost server]$ more openapitools.json
{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.1.1",
    "repository":{
       "downloadUrl":"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123"
    }
  }
}

@davesargrad
Copy link

davesargrad commented Jun 22, 2021

@ralphflat

Looks like you are now hitting a squid proxy properly.. It seems to be rejecting your request to download from maven.

@ralphflat
Copy link
Author

ralphflat commented Jun 22, 2021

I got some feedback from IT group monitoring the internet activity. The failed command above got the following error:

1624375550.827 0 10.92.82.143 TAG_NONE/501 3805 GET https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123 - HIER_NONE/- text/html

I executed a curl on the above URL:

curl https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.1.1/openapi-generator-cli-5.1.1.jar?test123 --output temp.tmp

I got the temp.tmp file generated. In addition, the IT guy saw the following messages:

1624390294.060    120 10.92.82.143 TCP_MISS/200 13683 CONNECT repo1.maven.org:443 - HIER_DIRECT/199.232.196.209 -
1624390317.424   2967 10.92.82.143 TCP_MISS/200 23915951 CONNECT repo1.maven.org:443 - HIER_DIRECT/199.232.196.209 - 

The failed log tried to do a GET on a https URL, while the success logs issued the CONNECT commands.

With the configuration file we are currently using, a maven repository is specified. I removed that from the configuration and got a different URL (https://search.maven.org/solrsearch/select?q=g:org.openapitools+AND+a:openapi-generator-cli&core=gav&start=0&rows=200 ), but still the same problem.

Could not find a way to prevent application from searching maven for updates. It seems like the openapi-generator-cli is trying to establish the "wrong" type of connection for https connection. I saw mention of use a -Dhttps.proxyHost and -Dhttps.proxyPort on the command line - tried that, as well as http.proxy* with no change in the results, as well as the same error messages in internet access logs. The curl command demonstrated that we could get the the firewall (also did a browser download), so this does not seem to be a proxy issue.

@davesargrad
Copy link

davesargrad commented Jun 22, 2021

@ralphflat

Until we get some guidance from @kay-schecker, I think perhaps you should try the openapi generator.. and bypass the openapi-generator-cli command line wrapper.

Download the latest jar, and use the java command directly.

@kay-schecker
Copy link
Contributor

Hi sorry for the late response. It's very difficult to debug such issues, because proxies often produce strange errors. I just found this article: https://stackoverflow.com/questions/27636360/squid-proxy-gives-501-on-get-request-made-by-python-but-not-curl

Could you try to create a short node.js script (using axios) to debug this issue within your network?

@davesargrad
Copy link

Hi @kay-schecker

I'll be glad to push that issue to our IT guys. Perhaps indeed it is in the configuration of the squid proxy. Good find.

@ralphflat
Copy link
Author

@kay-schecker

I asked our IT guy about this and he provided the following: "The web page referenced is correct that you cannot simply open a tcp connection to the proxy server and issue a GET command. For https sites you will have to use the proxy CONNECT method, and then you will have to negotiate TLS, and then you can issue your http GET command."

@Zialus
Copy link

Zialus commented Jul 6, 2021

Sorry to repost my request here, but seems like it was ignored last time and I've been using some workarounds in the meantime, such as unsetting the proxy env vars manually + using a private nexus repository.

But I'd still like to know if it would be possible to add the ability to respect the NO_PROXY env variable.

EDIT: BTW, I also have the same squid proxy issue when I try to download directly from the official nexus while using the corporate proxy.

@pstanoev
Copy link

pstanoev commented Jul 7, 2021

I am having similar issue. It is most likely that the NO_PROXY environment variable is not respected.

@naris
Copy link

naris commented Sep 25, 2021

I have a similar issue. I am completely unable to run openapi-generator-cli at all. Although I always get a 400 error instead of a 501. I am also behind a corporate proxy using windows 10. I have the proxy setup in windows and npm and everything else, other than openapi-genereator-cli has no issues :(

`╰─ npx @openapitools/openapi-generator-cli version ─╯
Unable to query repository, because of: "Request failed with status code 400"

Response:
cache-control no-cache
pragma no-cache
content-type text/html; charset=utf-8
proxy-connection close
connection close
content-length 513

(node:23516) UnhandledPromiseRejectionWarning: TypeError: error.response.data.on is not a function
at VersionManagerService.printResponseError (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\main.js:958:33)
at C:\src\metadater\node_modules@openapitools\openapi-generator-cli\main.js:864:18
at C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\operators\catchError.js:13:46
at OperatorSubscriber._this._error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\operators\OperatorSubscriber.js:38:21)
at OperatorSubscriber.Subscriber.error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\Subscriber.js:81:18)
at SafeSubscriber.__tryOrUnsub (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:205:16)
at SafeSubscriber.error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:156:26)
at Subscriber._error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:92:26)
at Subscriber.error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:72:18)
at OperatorSubscriber.Subscriber._error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\Subscriber.js:105:30)
(Use node --trace-warnings ... to show where the warning was created)
(node:23516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:23516) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

@naris
Copy link

naris commented Sep 25, 2021

If I disconnect my corporate VPN connection and remove the proxy setting I get this instead:
`╰─ npx @openapitools/openapi-generator-cli version ─╯
Unable to query repository, because of: "unable to get local issuer certificate"

Response:
(node:27980) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'headers' of undefined
at VersionManagerService.printResponseError (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\main.js:956:43)
at C:\src\metadater\node_modules@openapitools\openapi-generator-cli\main.js:864:18
at C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\operators\catchError.js:13:46
at OperatorSubscriber._this._error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\operators\OperatorSubscriber.js:38:21)
at OperatorSubscriber.Subscriber.error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\Subscriber.js:81:18)
at SafeSubscriber.__tryOrUnsub (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:205:16)
at SafeSubscriber.error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:156:26)
at Subscriber._error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:92:26)
at Subscriber.error (C:\src\metadater\node_modules\rxjs\internal\Subscriber.js:72:18)
at OperatorSubscriber.Subscriber._error (C:\src\metadater\node_modules@openapitools\openapi-generator-cli\node_modules\rxjs\dist\cjs\internal\Subscriber.js:105:30)
(Use node --trace-warnings ... to show where the warning was created)
(node:27980) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:27980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

@naris
Copy link

naris commented Sep 25, 2021

I managed to work around the issue by installing and using the previous version :
npm install @openapitools/openapi-generator-cli@previous

╰─ npx @openapitools/openapi-generator-cli version ─╯
4.3.1

@rdelhommer
Copy link

rdelhommer commented Oct 4, 2021

I was also able to find a workaround for this by manually setting the version in my openapitools.json file. The issue is happening when the npm wrapper tries to query the lastest available version of openapi-generator from maven. If you've set your version in openapitools.json, it wont run the query and will just download the jar file corresponding to the version you've chosen. So far I haven't had any issues with downloading the jar. Really only the query seems to be having issues

Example

{
    "generator-cli": {
      "version": "5.2.1"
    }
}

@kay-schecker
Copy link
Contributor

kay-schecker commented Oct 20, 2021

You could also disable ssl check, but only, if you know what you're doeing ;)
To do that across all operation systems just use: https://www.npmjs.com/package/cross-env

cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 openapi-generator-cli

@JohannesHoppe
Copy link

I looked a bit at the source code to find out how the proxy settings are used.

This is the place where it happens:

const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;

(see fix #130 & PR #139)

The environment variables HTTPS_PROXY and HTTP_PROXY are considered.
But as @pstanoev already assumed, the NO_PROXY environment variable is not respected. This must be taken into account and, if necessary, the environment variables must be set or removed accordingly.

@tapan-p
Copy link

tapan-p commented Dec 22, 2021

Meanwhile, I was able to generate the client using below steps. Basically skipping the wrapper and accessing jar directly.

  1. Download jar file with latest version from repository URL: https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.1/
  2. Run below command to generate the package (assuming you have java installed, json file for spec downloaded locally and jar file is downloaded).
    java -jar openapi-generator-cli-5.3.1.jar generate -g csharp-netcore -aditional-properties=targetFramework=net5.0 -i project.swagger.json -o ./Generated --skip-validate-spec

@mwiede
Copy link

mwiede commented Mar 1, 2022

As per yarnpkg/yarn#841 and nodejs/node-gyp#695 setting NODE_EXTRA_CA_CERTS fixed it for me.
I had already set cafile in .npmrc, but it seems this was ignored.

@artmotion
Copy link

I kinda still have this problem (and also being behind a very restrictive corp proxy).
I even put the 6.6.0.jar into the folder AND hoped for to just continue to generate the client, but it still tries to access the internet an returns with:

npx openapi-generator-cli generate 
Unable to query repository, because of: "connect ETIMEDOUT 34.238.74.221:443"

which is basically always an IP that points to AWS, which probably hosts the maven repo.

I also tried to specify an in-house maven repo, that has the file already, but it looks like the configuration is ignored or not picked up.

Is there anyway I can further debug this or set something like "DO_NOT_DOWNLOAD=true" to resolve this.
(Other than that, I will now download the jar with PowerShell and call the jar file with Java directly to generate the client).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests