SDC components: Fix JSON schema usage

Created on 8 January 2024, 11 months ago
Updated 6 February 2024, 10 months ago

Problem/Motivation

Hi,

We are building UI Patterns β†’ 2.x, based on SDC API, and we are using Prototype for testing our site building and contribution features (usage of SDC components in blocks, views, layouts, field formatters...).

Doing those tests, we have found some issues related to JSON schema usage.

Incorrect JSON schemas

Teaser component

tags prop schema has an unexpected "tags" property:

    tags:
      type: array
      title: Tags
      tags:
        type: object
        properties:
          title:
            type: string
          url:
            type: string

Proposal use "items" https://json-schema.org/understanding-json-schema/reference/array#items

    tags:
      type: array
      title: Tags
      items:
        type: object
        properties:
          title:
            type: string
          url:
            type: string

By the way, the Twig template is using title twice instead of url:

<a href="{{tag.title}}">{{tag.title}}</a>

One more thing...

On breadcrumbs component, items prop, the JSON schema is OK, but the related presenter template (breadcrumb.html.twig) is sending an incorrect data structure:

  • breadcrumbs prop instead of items
  • text properties instead of title.
{{
  include('prototype:breadcrumbs', {
    breadcrumbs: breadcrumbs,
    separator: '|',
  })
}}

Proposal: transform the data structure in the breadcrumb.html.twig template.

πŸ› Bug report
Status

Fixed

Version

5.2

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024