I am trying to use OpenAPI generator to automatically generate C# client code based on a openapi: "3.0.2"
json configuration:
openapi-generator generate -i https://test.com/docs/swagger/openapi.json -g csharp-netcore -c open-api-config.json -o DataLakeOpenApiRestClient.cs
This fails with the following error:
[main] ERROR io.swagger.v3.parser.util.RemoteUrl - unable to read java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.security.ssl.SSLSocketImpl.connect(Unknown Source) at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.protocol.https.HttpsClient.(Unknown Source) at sun.net.www.protocol.https.HttpsClient.New(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source) at io.swagger.v3.parser.util.RemoteUrl.urlToString(RemoteUrl.java:147) at io.swagger.v3.parser.OpenAPIV3Parser.readWithInfo(OpenAPIV3Parser.java:123) at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:45) at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16) at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:586) at org.openapitools.codegen.cmd.Generate.run(Generate.java:395) at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
However if I download the json file and run using a local file input, it works fine:
openapi-generator generate -i open-api-offline-file.json -g csharp-netcore -c open-api-config.json -o DataLakeOpenApiRestClient.cs
I have tested this on a computer without a corporate proxy and it works properly, so my main suspect is the proxy.
I have set HTTP_PROXY
and `HTTPS_PROXY, but they are not used.
Question: How to use OpenAPI generator with corporate proxy?
-Djava.net.useSystemProxies=true
. I am wondering ifopenapi-generator
actually reads these options. Anyway, I think I can get the content via another command and use the offline generation. – Polk