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

The properties of AssetStoryblok should be nullable. #112

Closed
ryami333 opened this issue Sep 3, 2024 · 0 comments · Fixed by #122
Closed

The properties of AssetStoryblok should be nullable. #112

ryami333 opened this issue Sep 3, 2024 · 0 comments · Fixed by #122
Labels
bug Something isn't working

Comments

@ryami333
Copy link

ryami333 commented Sep 3, 2024

The type of AssetStoryBlok (generated by generate-sb-types) is incorrect. When I leave an asset field empty then the body of that field's JSON looks like this:

{
  "id": null,
  "alt": null,
  "name": "",
  "focus": null,
  "title": null,
  "source": null,
  "filename": "",
  "copyright": null,
  "fieldtype": "asset",
  "meta_data": {}
}

Which does not match the shape of AssetStoryblok:

export interface AssetStoryblok {
  alt?: string;
  copyright?: string;
  id: number;
  filename: string;
  name: string;
  title?: string;
  focus?: string;
}

Related question - why does an empty asset field not just return null/undefined? Why does it return this phantom asset object? That seems like an API bug to me.

If this is intended behaviour, then AssetStoryblok's fields need to be made | null.

@ryami333 ryami333 added the bug Something isn't working label Sep 3, 2024
@ryami333 ryami333 changed the title The type of AssetStoryBlok The properties of AssetStoryBlok should be nullable. Sep 3, 2024
@ryami333 ryami333 changed the title The properties of AssetStoryBlok should be nullable. The properties of AssetStoryblok should be nullable. Sep 3, 2024
@Edo-San Edo-San linked a pull request Oct 2, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant