Open pwfff opened 8 years ago
Also, some problems with my current implementation:
Hi,
I just checked your code and felt surprised by the usage of exec, it's magic. Right now the design of pyswagger focus on correctness first, then is usage friendly. In your case, the code might not work when operationId is not assigned (it's an optional field of Operation object)
for op in self.app.op.values():
I will suggest you to try to create a scanner to collect Operation objects to your dict, indexed by any mean your like. Refer to this issue, an example implementation is there.
I've written a wrapper for working with pyswagger that makes it easier to call operations. Maybe someday you can include some of this to make calling a simple operation a bit easier. It has a lot of magic in it (the exec is ugly, I know), but it's the best way I could find to get functions with the right signature.
It's made just for my use case (single API token), but having the function signature be based off of the docs is helpful. It also has the docstring on it based off of the description from the swagger document (I suppose I should also have it fall back to summary if description is missing).
In the example below I can just call c.post_import(some_data=data) and it returns the response. I find this a lot easier than calling the operation to get the request/response tuple, and then calling client.