Description
Hi!
I'd like to use openapi-diff, but the access to my OpenAPI JSONs is protected by a Authorization (Bearer) token.
--header
seems to be a perfect fit:
docker run openapitools/openapi-diff --header "Authorization=Bearer ABCD" https://host1/v3/api-docs/app https://host2/v3/api-docs/app
Though i always end with stacktraces of
ERROR [io.swagger.parser.util.RemoteUrl] - unable to read
java.io.IOException: Server returned HTTP response code: 401 for URL: https://host1/v3/api-docs/app
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:138)
at io.swagger.parser.Swagger20Parser.readWithInfo(Swagger20Parser.java:44)
at io.swagger.parser.SwaggerParser.readWithInfo(SwaggerParser.java:34)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:89)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16)
at org.openapitools.openapidiff.core.OpenApiCompare.readLocation(OpenApiCompare.java:116)
at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:90)
at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:77)
at org.openapitools.openapidiff.cli.Main.main(Main.java:156)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://host1/v3/api-docs/app
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3061)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:305)
at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:135)
... 8 more
I tried various ways to pass in the --header
but only the format above is accepted - which makes sense looking at the code: https://github.com/OpenAPITools/openapi-diff/blob/master/cli/src/main/java/org/openapitools/openapidiff/cli/Main.java#L65
Though also looking at the code it seems that the header information is never passed on:
https://github.com/OpenAPITools/openapi-diff/blob/master/cli/src/main/java/org/openapitools/openapidiff/cli/Main.java#L156
A fix seems simple enough & I'm happy to provide PR; but am I missing something obvious that is missing?