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, getSpecsPath } from '../../utils';
7import { createSdkConfig, getSnapshotsPath, getTempSnapshotsPath } from './utils';
8
9const namespace = 'opencode';
10
11const outputDir = path.join(getTempSnapshotsPath(), namespace);
12const snapshotsDir = path.join(getSnapshotsPath(), namespace);
13
14const specPath = path.join(getSpecsPath(), '3.1.x', 'opencode.yaml');
15
16describe(`Python SDK: ${namespace}`, () => {
17 const createConfig = createSdkConfig({
18 outputDir,
19 });
20
21 const scenarios = [
22 {
23 config: createConfig({
24 input: specPath,
25 output: 'default',
26 plugins: ['@hey-api/python-sdk'],
27 }),
28 description: 'default',
29 },
30 ];
31
32 it.each(scenarios)(
33 '$description',
34 async ({ config }) => {
35 await createClient(config);
36
37 const filePaths = getFilePaths(
38 typeof config.output === 'string' ? config.output : config.output.path,
39 );
40
41 await Promise.all(
42 filePaths.map(async (filePath) => {
43 const fileContent = fs.readFileSync(filePath, 'utf-8');
44 await expect(fileContent).toMatchFileSnapshot(
45 path.join(snapshotsDir, filePath.slice(outputDir.length + 1)),
46 );
47 }),
48 );
49 },
50 15_000,
51 );
52});