Comments (6)
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.
Oh yes, it's using httplug interface and not PSR18, my bad, PR welcome then :p
from janephp.
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.
I'm giving a try at this issue 😉
from janephp.
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.
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)
- Bump nikic/php-parser to latest version HOT 1
- Jane 7.6.0 relies on Symfony 7.0? HOT 1
- Wrong type for array
- Endpoints uri's are not relative to the server>url
- OpenAPI 3.0 binary string format not supported properly HOT 2
- Nullable required properties during denormalization
- Config file .jane does not exist HOT 1
- Generated code is not compatible with `symfony/serializer` 7 HOT 3
- Endpoints with scalar return values have invalid return types
- JsonSchema DenormalizerGenerator does not unset data in else branch
- Uncaught Error: Call to undefined method `Jane\Component\JsonSchemaRuntime\Reference::getDefault()` in `NonBodyParameterGenerator.php:164`
- Deprecations for GenerateCommand::configure()
- Classmaps are generated all in one line, creating giant diffs on update HOT 5
- Content */* breaks generated Endpoint PHP class
- Support for +json types
- Produce a BadResponseException and use it in transformResponseBody()
- JaneObjectNormalizer::getSupportedTypes needs to be produced multiline same as normalizers before HOT 2
- createNormalizationValueStatement does not handle nullable object in DateType and DateTimeType
- Paths with singular and plural names will result in duplicate methods
- AddHostPlugin not taken into account when custom client supplied HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from janephp.