Skip to content

catalog.jsonSchema() does not describe the element-level on field #356

Open

Description

@hamzaPixl

Version: @json-render/core 0.21.0, @json-render/react 0.21.0

catalog.jsonSchema() describes type, props, children, visible, repeat… but not on, the top-level field that binds a component event to an action:

import { schema } from "@json-render/react/schema";
import { defineCatalog } from "@json-render/core";
import { z } from "zod";

const c = defineCatalog(schema, {
  components: { Button: { props: z.object({ label: z.string() }), description: "b", events: ["press"] } },
  actions: { go: { description: "g" } },
});
JSON.stringify(c.jsonSchema()).includes('"on"'); // false

Meanwhile validation rejects on placed inside props ("It should be a top-level field on the element"). A model given only the JSON Schema has no way to learn where on goes, so it either omits events or puts them in props and fails validation.

Suggestion: add on to the element schema, keyed by the component's declared events, with values referencing the catalog's actions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions