Skip to content

Feature: Figma component descriptions #374

Description

@m-nti

Summary

Figma REST component and component-set metadata includes a description string, but Specs generation does not preserve it. Please add an optional component-level description field to the Specs schema and populate it from the selected Figma source record.

This would let generated specifications retain component guidance already authored in Figma without requiring consumers to maintain an out-of-schema companion artifact.

Current behavior

For a selected source node, the Figma file response exposes descriptions in one of two maps:

  • A standalone COMPONENT uses file.components[nodeId].description.
  • A COMPONENT_SET uses file.componentSets[nodeId].description.

Generated component output records the same node in metadata.source.nodeId and metadata.source.nodeType, but does not emit its description. The current Component schema has no description property and rejects additional root properties, so a consumer cannot add the value to api.yaml while retaining schema conformance. The configured transformer registry also provides no custom generation hook for this field.

A concrete example from our repo is Figma component-set node 3288:1275. Its REST metadata contains:

Radio Buttons allow users to select a single option from a set of multiple choices. Once selected, an option cannot be deselected without choosing another.

The generated Radio api.yaml identifies node 3288:1275 but contains no corresponding description.

Proposed schema

Add an optional string to the component definition:

export interface Component {
  title: string;
  description?: string;
  // existing fields
}

Equivalent JSON Schema shape:

{
  "description": {
    "type": "string",
    "minLength": 1
  }
}

Mapping rules

  1. Use the source node selected for the generated component.
  2. For COMPONENT_SET, read componentSets[nodeId].description.
  3. For COMPONENT, read components[nodeId].description.
  4. Trim leading and trailing whitespace.
  5. Omit description when the source value is absent or whitespace-only; do not emit an empty string.
  6. Preserve meaningful internal line breaks and Unicode.
  7. With split concerns enabled, place description in api.yaml because it describes the component API/documentation surface rather than variants, examples, or styling.
  8. With non-split output, place it on the component root.

Compatibility

The field is optional and additive. Existing documents remain valid, existing consumers can ignore it, and generators continue producing the same output for Figma components without descriptions.

Acceptance criteria

  • The Component TypeScript type and JSON Schema expose description?: string.
  • Figma REST generation covers both COMPONENT and COMPONENT_SET source records.
  • Split-concern generation writes the field to api.yaml.
  • Non-split generation writes the field to the component root.
  • Empty descriptions are omitted.
  • Multiline and Unicode descriptions round-trip through YAML and JSON serialization.
  • Schema, transformer, split-output, and documentation tests cover the new field.
  • The Component schema documentation and generate command documentation describe the behavior.

Consumer workaround

Until native support is available, our repo generates a schema-valid description.yaml beside each api.yaml, joined through metadata.source.nodeId and metadata.source.nodeType. Native support would allow that companion generator to be removed without migrating the description content itself.

Activity

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

Metadata

Metadata

Assignees

Labels

figma-from-specsTransformer from specs into Figma assetsschemaspecs-schema types and JSON schemaspecs-from-figmaTransformer from Figma into specs

Fields

Priority

High

Projects

  • Status
    In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions