An experimental TypeSpec syntax for Lexicon
README.md

Lexicon Spec Test Fixtures#

This directory contains test fixtures organized by ATProto Lexicon specification features, not by real-world examples.

Organization#

Each subdirectory focuses on a specific feature from the Lexicon spec:

  • union/ - Union type features (open, closed, variants)
  • string-constraints/ - String knownValues, enum, formats
  • validation/ - Constraints (min/max length/value, graphemes)
  • primary-types/ - Record, query, procedure, subscription
  • field-types/ - Primitive types and their features
  • refs/ - Reference patterns (local, cross-namespace)
  • nullable/ - Nullable field handling
  • unknown/ - Unknown type usage
  • tokens/ - Token definitions and usage
  • binary/ - Blob and bytes types
  • evolution/ - Schema evolution patterns

Purpose#

Unlike test/scenarios/atproto/ which tests real ATProto lexicons, these fixtures:

  1. Test each spec feature in isolation
  2. Demonstrate minimal, focused examples
  3. Serve as documentation for TypeSpec → Lexicon mappings
  4. Catch edge cases and corner cases in the spec

Example Structure#

Each feature directory contains:

  • input/*.tsp - TypeSpec definitions for that feature
  • output/*.json - Expected Lexicon JSON output

Tests should be atomic and focus on one feature at a time.