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