@whook/whook
Version:
Build strong and efficient REST web services.
25 lines • 943 B
JavaScript
import { isValidOpenAPIPath, PATH_ITEM_METHODS, } from 'ya-open-api-types';
import { YError } from 'yerror';
export function isValidWhookOpenAPI(api) {
for (const path in api.paths) {
if (isValidOpenAPIPath(path)) {
const pathItem = api.paths[path];
if (typeof pathItem === 'undefined' || '$ref' in pathItem) {
throw new YError('E_BAD_PATH_ITEM', [path, pathItem]);
}
for (const method of PATH_ITEM_METHODS) {
if (pathItem[method]) {
if ('$ref' in pathItem[method] || !pathItem[method].operationId) {
throw new YError('E_BAD_OPERATION', [
path,
method,
pathItem[method],
]);
}
}
}
}
}
return true;
}
//# sourceMappingURL=openapi.js.map