2022-05-29 18:31:16 +03:00
|
|
|
// Check API definition to ensure conformance to Azure security schemes guidelines.
|
|
|
|
|
|
|
|
// Check:
|
|
|
|
// - Operation (input) has a `security`, or there is a global `security`.
|
|
|
|
|
|
|
|
// @param input - an operation
|
2022-06-20 21:31:39 +03:00
|
|
|
module.exports = (input, _, context) => {
|
2022-05-29 18:31:16 +03:00
|
|
|
if (input === null || typeof input !== 'object') {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is a global `security`, no need to check the operation.
|
|
|
|
if (context.document.data.security) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const path = context.path || [];
|
|
|
|
|
|
|
|
if (!input.security) {
|
|
|
|
return [{
|
|
|
|
message: 'Operation should have a security requirement.',
|
|
|
|
path: [...path, 'security'],
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
};
|