You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since we can't reply to #124 (@ob-stripe you can remove this issue if you want after reading it, I just wanted to show some research I've made around non-static methods generation)
This is not battle tested and strongly depends on OpenAPI definition quality but this is a very easy way to generate a Client based on an OpenAPI spec.
The text was updated successfully, but these errors were encountered:
Korbeil
changed the title
[Feature] Refactor to not use static method calls (quick showcase)
Refactor to not use static method calls (quick showcase)
Aug 8, 2019
Hi @Korbeil, thanks for sharing this! This looks very interesting, and close in concept to what we're trying to achieve.
As I briefly mentioned in the other thread, we're in the process of rolling out our own OpenAPI-based client library generator. We've chosen to write our own generator instead of using one of the many existing ones because 1/ we want to maintain a single codebase that will let us generate all our different client libraries (seven different programming languages at the moment, and we're looking to add more as the project matures) and 2/ we wanted to be able to generate libraries with APIs that are as close as possible to the existing manually written libraries.
Of course this would not prevent us from adding new APIs, i.e. in the case of PHP the plan is to add new non-static methods while still keeping backwards compatibility with the existing methods. It's too early to discuss any specific technical details, but I imagine it will look something like this:
// Existing static APIs, would still work
\Stripe\Stripe::setApiKey("sk_test_123");
$customer = \Stripe\Customer::retrieve("cus_123");
// New non-static APIs$stripe = new \Stripe\StripeClient("sk_test_123");
$customer = $stripe->customers->retrieve("cus_123");
where $stripe->customers would return an instance of a new CustomerService class that holds non-static methods for customer-related API requests.
I'm closing the issue but keeping this thread open, so feel free to reply!
Since we can't reply to #124 (@ob-stripe you can remove this issue if you want after reading it, I just wanted to show some research I've made around non-static methods generation)
I created a quick issue to showcase of Jane based on Stripe OpenAPI specification that I created some months ago for my own usage: https://github.com/Korbeil/stripe-php-api/
This is not battle tested and strongly depends on OpenAPI definition quality but this is a very easy way to generate a Client based on an OpenAPI spec.
We already made a client for the Slack API with their OpenAPI spec: https://github.com/jolicode/slack-php-api with Jane which is referenced by Slack as one of the Client to use when using PHP https://api.slack.com/community.
The text was updated successfully, but these errors were encountered: