feat(GOV-009): 建立后端契约与健康检查
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { createOpenApiDocument } from '../../../tools/export-openapi';
|
||||
|
||||
describe('Server OpenAPI 单向发布', () => {
|
||||
it('从真实 Controller 和 DTO 生成健康接口契约', async () => {
|
||||
const document = await createOpenApiDocument();
|
||||
|
||||
expect(document.paths).toHaveProperty('/api/v1/health');
|
||||
expect(document.components?.schemas).toHaveProperty('HealthResponseDto');
|
||||
});
|
||||
|
||||
it('仓库内 OpenAPI 文件是可解析的同一契约', async () => {
|
||||
const content = await readFile(
|
||||
path.resolve(__dirname, '../../../openapi/openapi.json'),
|
||||
'utf8',
|
||||
);
|
||||
const document = JSON.parse(content) as {
|
||||
paths: Record<string, unknown>;
|
||||
components?: { schemas?: Record<string, unknown> };
|
||||
};
|
||||
|
||||
expect(document.paths).toHaveProperty('/api/v1/health');
|
||||
expect(document.components?.schemas).toHaveProperty('HealthResponseDto');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user