Yelp/swagger-py — pull request #86 by dnephin (2014-12-27 22:59:09+00:00)
Title: Cleanup swagger client

Previously the entire process of fetching the api docs, validating the api docs, and building Resources/Operations was done as part of the constructor. Constructors should never do anything more than assignment. Complex constructors are difficult to test, and make re-use more difficult.

This branch splits the constructor into two factory methods `from_uri()`, and `from_resource_listing()`. This allows consumers to create a SwaggerClient from just a list of resources, which also removes the branch logic from the constructor. This is still backwards compatible because the only documented interface is the `get_client()` call.

Some other things:
* use simplejson if it's available (since it's much faster, and this is very slow)
* completely removed the need for `ClientProcessor` (yay less inheritance!). This subclass was only being used for the single method that it implemented. All other operations are already done by default by the `Loader`. That method was extracted to `append_name_to_api()`
* change the kwarg for the client cache to be `ttl` instead of `timeout` (`timeout` is still supported for backwards compatibility)
* `SwaggerClient`, `Resource`, and `Operation` now support `dir()` (and tab completion in ipython) without `setattr` (which was duplicating the `__getattr__`).

Resolves #80. Remove special case for `datetime` in `stringify_body`. This should be totally unnecessary. The `swagger_model` should already convert this datetime unto the proper format.

Resolves #76. Previously `api_base_path` was being used for two different things: overriding the default url that was specified in the swagger api doc, and also as a base url for swagger api docs that use relative urls. I've split this into two params. `api_base_path` is now only an override, `base_url` is now the base url to append to relatives `basePath` urls.

Resolves #83. `raise_with` is unnecessary, and makes the interface for `swagger-py` more verbose than it needs to be.

Sorry this is so big. Most of this had to be changed all at once, so I wasn't able to break it into smaller parts.