swagger-api / swagger-api/swagger-parser
HTTP 401 even after adding AuthorizationValue in SwaggerParser().read()
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
I'm able to access the Swagger end point from Postman but when i try the same from new SwaggerParser().read(), I get the following exception.
Note: The Readme also is not updated with the 3rd boolean parameter for new SwaggerParser().read()
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:1944)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1939)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1938)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1508)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:138)
at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:93)
at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:79)
at com.sudarsun.SwaggerParserTester.main(SwaggerParserTester.java:19)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://swaggerurl/v2/api-docs
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3051)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:300)
at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:135)
... 3 more```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at SwaggerParser.read(), Swagger20Parser.read(), and RemoteUrl.urlToString(), which appear in the reported stack trace, and inspect how AuthorizationValue is passed to the remote request. Reproduce the 401 case and check the README's documented read() signature; done means authenticated reads work as intended and the third boolean parameter is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100