Я пытаюсь проверить объект Swagger как полезную нагрузку по этой ссылке
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#security-requirement-object
У меня проблемы с безопасностью, По этой ссылке я создал этот код,
const scopesObject=Joi.object().pattern(/^/,joi.string()).required();
const securitySchemeObject=Joi.object({
type: Joi.string().valid('basic','apikey','oauth2').required(),
description: Joi.string(),
name: Joi.string().when('type', { is: 'apikey', then: Joi.string().required()}),
in: Joi.string().when('type', { is: 'apikey', then: Joi.string().valid('query','header').required()}),
flow: Joi.string().when('type', { is: 'oauth2', then: Joi.string().valid("implicit", "password", "application","accessCode").required()}),
authorizationUrl: Joi.string().when('flow', { is: 'implicit', then: Joi.string().required()})
.when('flow', { is: 'accessCode', then: Joi.string().required()}),
tokenUrl: Joi.string().when('flow', { is: 'password', then: Joi.string().required()})
.when('flow', { is: 'application', then: Joi.string().required()})
.when('flow', { is: 'accesscode', then: Joi.string().required()}),
scopes: Joi.object().when('type', { is: 'oauth2', then: scopesObject.required()})
});
const start=Joi.object().pattern(/^/,securitySchemeObject);
var securityRequirementObject=Joi.object().pattern(/^/,joi.array().items(scopesObject));
Joi.array()
.items(
securityRequirementObject,
);
В ссылке они упомянули шаблонное поле {имя}, ключ которого должен уже присутствовать в securityschemeobject, а ключ области действия должен быть таким же.Как я могу этого достичь?Если я что-то пропускаю, поправьте меня.