mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
fix: json schema 默认全部解析
This commit is contained in:
parent
14fdde4b6d
commit
d77e51e07c
@ -997,7 +997,7 @@ class interfaceController extends baseController {
|
||||
let required = ctx.request.body.required;
|
||||
|
||||
let res = yapi.commons.schemaToJson(schema, {
|
||||
alwaysFakeOptionals: required ? true : false
|
||||
alwaysFakeOptionals: _.isUndefined(required) ? true : require
|
||||
})
|
||||
// console.log('res',res)
|
||||
return ctx.body = res;
|
||||
|
@ -218,7 +218,9 @@ module.exports = async (ctx, next) => {
|
||||
if (interfaceData.res_body_is_json_schema === true) {
|
||||
//json-schema
|
||||
const schema = yapi.commons.json_parse(interfaceData.res_body);
|
||||
res = yapi.commons.schemaToJson(schema);
|
||||
res = yapi.commons.schemaToJson(schema, {
|
||||
alwaysFakeOptionals: true
|
||||
});
|
||||
} else {
|
||||
// console.log('header', ctx.request.header['content-type'].indexOf('multipart/form-data'))
|
||||
// 处理 format-data
|
||||
|
@ -35,6 +35,7 @@ formats.forEach(item => {
|
||||
|
||||
exports.schemaToJson = function(schema, options = {}) {
|
||||
Object.assign(options, defaultOptions);
|
||||
|
||||
jsf.option(options);
|
||||
let result;
|
||||
try {
|
||||
@ -552,38 +553,36 @@ exports.getUserdata = async function getUserdata(uid, role) {
|
||||
};
|
||||
|
||||
exports.sendNotice = async function sendNotice(projectId, data) {
|
||||
const followInst = yapi.getInst(followModel);
|
||||
const userInst = yapi.getInst(userModel);
|
||||
const projectInst = yapi.getInst(projectModel);
|
||||
const list = await followInst.listByProjectId(projectId);
|
||||
const starUsers = list.map(item => item.uid);
|
||||
const followInst = yapi.getInst(followModel);
|
||||
const userInst = yapi.getInst(userModel);
|
||||
const projectInst = yapi.getInst(projectModel);
|
||||
const list = await followInst.listByProjectId(projectId);
|
||||
const starUsers = list.map(item => item.uid);
|
||||
|
||||
const projectList = await projectInst.get(projectId);
|
||||
const projectMenbers = projectList.members.filter(item => item.email_notice).map(item => item.uid);
|
||||
const projectList = await projectInst.get(projectId);
|
||||
const projectMenbers = projectList.members
|
||||
.filter(item => item.email_notice)
|
||||
.map(item => item.uid);
|
||||
|
||||
const users = arrUnique(projectMenbers, starUsers);
|
||||
const usersInfo = await userInst.findByUids(users);
|
||||
const emails = usersInfo.map(item => item.email).join(',');
|
||||
|
||||
const users = arrUnique(projectMenbers, starUsers);
|
||||
const usersInfo = await userInst.findByUids(users);
|
||||
const emails = usersInfo.map(item => item.email).join(',');
|
||||
|
||||
try {
|
||||
yapi.commons.sendMail({
|
||||
to: emails,
|
||||
contents: data.content,
|
||||
subject: data.title
|
||||
});
|
||||
} catch (e) {
|
||||
yapi.commons.log('邮件发送失败:' + e, 'error');
|
||||
}
|
||||
try {
|
||||
yapi.commons.sendMail({
|
||||
to: emails,
|
||||
contents: data.content,
|
||||
subject: data.title
|
||||
});
|
||||
} catch (e) {
|
||||
yapi.commons.log('邮件发送失败:' + e, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
function arrUnique(arr1, arr2) {
|
||||
|
||||
let arr = arr1.concat(arr2);
|
||||
let res = arr.filter(function (item, index, arr) {
|
||||
let res = arr.filter(function(item, index, arr) {
|
||||
return arr.indexOf(item) === index;
|
||||
});
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user