Skip to content

feat: MCD-1297: Add @schemaType so @schemaRef can point at object definitions. - #202

Open
drubot wants to merge 2 commits into
1.xfrom
feature/mcd-1297-schema-type
Open

feat: MCD-1297: Add @schemaType so @schemaRef can point at object definitions.#202
drubot wants to merge 2 commits into
1.xfrom
feature/mcd-1297-schema-type

Conversation

@drubot

@drubot drubot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

@schemaRef hard-coded type: 'string' on the generated prop definition. Canvas resolves a prop's storage from its JSON Schema type before it resolves the $ref, so a $ref pointing at an object definition never matched — only URI-ish string definitions were reachable.

A prop typed as a TypeScript interface carries no JSON Schema type of its own (mapVueTypeToJsonSchema falls through to string), so the type has to be stated explicitly. This adds a @schemaType JSDoc tag:

/**
 * Image
 * @schemaRef lupus_image/image
 * @schemaType object
 */
media?: LupusImage

It defaults to string, so every existing @schemaRef prop is unchanged.

This unblocks Drupal extensions shipping their own schema.json definitions — the json-schema-definitions://<extension>.module/<name> stream wrapper reads a schema.json from any extension root, not only Canvas. MCD-1297 uses it for a richer image object (media copyright / caption / source / focal point) than Canvas' built-in canvas.module/image.

Changes

  • @schemaType tag detection, validated against the JSON Schema primitive types; an unknown value warns and falls back.
  • Playground fixture prop (TestSchemaRefFile.richImage) exercising an object $ref.
  • Tests: object $ref honours @schemaType; @schemaRef without the tag still yields type: string.
  • README: tag list + a worked example.

Testing

npm run lint clean (5 pre-existing warnings in an untouched file). npm test — 130/130 pass, including the 2 new cases.

Refs: MCD-1297

Drafted with Claude Code from claude-vm-1.

loki et fago and others added 2 commits August 3, 2026 13:20
…nitions.

Canvas resolves a prop's storage from its JSON Schema type before resolving
the $ref, so an object definition only matches when the prop declares
type: object. A prop typed as a TypeScript interface carries no JSON Schema
type, so the type has to be stated. Defaults to string, which is what the
Canvas URI refs need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants