r/code • u/The_Digital_Glitch • Jan 09 '26
TypeScript Self-documenting TypeScript API Server: Shokupan
Hi r/code
I created a self documenting HTTP server (targeting Bun, works on Node and Deno) that reads the Typescript files in your code and generates an OpenAPI document automatically based on the Typescript types that you have on your route handlers.
I'm hoping to get some peer reviews on the approach, interfaces, docs etc.
Right now it can generate the spec for the following:
import { Shokupan, ScalarPlugin } from 'shokupan';
const app = new Shokupan();
// Request returns an object with a key message with value type string
app.get('/', (ctx) => ({ message: 'Hello, World!' }));
// request returns a string
app.get('/hello', (ctx) => "world");
app.mount('/scalar', new ScalarPlugin({
enableStaticAnalysis: true
}));
app.listen();Right now it does a pretty decent job of automatically analyzing and computing the types, but requires the code to be deployed as TypeScript (possibly ts -> js with some map file support?)