marcin maruszewski → created an issue.
It's done.
marcin maruszewski → created an issue.
@prudloff, do you have any update regarding different hashes on AssetControllerBase::deliver? I think I'm having the same issue. We use Cloudfront for caching website and JS assets can't be cached due to Cachecontrol: private, no-store
headers.
I also found this interesting library - https://github.com/maasglobal/io-ts-from-json-schema. But it seems that when I try to generate type from https://isobar-playground.github.io/jsonapi/action/action/resource/schema/ it fails with the following error:
Error: properties keyword is not supported outside explicit object definitions. See https://github.com/maasglobal/io-ts-from-json-schema/issues/33
To be honest, I'm quite sad that (according to https://dri.es/headless-cms-rest-vs-jsonapi-vs-graphql) Drupal maintainers chose JSON:API as the main headless solution and didn't check if there was a solution for this problem for such a long time (the post is from more than 5 years ago). It looks like "on paper" JSON:API looks great (and I agree), but there are no ready-made tools for PHP programmers to jump into TypeScript and get all the benefits of it, like the discussed codegen for types.
But I also understand and appreciate the work of the people behind the API Client initiative and JSON:API. I just hope that one day there will be an out-of-the-box solution to this problem.
FYI, I have created this GitHub page - https://isobar-playground.github.io/jsonapi/
It contains all the /schema routes generated with https://www.drupal.org/project/jsonapi_schema → for a fresh Drupal installation with a Blog content type with field_hero_image media reference. It may be helpful in explaining what Drupal can produce in terms of JSON:API schema files. Feel free to use it.
But TBH I think there is some confusion in creating schema with jsonapi_schema module, and output from /jsonapi pages. I used https://www.jsonschemavalidator.net/s/qpgAL5KB to validate Drupal node against generated schema and it failed. But if I just pass JSON from data then it also fails, but with some "normal" issues like missing log message or invalid type for timestamp fields. Is this how the JSON:API works?
While searching for a solution, I came across the https://github.com/glideapps/quicktype library. It provides a CLI for generating TypeScript interfaces/types from JSON files.
I created a JSON file from /jsonapi/node/blog/resource/schema and ran
quicktype --no-combine-classes --nice-property-names -o types/blog.ts schema/blog.json
.
As you can see, there are some wired interfaces like FluffyData or PurpleProperties. Also, despite the --no-combine-classes flag, some classes are combined into one, like DrupalInternalNid.
But there are some advantages like Convert class witch to my understanding acts like a parser.
Is this knowledge helpful for this topic?
Is there a roadmap for this issue? I ask because I've been thinking for a while about creating some sort of example of Drupal's ability to use JSON:API and Typescript in NextJS, but I don't quite know how to combine it.
I've been looking at jsonapi_schema and json-schema-to-typescript, but I can see that at this stage these are not things that would make working with types easier. They generate weird field names, weird types and don't give you the ability to link entities to each other. Or at least I don't know how to do that.
I'll be watching with interest to see further progress on this topic.
Hi natts, thanks for contributing to the Drupal community by creating and maintaining this module. I've been trying to use it, but I'm forced to use only "green" stable module releases in my project. Is there any chance of releasing v3.0.4 with the following fix https://git.drupalcode.org/project/link_icons/-/commit/beae788d9b91b4708...? I would really appreciate it!
Marcin Maruszewski → created an issue.
Marcin Maruszewski → created an issue.