Skip to content

Add API support for component props #170

@wise-king-sullyman

Description

@wise-king-sullyman

Problem Statement

Component props documentation is currently generated via npm run build:props and accessible through a standalone /props?components=... endpoint. However, this doesn't integrate with the hierarchical API structure used for content navigation (/api/[version]/[section]/[page]).

Goal

Integrate component props data into the versioned, hierarchical API structure to enable consumers to fetch props alongside or separately from component documentation content.

Proposed Solution

Add a props endpoint that aligns with the existing API hierarchy:

GET /api/v6/components/alert/props → Returns props for the Alert component

Completion Criteria

  • API Route Created

    • Create /api/[version]/[section]/[page]/props.ts route
    • Route returns JSON array of props objects from props.json
    • Lookup is case-insensitive (e.g., alert, Alert, ALERT all work)
  • Error Handling

    • Return 404 when props don't exist for the requested component
    • Return appropriate error messages for invalid paths
    • Handle cases where props.json hasn't been generated
  • Documentation

    • Update README.mdx with new props API endpoint
    • Update the api index route
    • Update OpenAPI spec in /api/openapi.json.ts if applicable
  • Testing

    • Test valid requests
    • Test error cases (missing props, invalid paths)
    • Verify integration with existing build:props workflow
  • Backwards Compatibility

    • Existing /props?components=... endpoint continues to work
    • No breaking changes to props.json structure
    • Works whether props.json exists or not (graceful degradation)

Out of Scope

  • Changes to the build:props command or props generation logic
  • Automatic props generation during build (optional enhancement for later)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Ready to assign

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions