Swagger.json read () method failing

40 views
Skip to first unread message

Shreejit Nair

unread,
Jul 8, 2016, 12:17:58 PM7/8/16
to Swagger
Hi,

My Swagger.read(some json path) always returns some error or returns null.
However, the petstore.json works correctly and returns the swagger object correctly

Swagger swagger = new SwaggerParser().read(url); // Does not seem to be working for me


Tried with:

1. http://ipaddress/TomcatWebAppForChefNode/swagger.json

returns null


2. http://somepath/swagger.json

Throws errors like:

java.io.IOException: Invalid Http response

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1343)

at io.swagger.parser.util.RemoteUrl.urlToString(RemoteUrl.java:130)

at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:81)

at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:64)

at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:52)


3. Works fine with: 

http://petstore.swagger.io/v2/swagger.json returns a swagger object of the entire stuff correctly


Please let me know if there is a spec i should be referring to as a template.


Regards,

Shreejit

lsa...@genexus.com

unread,
Jul 8, 2016, 12:26:07 PM7/8/16
to Swagger
Hi, I tried your json at Swagger Editor and it has two errors.

Maybe that´s the issue

Shreejit Nair

unread,
Jul 8, 2016, 1:29:32 PM7/8/16
to Swagger
Thanks a lot,
Is there a tool or UI that can help validate my Swagger to see if its compliant?
Since i am converting the spec into an object and extracting everything using the read() method call.
getBasePath,getOperations,getParameters and all that

It is critical for me to ensure the Swagger.json itself is valid before all this works

lsa...@genexus.com

unread,
Jul 11, 2016, 8:54:30 AM7/11/16
to Swagger
Sure, you can use http://editor.swagger.io/
Reply all
Reply to author
Forward
0 new messages