docs: show rate limit information

Changelog: Added
This commit is contained in:
Johann150 2023-01-26 08:34:06 +01:00
parent 57cf6c7163
commit 95a9027a66
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -126,11 +126,21 @@ export function genOpenapiSpec() {
};
}
let desc = (endpoint.meta.description ? endpoint.meta.description : 'No description provided.') + '\n\n';
let desc = endpoint.meta.description ?? 'No description provided.');
desc += `**Credential required**: *${endpoint.meta.requireCredential ? 'Yes' : 'No'}*`;
if (endpoint.meta.kind) {
const kind = endpoint.meta.kind;
desc += ` / **Permission**: *${kind}*`;
desc += `\n\n**Permission**: `' + endpoint.meta.kind + '`';
}
if (endpoint.meta.limit) {
const limit = endpoint.meta.limit;
desc += '\n### Rate limit\nRate limiting group: `' + (limit.key ?? endpoint.name) + '`';
if (limit.duration && limit.max) {
desc += ` \nNo more than ${limit.max} requests every ${limit.duration} ms.`;
}
if (limit.minInterval) {
desc += ` \nMinimum delay between each request: ${endpoint.meta.limit.minInterval} ms.`;
}
}
const requestType = endpoint.meta.requireFile ? 'multipart/form-data' : 'application/json';