Description
First of all, thank you for this great project, the code is very nice and I think it really has a lot of potential.
Is your feature request related to a problem? Please describe.
As mentioned in #171, the current approach arguably needs a little too much boilerplate that could be avoided by adding a more object oriented Client
.
Describe the solution you'd like
- Add two new client interfaces,
SyncClient
andAsyncClient
that would wrap the currently generated tag packages in objects, and expose them as properties.
With that approach, a developer could call an endpoint with as little code as:
from petstore_client import SyncPetstoreClient # Named after the spec title, nicer if you import several auto-generated clients
client = SyncPetstoreClient("http://mypetstore")
pets = client.pets.list_pets()
-
One issue is that we loose the ability to statically tell the user that some endpoint requires an
AuthenticatedClient
or not... Some thinking required here I guess. -
Additionally, a default
base_url
could be provided through an environment variable named after the spec title, for instance:SWAGGER_PETSTORE_BASE_URL
. It could be nice to prevent microservices from using different naming conventions.
For reference, my crude attempt at implementing those interfaces is available here: https://github.com/upciti/openapi-python-client/tree/feature/0-boilerplate-clients.