mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import { sync } from 'glob';
|
|
|
|
import { generate, HttpClient } from '../';
|
|
|
|
describe('v2', () => {
|
|
it('should generate', async () => {
|
|
await generate({
|
|
input: './test/spec/v2.json',
|
|
output: './test/generated/v2/',
|
|
httpClient: HttpClient.FETCH,
|
|
useOptions: false,
|
|
useUnionTypes: false,
|
|
exportCore: true,
|
|
exportSchemas: true,
|
|
exportModels: true,
|
|
exportServices: true,
|
|
});
|
|
|
|
sync('./test/generated/v2/**/*.ts').forEach(file => {
|
|
const content = readFileSync(file, 'utf8').toString();
|
|
expect(content).toMatchSnapshot(file);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('v3', () => {
|
|
it('should generate', async () => {
|
|
await generate({
|
|
input: './test/spec/v3.json',
|
|
output: './test/generated/v3/',
|
|
httpClient: HttpClient.FETCH,
|
|
useOptions: false,
|
|
useUnionTypes: false,
|
|
exportCore: true,
|
|
exportSchemas: true,
|
|
exportModels: true,
|
|
exportServices: true,
|
|
});
|
|
|
|
sync('./test/generated/v3/**/*.ts').forEach(file => {
|
|
const content = readFileSync(file, 'utf8').toString();
|
|
expect(content).toMatchSnapshot(file);
|
|
});
|
|
});
|
|
});
|