Schema-first API
Design Using
TypeSpec
Cailin Smith
Microsoft
Who am I?
Agenda
•TypeSpec basics
•TypeSpec
workflow
•How TypeSpec can
help you scale
TypeSpec
as a language
TypeSpec as a
language
•Models
•Operations/
Interfaces
•Decorators
•Importing
TypeSpec
as a platform
TypeSpec as a
platform
•Libraries
•Linters
•Emitters
MethodScript
TypeSpec
in API scale
Ultra-Small,
Small,
Medium
Large
Enterprise
TypeSpec
ecosystem
OpenAPI ->
TypeSpec
Custom TypeSpec
Libraries
.NET (C#)/Java Client
Generators
C#/JavaScript
Servers
JSON Schema /
Protobuf
Appendix
•https://typespec.io/
•https://github.com/microsoft/typesp
ec
•https://methodscript.com/

Editor's Notes

  • #2 Software Engineer in MDCN Internal backend api professional interest Not on TypeSpec team, no inside information on TypeSpec FORWARD LOOKING STATEMENTS ARE MY OWN OPINION
  • #3 How to use TSP – Small example How this can help you scale
  • #6 If you squint…
  • #8 Finite collection of named ordinals
  • #12 HTTP library
  • #13 These are imports for other files, but you can also import libraries Split up TypeSpec into different files
  • #16 Install npm install -g @typespec/compiler After that, it’s more or less an npm project package.json
  • #17 More generally, runs the emitter, doing whatever the emitter does. Can also be configured to run as part of the tsp config. Will show shortly what result is
  • #18 Installing IDE is recommended You can create your own linters too
  • #19 Playground on typespec.io
  • #20 My Programing Language Small API for managing telemetry and update checks
  • #22 Const types
  • #24 Unused parameter
  • #26 swagger-codegen-cli
  • #28 How can TypeSpec help you scale?
  • #29 Ultra-small doesn’t really matter what you do Even for ultra-small TSP overhead is minimal, most of the effort is in learning things 3-4 devs, 1 dev can spend a sprint getting things set up Tech lead responsible for API design 1 team with large API surface, multiple teams working on different APIs. No brainer to add automation – at least client, maybe server stubs
  • #30 A thousand endpoints/models No one person can keep full API in their head Introduce governance – architect or tech lead full time job Paradigms – standardized core business logic Less stuff in front brain, better review GOVERNANCE IS CRITICAL NO SPEC REVIEW AT PR LEVEL DOCS MOVE THROUGH TO EVERYTHING –ESPECIALLY SERVER
  • #31 30 loc tsp 60 loc openapi Main strength of tsp – no revolutionary architecture, but allows for scale
  • #32 Entire API governance team Entire team dedicated to TypeSpec tooling
  • #34 Budding ecosystem