Fix json type and add groups

This commit is contained in:
Alexandre Bodin 2019-09-10 16:52:51 +02:00
parent e07d83a89b
commit 32b8e4174b
2 changed files with 29 additions and 1 deletions

View File

@ -21,7 +21,8 @@
},
"dishes": {
"group": "dish",
"type": "group"
"type": "group",
"repeatable": true
}
}
}

View File

@ -656,6 +656,31 @@ module.exports = {
default:
acc.properties[current] = associationSchema;
}
} else if (type === 'group') {
const { repeatable, group, min, max } = attribute;
const cmp = this.generateMainComponent(
strapi.groups[group].attributes
);
if (repeatable) {
acc.properties[current] = {
type: 'array',
items: {
type: 'object',
...cmp,
},
minItems: min,
maxItems: max,
description,
};
} else {
acc.properties[current] = {
type: 'object',
...cmp,
description,
};
}
} else {
acc.properties[current] = {
type,
@ -1573,6 +1598,8 @@ module.exports = {
case 'biginteger':
case 'long':
return 'integer';
case 'json':
return 'object';
default:
return type;
}