fork of hey-api/openapi-ts because I need some additional things
1import fs from 'node:fs';
2import path from 'node:path';
3
4import { createClient } from '@hey-api/openapi-python';
5
6import { getFilePaths } from '../../../utils';
7import { createPydanticConfig, getSnapshotsPath, getTempSnapshotsPath } from './utils';
8
9const version = '3.1.x';
10
11const outputDir = path.join(getTempSnapshotsPath(), version);
12const snapshotsDir = path.join(getSnapshotsPath(), version);
13
14describe(`Pydantic: OpenAPI ${version}`, () => {
15 const createConfig = createPydanticConfig({
16 openApiVersion: version,
17 outputDir,
18 });
19
20 const scenarios = [
21 {
22 config: createConfig({
23 input: 'opencode.yaml',
24 output: 'opencode',
25 }),
26 description: 'OpenCode spec',
27 },
28 ];
29
30 it.each(scenarios)('$description', async ({ config }) => {
31 await createClient(config);
32
33 const filePaths = getFilePaths(config.output);
34
35 await Promise.all(
36 filePaths.map(async (filePath) => {
37 const fileContent = fs.readFileSync(filePath, 'utf-8');
38 await expect(fileContent).toMatchFileSnapshot(
39 path.join(snapshotsDir, filePath.slice(outputDir.length + 1)),
40 );
41 }),
42 );
43 });
44});