The little schema that could (...but should it?)
summary
Uses Rails' schema.rb as the single source of truth to generate model validations (via columns and reflections), auto-create controllers/routes with metaprogramming, convert DB columns to OpenAPI JSON for docs, and emit TypeScript types with openapi-typescript; CI (GitHub Actions) runs diff checks to prevent drift and a tool generator builds callable AI tools from Swagger. Most pieces work and tests pass in the companion repo, but enums, check constraints and some edge cases remain unhandled. schema.rb as source of truth generates OpenAPI and TypeScript
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:06Schemas in databases
- 2:11Model validations from schema
- 8:31Why this approach questionable
- 8:51Controller boilerplate automation
- 13:07OpenAPI docs from schema
- 17:58Schema-driven documentation benefits
- 19:01OpenAPI to TypeScript types
- 22:12CI for schema drift
- 23:37Schemas for AI features
- 31:46Closing remarks
related talks
22mSpecification-Driven Development of REST APIs
39mAPI Development in 2017
30mRswag: Automated API Documentation
36mGraphQL Migration: A Proper Use Case for Metaprogramming?
23mBuilding APIs you want to hug with GraphQL
29mNever again without a contract: dry-validation
31mBuilding an OpenAPI from Typescript
43mAPI first with Swagger and Scala
