Closed caroillemann closed 2 weeks ago
I never came across your issue.. I am sure that the assets have an ID, if nothing is selected I assume the entire field should be null
Yes, when you add an asset in the field, it has an ID and the object looks like this:
"file": {
"id": 17136175,
"alt": "",
"name": "",
"focus": "",
"title": "",
"source": "",
"filename": "https://a.storyblok.com/f/123456/482x482/9cb1e9ae94/transparent-png.png",
"copyright": "",
"fieldtype": "asset",
"meta_data": {},
"is_external_url": false
},
But if nothing is selected, you get this object where id
is null
:
"file": {
"id": null,
"alt": null,
"name": "",
"focus": null,
"title": null,
"source": null,
"filename": "",
"copyright": null,
"fieldtype": "asset",
"meta_data": {}
},
I'm experiencing an issue with the
id
field in the generatedAssetStoryblok
type.When I add a field of type 'Asset' in Storyblok and do not select an image, this is the JSON output I see when previewing the 'Published JSON':
As you can see, the
id
isnull
when no asset is selected. However, in the type generator code, theid
is included in the array ofrequired
fields: https://github.com/dohomi/storyblok-generate-ts/blob/f4d79806dc4d57568a9e317b0d30675f92929999/src/genericTypes.ts#L36Am I missing something, or do you agree this should be changed?
For additional context, here is a full Story object: