Swagger-codegen: [PHP] Add option to generate client without Guzzle

Created on 3 Apr 2017  路  3Comments  路  Source: swagger-api/swagger-codegen

Description

Follow up on discussions that took place in https://github.com/swagger-api/swagger-codegen/pull/5190 and https://github.com/swagger-api/swagger-codegen/issues/1482. In some cases dependency on guzzle may be a problem and it should be possible to use any other psr7-compatible client. Its should not be a big deal considering that generated client is already using psr7 compatible request and response objects.

Swagger-codegen version

2.3.0+

Swagger declaration file content or url

n/a

Command line used for generation

--library=none or something

Steps to reproduce

n/a

Related issues

https://github.com/swagger-api/swagger-codegen/pull/5190
https://github.com/swagger-api/swagger-codegen/issues/1482

Suggest a Fix

n/a

PHP Feature help wanted

Most helpful comment

unless you need async requests, i would not depend on the httplug client interface but the psr-18 interface directly, and psr-17 for the factory for requests.

php-http offers a bunch of clients implementing the client interface, and the next guzzle version is expected to implement psr-18 directly. the way to go would be to require a psr/http-client-implementation and then let the user configure the library with a client or potentially use php-http/discovery to automatically discover an available client.

All 3 comments

The best would be to use php-http directly as it provide HTTP client abstraction with PSR7 interfaces compliance and allows end user to choose which one to use: http://docs.php-http.org/en/latest/clients.html

It simple and used by a lot of PHP libraries now: https://packagist.org/packages/php-http/httplug/dependents

I see it was proposed in https://github.com/swagger-api/swagger-codegen/pull/5190/files#r108366631 but removed, why?

unless you need async requests, i would not depend on the httplug client interface but the psr-18 interface directly, and psr-17 for the factory for requests.

php-http offers a bunch of clients implementing the client interface, and the next guzzle version is expected to implement psr-18 directly. the way to go would be to require a psr/http-client-implementation and then let the user configure the library with a client or potentially use php-http/discovery to automatically discover an available client.

Would this be something to implement as an option, or just as another type of generated output? If I wanted to pay with this approach, is there any way to wrap the output as a plugable module? I can imagine there are many dozens of generated code that people may want to produce (for example, I would like to generate just the message generation without any client) so there is surely a way that can be done without forking and modifying the whole application?

Was this page helpful?
0 / 5 - 0 ratings