Create OpenAPI specifications from TypeScript types using typia.
This project is published on JSR
bunx jsr add @pnsk-lab/typia-openapi
import { stringify } from 'yaml'
import typia from 'typia'
import { typiaToOpenAPI } from '@pnsk-lab/typia-openapi'
const api = typiaToOpenAPI({
openapi: '3.1.0',
info: {
title: 'Example API',
version: '1.0.0',
},
servers: [
{
url: 'https://api.example.com/v1',
description: 'Production server',
},
],
paths: {
'/users': {
get: {
summary: 'Get all users',
responses: {
'200': {
description: 'A list of users',
content: {
'application/json': {
schema: typia.json.schema<{
id: string
}[]>()
}
}
}
}
}
}
}
})
await Bun.write('example/schema.yaml', stringify(api, { indent: 2 }))
Contributions are welcome! Please open a pull request with your changes.