Git Product home page Git Product logo

Comments (6)

ShellCode33 avatar ShellCode33 commented on June 12, 2024 1

I'm facing the same issue, openapi-generator-cli is not using the proxy, therefore it is unable to download the jar file from maven.

This might be related: axios/axios#2072

EDIT: it might actually be related to the HTTP method used to go through the proxy. If you use a proxy that simply forwards requests it will work (for http, not for https), but if your proxy relies on the CONNECT method and denies other methods (which is usually how corporate proxies work), it won't work.

The workaround seems to be:

const HttpsProxyAgent = require('https-proxy-agent');

const axiosDefaultConfig = {
    baseURL: 'https://domain.tld/api',
    proxy: false,
    httpsAgent: new HttpsProxyAgent('http://127.0.0.1:8080')
};

Of course the HTTPS_PROXY environment variable should be used.

from openapi-generator-cli.

wing328 avatar wing328 commented on June 12, 2024 1

please open a PR to start with and we'll start from there.

from openapi-generator-cli.

wing328 avatar wing328 commented on June 12, 2024

@mdgilene thanks for reporting the issue.

@keks42 is that something you can take a look when you've time?

from openapi-generator-cli.

keks42 avatar keks42 commented on June 12, 2024

@wing328 Thanks for highlighting me, I can try, but unfortunately I could not reproduce the problem :(

@mdgilene Thanks for reporting the issue.

I tried to reproduce it, but for me everything seems to work fine. Here is what I did:
I locally started a proxy server [1] that just logs & forwards everything. Then I started some minimum working example, I just checked out some project using this library [2]. The project uses openapi-generator-cli in an older version, so I upgraded it to use 2.7.0. Without configuring any proxy stuff that project worked fine. There were no connections shown in the proxy.

Then I proceeded to set the proxy environment:
$ export HTTP_PROXY=http://localhost:1080
$ export HTTPS_PROXY=http://localhost:1080

I removed the node_modules in that project to have a clean start again and executed the generation task again npm run generate:api. It worked fine and on my proxy there were 2 requests shown trying to connect mavencentral to download the openapi jar. I got a 501 because the local proxy forwarded the actual https request as http, but that is an issue of my local proxy configuration - the openapi-generator-cli did use the proxy.
Then I added the downloadUrl to use my companies own maven-repository (which still does accept http calls unlike mavenCentral) and that worked fine. The requests were shown in the proxy logs and the jar was downloaded & executed.

Long story short: What can I do to reproduce your error?

[1] https://www.mock-server.com/mock_server/mockserver_ui.html
[2] https://github.com/kevinboosten/angular-openapi-demo

from openapi-generator-cli.

jontze avatar jontze commented on June 12, 2024

I ran into this issue as well. Based on what @ShellCode33 pointed out ( #714 (comment) ) and the initial implementation 66b78ff , I was able to resolve it with the following code:

// apps/generator-cli/src/app/app.module.ts
import { HttpsProxyAgent } from 'https-proxy-agent';

const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
const httpModuleConfig: HttpModuleOptions = {};

if (proxyUrl) {
  httpModuleConfig.proxy = false;
  httpModuleConfig.httpsAgent = new HttpsProxyAgent(proxyUrl);
}

@Module({
  imports: [
    HttpModule.register({
      ...httpModuleConfig,
    }),
  ],
  // ...
})
export class AppModule implements OnApplicationBootstrap {
 // ...
}

However, I just noticed that there's also a draft pull request with a similar approach: #752 . I'm thinking about opening another PR, but unfortunately I'm not that deep into proxies and not too sure if my implementation might break things... 😅

from openapi-generator-cli.

github-actions avatar github-actions commented on June 12, 2024

🎉 This issue has been resolved in version 2.13.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

from openapi-generator-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.