大摇大摆地删除从 Joe 模式生成的额外主体
Remove extra body generated from Joe schema in swagger
我有两个 Joi 架构,如下所示:
const updateProfile: {
body: ObjectSchema;
} = {
body: Joi.object().keys({
dob: JoiDate.date()
.format('MM/DD/YYYY')
.max(new Date())
.required()
.default('01/30/2022'),
genderId: Joi.number().integer().required(),
weightLbs: Joi.number().required(),
heightIn: Joi.number().required(),
...
}),
};
const updateUser: {
body: ObjectSchema;
} = {
body: Joi.object().keys({
firstName: Joi.string(),
lastName: Joi.string(),
profile: updateProfile
}),
};
const updateUserSchema = j2s(updateUser.body).swagger;
生成的 Swagger 模式包含一个额外的 `body,有什么办法可以删除它吗?
从 updateProfile
中删除 body
解决了我的问题:
const updateProfile: ObjectSchema = Joi.object().keys({
dob: JoiDate.date()
.format('MM/DD/YYYY')
.raw()
.max(new Date())
.required()
.default('01/30/2022'),
genderId: Joi.number().integer().required(),
weightLbs: Joi.number().required(),
heightIn: Joi.number().required(),
...
});
我有两个 Joi 架构,如下所示:
const updateProfile: {
body: ObjectSchema;
} = {
body: Joi.object().keys({
dob: JoiDate.date()
.format('MM/DD/YYYY')
.max(new Date())
.required()
.default('01/30/2022'),
genderId: Joi.number().integer().required(),
weightLbs: Joi.number().required(),
heightIn: Joi.number().required(),
...
}),
};
const updateUser: {
body: ObjectSchema;
} = {
body: Joi.object().keys({
firstName: Joi.string(),
lastName: Joi.string(),
profile: updateProfile
}),
};
const updateUserSchema = j2s(updateUser.body).swagger;
生成的 Swagger 模式包含一个额外的 `body,有什么办法可以删除它吗?
从 updateProfile
中删除 body
解决了我的问题:
const updateProfile: ObjectSchema = Joi.object().keys({
dob: JoiDate.date()
.format('MM/DD/YYYY')
.raw()
.max(new Date())
.required()
.default('01/30/2022'),
genderId: Joi.number().integer().required(),
weightLbs: Joi.number().required(),
heightIn: Joi.number().required(),
...
});