Git Product home page Git Product logo

Comments (6)

joelwurtz avatar joelwurtz commented on September 20, 2024

This library already does that, or maybe i misunderstood something ?

Here we use PSR18 / PSR17 : https://github.com/janephp/janephp/blob/4.x/src/OpenApiRuntime/Client/Psr7HttplugClient.php#L32

And generated code will use httplug discovery package to automatically provide those objects:

see https://github.com/janephp/janephp/blob/4.x/src/OpenApi/Tests/fixtures/from-url/expected/Client.php#L42 for example

But it's a simple static create method, you can provide your own way of creating the Client by passing any PSR18 compatible client and PSR17 factory

from janephp.

joelwurtz avatar joelwurtz commented on September 20, 2024

Oh yes, it's using httplug interface and not PSR18, my bad, PR welcome then :p

from janephp.

judgej avatar judgej commented on September 20, 2024

Cool. I'll have a play and go from there :-)

So many libraries (in fact ALL OpwnAPI generated libraries, just about ALL SDKs provided by services and payment gateways) tightly bind the client and message factories, making them much more difficult to integrate into some other libraries and applications. PSR-7+PSR-17+PSR-18 really put some focus on handling these as completely different things. There are HTTP messages (requests and responses) and a client to throw them out and get a response). Those concerns should never be built into the same package IMO, and now they can be separated nicely through the approved PSRs. Sorry, ranting, but I think there is a bright future for APIs and a definite better way of approaching them :-)

from janephp.

pyrech avatar pyrech commented on September 20, 2024

I'm giving a try at this issue 😉

from janephp.

judgej avatar judgej commented on September 20, 2024

I've got a Xero client here in which I have made an attempt at PSR-18/17 discovery. I'm not convinced I have it right, as I have not quite put my hands on what the standard or most accepted way to do this is. Ideally a library doing API calls can be given a PSR-17 message generator and PSR-18 client, and won't need any further dependencies on implementations or discovery libraries.

But what is discovery is needed? Is there then a discovery needed for the discovery libraries? How deep does that particular rabbit hole go? Anyway, there may be something you can use in that Xero client, even if it's an example of how not to do it!

from janephp.

pyrech avatar pyrech commented on September 20, 2024

FYI, I made a PR to add support for PSR 18 client generation (#120). I kept the dependency on php-http/discovery because they already provides a PSR17 factory discovery which is quite complete IMO.

from janephp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.