feat: v0.5.0 — machine-readable API docs: GET /api/version + OpenAPI 3.1 spec at /api/openapi; AGENTS.md points agents at the live spec

This commit is contained in:
2026-09-17 10:15:25 +00:00
parent 1c50cfeab2
commit 4d9a1e9fa9
9 changed files with 226 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
import { openApiSpec } from '@/lib/openapi';
export async function GET() {
return Response.json(openApiSpec);
}
+18
View File
@@ -0,0 +1,18 @@
import pkg from '@/package.json';
import { describe, expect, it } from 'vitest';
import { GET } from './route';
describe('GET /api/version', () => {
it('returns 200 with the version sourced from package.json', async () => {
const res = await GET();
expect(res.status).toBe(200);
expect(res.headers.get('content-type')).toContain('application/json');
const body = (await res.json()) as { version: string };
expect(body.version).toBe(pkg.version);
});
it('returns exactly the version field', async () => {
const res = await GET();
expect(await res.json()).toEqual({ version: pkg.version });
});
});
+5
View File
@@ -0,0 +1,5 @@
import pkg from '@/package.json';
export async function GET() {
return Response.json({ version: pkg.version });
}