2022-07-07 07:52:34 -05:00
|
|
|
import OpenApiSchemaValidator from 'openapi-schema-validator';
|
2022-10-21 00:14:17 -05:00
|
|
|
import type { OpenAPI } from 'openapi-types';
|
2022-07-07 07:52:34 -05:00
|
|
|
|
2022-07-26 22:23:10 -05:00
|
|
|
import { api } from '@/api';
|
2022-06-16 03:59:00 -05:00
|
|
|
|
|
|
|
describe('Swagger check', () => {
|
2022-07-07 07:52:34 -05:00
|
|
|
it('should provide a valid swagger.json', async () => {
|
|
|
|
const response = await api.get('swagger.json');
|
|
|
|
expect(response).toHaveProperty('statusCode', 200);
|
|
|
|
expect(response.headers['content-type']).toContain('application/json');
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
const object: unknown = JSON.parse(response.body);
|
|
|
|
const validator = new OpenApiSchemaValidator({ version: 3 });
|
|
|
|
const result = validator.validate(object as OpenAPI.Document);
|
|
|
|
expect(result.errors).toEqual([]);
|
|
|
|
}).not.toThrow();
|
2022-06-16 03:59:00 -05:00
|
|
|
});
|
|
|
|
});
|