OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.68k stars 6.54k forks source link

[REQ] PHP Client/Server class property types #5349

Open xvilo opened 4 years ago

xvilo commented 4 years ago

Is your feature request related to a problem? Please describe.

Currently, PHP 7.4 has support for typed properties (see this RFC: https://wiki.php.net/rfc/typed_properties_v2). I think we should support this behind a feature flag.

Describe the solution you'd like

Add types to class properties, as we have them already as method arguments.

Additional context

This could be added for the following generators:

I could create this functionality for the Symfony Server if this is wanted, for the others I would hope others could contribute to this.

As an example, the current model output for the PHP Symfony server is: Screenshot 2020-02-17 at 16 37 37

What it could become afterward: Screenshot 2020-02-17 at 16 37 53

ybelenko commented 4 years ago

I would add typehinting to all current PHP generators without a feature flag. The biggest advantage to me as library creator is that I don't need to check income parameters anymore, PHP does it for me and throws TypeError exception.

Btw @xvilo, we have open PR #6620 with Symfony generator upgrade, you can test it, any feedback is welcome.

xvilo commented 4 years ago

Thanks @ybelenko, I can check sometime. Btw, I've already contributed the following change: #5348