tornado-swagger
tornado-swagger copied to clipboard
Unable to read api 'spec' from path http://localhost:7111/swagger/spec (server returned undefined)
Hi Serena,
Thank you for providing the tornado-swagger package :)
I try to run the example but opening the url http://localhost:7111/swagger/spec.html shows me the following message:
"Unable to read api 'spec' from path http://localhost:7111/swagger/spec (server returned undefined)"
Maybe you quickly see what I did wrong. I have attached my code below.
Thank you for any help.
Best Andreas
I tried to run the following code:
from tornado_swagger import swagger import tornado.web
swagger.docs()
class ItemNoParamHandler(tornado.web.RequestHandler): @swagger.operation(nickname='create') def get(self): """ @param body: create test results for a item. @type body: L{Item} @return 200: item is created. @raise 400: invalid input """ self.write("test")
def make_app(): return swagger.Application([ (r"/", ItemNoParamHandler) ])
@swagger.model class Item: """ @descriptin: This is an example of a model class that has parameters in its constructor and the fields in the swagger spec are derived from the parameters to init. @notes: In this case we would have property1, property2 as required parameters and property3 as optional parameter. @property property3: Item decription @ptype property3: L{PropertySubclass} """ def init(self, property1, property2=None): self.property1 = property1 self.property2 = property2
if name == "main": app = make_app() app.listen(7111) tornado.ioloop.IOLoop.current().start()
Hi Andreas,
Thanks for using tornado-swagger. About your problem, I think it is due to the version of tornado is not compatible, I have restricted the tornado version to be less than 4.3, and tested it locally. Hope it works fine in your place too, if not, please let me know, I will fix it ASAP.
Hi Serena,
Ah, I see. I'am using tornado version 5.0.2, so that is probably the problem.
However, I have problems to downgrade to tornado version < 4.3 as I run into a lot of dependency conflicts.
If you would have time to test it as well with higher versions of tornado would be great, I think your package could help a lot of users to work with Swagger.
Hi Andreas,
Thanks for your advice, I will look into it when I am available.