DoclerLabs / api-client-generator

API client generator is a console application capable of generating an API client based on OpenAPI(Swagger) specification.
MIT License
34 stars 19 forks source link

Readd json serialize on schema objects to simplify json encoding them #17

Closed vsouz4 closed 3 years ago

vsouz4 commented 3 years ago
mikemadisonweb commented 3 years ago

The PR looks sane. @vsouz4 What about breaking change that @ivastly mentioned in the previous PR? With array of arrays instead of an array of entities? Is it valid? Unfortunately, I don't have a real client now to test it.

vsouz4 commented 3 years ago

The PR looks sane. @vsouz4 What about breaking change that @ivastly mentioned in the previous PR? With array of arrays instead of an array of entities? Is it valid? Unfortunately, I don't have a real client now to test it.

I've spoken with @ivastly seems like he had some code like

array_map(
    static function (SomeObject ...) {
        ...
    },
    $someCollection->toArray()
)

and had to change ->toArray() to $someCollection->getIterator()->getArrayCopy() or iterator_to_array($someCollection). Turns out the change I've introduced on that previous PR (3.0.3) should've been made together with the major version 3.0.0 update, because with the lack of jsonSerialize, we had to start using toArray to serialize our objects, and we needed toArray to call inner toArray's as well otherwise we would need to recursively/manually serialize these inner objects.