Skip to content

Multi-File Output

For large specs, enable split-schemas to emit every schema into its own file under schemas/:

Terminal window
npx tsp compile api.tsp \
--emit @lars-artmann/typespec-asyncapi \
--option @lars-artmann/typespec-asyncapi.split-schemas=true

or in tspconfig.yaml:

options:
"@lars-artmann/typespec-asyncapi":
split-schemas: true
  • Every components.schemas entry becomes schemas/Name.yaml (or .json)
  • All $ref values are rewritten from #/components/schemas/Name to schemas/Name.yaml — in the main document and in the schema files themselves
  • The main document keeps channels, operations, messages, and all other components inline
  • Specs with dozens of schemas that become unreadable in one file
  • Review diffs that should show one schema per change
  • Downstream tools that consume per-schema files