Support dynamic zones in documentation plugin

This commit is contained in:
Alexandre Bodin 2019-12-02 11:59:31 +01:00
parent 46c32055cf
commit d901b54c2e
2 changed files with 31 additions and 2 deletions

View File

@ -43,7 +43,7 @@
},
"body": {
"type": "dynamiczone",
"components": []
"components": ["default.closingperiod", "default.openingtimes"]
},
"description": {
"type": "richtext",

View File

@ -672,7 +672,6 @@ module.exports = {
},
minItems: min,
maxItems: max,
description,
};
} else {
acc.properties[current] = {
@ -681,6 +680,36 @@ module.exports = {
description,
};
}
} else if (type === 'dynamiczone') {
const { components, min, max } = attribute;
const cmps = components.map(component => {
const schema = this.generateMainComponent(
strapi.components[component].attributes,
strapi.components[component].associations
);
return _.merge(
{
properties: {
__component: {
type: 'string',
enum: components,
},
},
},
schema
);
});
acc.properties[current] = {
type: 'array',
items: {
oneOf: cmps,
},
minItems: min,
maxItems: max,
};
} else {
acc.properties[current] = {
type,