kibana/x-pack/plugins/fleet/common/openapi/validate_docs.test.ts
Kibana Machine 57a7f7f583
[Fleet] Add validation test for openApi files (#121544) (#121769)
* [Fleet] Add validation test for openApi files

* Fix missing types declaration

* Fix licence issue

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Cristina Amico <criamico@users.noreply.github.com>
2021-12-21 08:59:34 -07:00

27 lines
858 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import SwaggerParser from '@apidevtools/swagger-parser';
// Validate the entrypoint.yaml file, sothe generated bundle will be correct.
// https://github.com/APIDevTools/swagger-parser
const validateDocs = async (entrypointFile: string) => {
try {
await SwaggerParser.validate(entrypointFile);
return 'Entrypoint is valid';
} catch (err) {
return err;
}
};
describe('openApi', () => {
it('Checks that entrypoint.yaml is valid', async () => {
expect(await validateDocs('x-pack/plugins/fleet/common/openapi/entrypoint.yaml')).toEqual(
'Entrypoint is valid'
);
});
});