Spike: Investigate schema creation for bundles

Created on 25 July 2025, 10 days ago

We can now generate json schema on the fly for arbitrary PHP objects, but we need to figure out a way to generate a json schema for a bundle (or list of fields in a bundle) that will only include what we need to pass to AI.

The ways that I’ve found to generate lists of fields contain a lot of cruft. The best way I’ve found so far is \Drupal::service('entity_field.manager')->getFieldDefinitions('node', ‘[bundle]')
I’ve tried iterating through that to create a “clean” PHP object, but it’s going to be really complicated.

OTOH, I found this: Drupal core can now generate JSON Schemas for content entities . I’ve dug into it some. We might be able to do something like this:

\Drupal::service('serializer')->getJsonSchema([object])

but I haven’t tried it. And I don’t know what we would pass to it. It looks like this serialization is built into json api now, so it might be worth looking there to see how that module does it.

So, please:

Investigate to find the best way to create json schema out of a bundle / list of fields.

Generate a POC.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States majorrobot

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024