shotstack / shotstack-sdk-php

PHP SDK for Shotstack, the cloud video editing API.
https://shotstack.io/product/sdk/php/
11 stars 5 forks source link

Setting model constructor values to null #24

Closed IKancijan closed 2 years ago

IKancijan commented 2 years ago

While parsing a template, some of the model's default values break the output. Any invalid properties should be dealt with subsequently

jeffski commented 2 years ago

Thanks will investigate this request, we are aware parsing a template has some issues, particularly around the assets. The default values can be set to null potentially. The ObjectSerializer file is generated by the OpenAPI Generator so it makes it more difficult to change that but will look in to it.

Do you have an example PHP script that will recreate your errors, so we can accelerate the investigation and test.

IKancijan commented 2 years ago

Unfortunately, I don't have a standalone script, but it's easy to recreate. I'm using one of your templates (https://shotstack.io/templates/startup-presentation/) JSON. I've extended ObjectSerializer and tweaked the deserialize() method you can see in this PR. Now, default model properties are assigned on construct which adds default values to properties that don't seem to be required by your documentation (fit, background, position...) and rendered media looks broken. I can set them to null, but unless I cross-reference the JSON template, I can't know if a value is valid or not.

jeffski commented 2 years ago

@IKancijan I had a quick look at this and it works nicely. I was able to get it to work without setting all the default values to null in the assets and timeline. I used the startup presentation JSON file as an example and it all seemed to work OK. Please can you confirm if there are cases where those values need to be set as null?

IKancijan commented 2 years ago

@jeffski sorry for waiting. The problem is when I deserialize the template, I get values like "fit" => "crop" which are added by default if "fit" is not set in the template and that causes problems. I know adding a proper "fit" value solves the problem, but if I can render a video without them, I should be able to deserialize the template without default values being added, no?

jeffski commented 2 years ago

We have just released this: https://github.com/shotstack/shotstack-sdk-php/releases/tag/v0.2.2.

It sets all the values to null and does not set defaults. It still doesn't fix the issue with serializing but will investigate that one soon.

IKancijan commented 2 years ago

Thank you!