pyopenapi / pyswagger

An OpenAPI (fka Swagger) client & converter in python, which is type-safe, dynamic, spec-compliant.
MIT License
384 stars 88 forks source link

Get a typeerror when using renderer #77

Closed YoooFeng closed 8 years ago

YoooFeng commented 8 years ago

Hi, recently i'm trying to use pyswagger(in python 2.7) to test my swagger spec. When i use renderer to test APIs, i got: TypeError: call() takes exactly 1 argument (2 given). My code is the same as the tutorial/render.md:

app = SwaggerApp.create('http://petstore.swagger.io/v2/swagger.json') client = Client() renderer = Renderer() input_ = renderer.renderall(app.s('user').post) resp = client.request(app.s('user').post(input))

I'm new in python, so who can tell me what's the problem?Thank you!

mission-liao commented 8 years ago

Sorry that the example for Render is invalid.....the correct one should be:

resp = client.request(app.s('user').post(**input_))

because the accepted parameter of Operation.call is **k. I'll fix this part in tutorial later. Thanks for reporting issues and welcome to python's world.

YoooFeng commented 8 years ago

Thank you so much for your response mission-liao, It works now!I am designing a tool that could autotest all APIs in swagger spec, it seems i have a long way to go :)

mission-liao commented 8 years ago

Ya, it would be a long way to go. Before cooking by yourself, did you try this one? https://github.com/Trax-air/swagger-tester. It looks like a new library but would be worth to try.

YoooFeng commented 8 years ago

Thank you for your advise, I will have a try!