Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets not loading from object #11

Open
emilsedgh opened this issue Nov 26, 2021 · 3 comments
Open

Assets not loading from object #11

emilsedgh opened this issue Nov 26, 2021 · 3 comments

Comments

@emilsedgh
Copy link

Using editor.constructFromObject to populate a whole editor fails on Assets.

From what I'm seeing here, this fails because at here, it's obvious that Asset can't really populate from an object.

It appears that for each asset, there is a different model defined, like LumaAsset or TitleAsset.

But the Clip model doesn't really distribute the asset to any of them. Instead it goes directly to Asset model, which does nothing.

I think Asset.constructFromObject should be able to see the type, and based on that, invoke another model.

I would normally provide a pull request, but this is all auto-generated so I have no idea how to fix this.

@jeffski
Copy link
Member

jeffski commented Nov 26, 2021

Hi @emilsedgh,
There is actually a big bug in the generator. The Clip when generated is trying to load a file model/OneOfVideoAssetImageAssetTitleAssetHtmlAssetAudioAssetLumaAsset for the assets, but this file is never actually created. It obviously does not know how to handle Swagger/OAS3 oneOf types.

To work around that we just created the Assets.js file and updated the references to it. We have to manually update this part of the codebase every time anyway along with one or two other things.

If you wanted to submit a pull request that would be awesome. We'll work it in with the generated code each time which we do anyway right now until we can fully automate it.

It would be great if you could submit a pull requ

@emilsedgh
Copy link
Author

I'll try to come up with a patch soon. Is there any similar bug that'd prevent constructFromObject working reliably? I'm trying to figure out if I can rely on it or I should switch to imperative function calls.

@jeffski
Copy link
Member

jeffski commented Nov 26, 2021

I never used constructFromObject or tried to work it out to be honest, which is why it never got any attention or checks. Most users just use the classes similar to how we use them in our demo project, like this: https://github.com/shotstack/node-demos/blob/main/examples/images.js.

The other way is to skip the SDK and just JSON.stringify the whole edit object and use fetch or axios to post to the API.

If you don't get a chance to look at it I will see what I can do in the next SDK update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants