我在 joi 语法上定义了一个名为 TestBean 的 bean。然后定义了另一个使用 TestBean 模式/bean 的 bean BeanMethodDocument。生成的 Swagger/model 会忽略此参数,但使用 TestBean 定义的数组有效吗?
以下 JOI 语法似乎丢失了 TestBean 定义:“arg: joi.object().schema(TestBean).required()”
'use strict';
var createRouter = require('@arangodb/foxx/router');
var joi = require('joi');
var router = createRouter();
module.context.use(router);
const TestBean = joi.object().required().keys({
member1: joi.array().items(joi.string().required()),
member2: joi.number().required()
});
const BeanMethodDocument = joi.object().required().keys({
arg: joi.object().schema(TestBean).required(),
argArray: joi.array().items(TestBean).required(),
option: joi.string().valid('Empty','Full','HalfFull','HalfEmpty')
});
router.post('/beanMethod', function (req, res) {
const arg = req.body.arg;
const argArray = req.body.argArray;
const option = req.body.option;
res.send({result:true});
})
.body(BeanMethodDocument, 'beanMethod POST request')
.response(joi.boolean().required(), 'beanMethod POST response')
.summary('beanMethod summary')
.description('beanMethod description');
生成的 Swagger 文档显示 arg 参数为空?"arg": {
"type": "object",
"properties": {},
"additionalProperties": false },