@strapi/plugin-documentation 0.0.0-d0fee44d6f → 0.0.0-d36609ff26fb4e00a41a7e2b657f16c7466203fe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/build-component-schema.test.js +8 -8
- package/admin/src/index.js +3 -3
- package/admin/src/pages/PluginPage/index.js +3 -3
- package/admin/src/pages/PluginPage/tests/index.test.js +1 -1
- package/admin/src/pages/SettingsPage/index.js +3 -3
- package/admin/src/pages/SettingsPage/tests/index.test.js +1 -1
- package/admin/src/pages/utils/api.js +1 -1
- package/admin/src/pages/utils/useReactQuery.js +3 -3
- package/admin/src/translations/dk.json +1 -1
- package/admin/src/translations/en.json +1 -1
- package/admin/src/translations/es.json +1 -1
- package/admin/src/translations/ko.json +1 -1
- package/admin/src/translations/pl.json +1 -1
- package/admin/src/translations/sv.json +39 -0
- package/admin/src/translations/tr.json +37 -18
- package/admin/src/translations/zh.json +20 -5
- package/admin/src/utils/getTrad.js +1 -1
- package/admin/src/utils/openWithNewTab.js +1 -1
- package/package.json +12 -8
- package/server/bootstrap.js +2 -4
- package/server/controllers/documentation.js +3 -6
- package/server/public/index.html +27 -14
- package/server/public/login.html +131 -121
- package/server/routes/index.js +1 -0
- package/server/services/documentation.js +8 -7
- package/server/services/helpers/build-api-endpoint-path.js +10 -10
- package/server/services/helpers/build-component-schema.js +82 -22
- package/server/services/helpers/utils/clean-schema-attributes.js +51 -28
- package/server/services/helpers/utils/get-schema-data.js +2 -2
- package/server/services/helpers/utils/loop-content-type-names.js +1 -0
- package/server/services/helpers/utils/pascal-case.js +1 -1
- package/server/services/helpers/utils/query-params.js +22 -1
- package/server/services/helpers/utils/routes.js +2 -2
|
@@ -2,18 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const getSchemaData = require('./get-schema-data');
|
|
5
|
-
|
|
5
|
+
const pascalCase = require('./pascal-case');
|
|
6
6
|
/**
|
|
7
7
|
* @description - Converts types found on attributes to OpenAPI acceptable data types
|
|
8
8
|
*
|
|
9
9
|
* @param {object} attributes - The attributes found on a contentType
|
|
10
|
-
* @param {{ typeMap: Map, isRequest: boolean }} opts
|
|
10
|
+
* @param {{ typeMap: Map, isRequest: boolean, addComponentSchema: function, componentSchemaRefName: string }} opts
|
|
11
11
|
* @returns Attributes using OpenAPI acceptable data types
|
|
12
12
|
*/
|
|
13
|
-
const cleanSchemaAttributes = (
|
|
13
|
+
const cleanSchemaAttributes = (
|
|
14
|
+
attributes,
|
|
15
|
+
{
|
|
16
|
+
typeMap = new Map(),
|
|
17
|
+
isRequest = false,
|
|
18
|
+
addComponentSchema = () => {},
|
|
19
|
+
componentSchemaRefName = '',
|
|
20
|
+
} = {}
|
|
21
|
+
) => {
|
|
14
22
|
const attributesCopy = _.cloneDeep(attributes);
|
|
15
23
|
|
|
16
|
-
for (const prop
|
|
24
|
+
for (const prop of Object.keys(attributesCopy)) {
|
|
17
25
|
const attribute = attributesCopy[prop];
|
|
18
26
|
if (attribute.default) {
|
|
19
27
|
delete attributesCopy[prop].default;
|
|
@@ -86,43 +94,53 @@ const cleanSchemaAttributes = (attributes, { typeMap = new Map(), isRequest = fa
|
|
|
86
94
|
}
|
|
87
95
|
case 'component': {
|
|
88
96
|
const componentAttributes = strapi.components[attribute.component].attributes;
|
|
89
|
-
|
|
97
|
+
const rawComponentSchema = {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
...(isRequest ? {} : { id: { type: 'number' } }),
|
|
101
|
+
...cleanSchemaAttributes(componentAttributes, {
|
|
102
|
+
typeMap,
|
|
103
|
+
isRequest,
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const refComponentSchema = {
|
|
108
|
+
$ref: `#/components/schemas/${pascalCase(attribute.component)}Component`,
|
|
109
|
+
};
|
|
110
|
+
const componentExists = addComponentSchema(
|
|
111
|
+
`${pascalCase(attribute.component)}Component`,
|
|
112
|
+
rawComponentSchema
|
|
113
|
+
);
|
|
114
|
+
const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;
|
|
90
115
|
if (attribute.repeatable) {
|
|
91
116
|
attributesCopy[prop] = {
|
|
92
117
|
type: 'array',
|
|
93
|
-
items:
|
|
94
|
-
type: 'object',
|
|
95
|
-
properties: {
|
|
96
|
-
...(isRequest ? {} : { id: { type: 'string' } }),
|
|
97
|
-
...cleanSchemaAttributes(componentAttributes, { typeMap, isRequest }),
|
|
98
|
-
},
|
|
99
|
-
},
|
|
118
|
+
items: finalComponentSchema,
|
|
100
119
|
};
|
|
101
120
|
} else {
|
|
102
|
-
attributesCopy[prop] =
|
|
103
|
-
type: 'object',
|
|
104
|
-
properties: {
|
|
105
|
-
...(isRequest ? {} : { id: { type: 'string' } }),
|
|
106
|
-
...cleanSchemaAttributes(componentAttributes, {
|
|
107
|
-
typeMap,
|
|
108
|
-
isRequest,
|
|
109
|
-
}),
|
|
110
|
-
},
|
|
111
|
-
};
|
|
121
|
+
attributesCopy[prop] = finalComponentSchema;
|
|
112
122
|
}
|
|
113
123
|
break;
|
|
114
124
|
}
|
|
115
125
|
case 'dynamiczone': {
|
|
116
|
-
const components = attribute.components.map(component => {
|
|
126
|
+
const components = attribute.components.map((component) => {
|
|
117
127
|
const componentAttributes = strapi.components[component].attributes;
|
|
118
|
-
|
|
128
|
+
const rawComponentSchema = {
|
|
119
129
|
type: 'object',
|
|
120
130
|
properties: {
|
|
121
|
-
...(isRequest ? {} : { id: { type: '
|
|
131
|
+
...(isRequest ? {} : { id: { type: 'number' } }),
|
|
122
132
|
__component: { type: 'string' },
|
|
123
|
-
...cleanSchemaAttributes(componentAttributes, {
|
|
133
|
+
...cleanSchemaAttributes(componentAttributes, {
|
|
134
|
+
typeMap,
|
|
135
|
+
isRequest,
|
|
136
|
+
addComponentSchema,
|
|
137
|
+
}),
|
|
124
138
|
},
|
|
125
139
|
};
|
|
140
|
+
const refComponentSchema = { $ref: `#/components/schemas/${pascalCase(component)}` };
|
|
141
|
+
const componentExists = addComponentSchema(pascalCase(component), rawComponentSchema);
|
|
142
|
+
const finalComponentSchema = componentExists ? refComponentSchema : rawComponentSchema;
|
|
143
|
+
return finalComponentSchema;
|
|
126
144
|
});
|
|
127
145
|
|
|
128
146
|
attributesCopy[prop] = {
|
|
@@ -171,8 +189,13 @@ const cleanSchemaAttributes = (attributes, { typeMap = new Map(), isRequest = fa
|
|
|
171
189
|
|
|
172
190
|
if (prop === 'localizations') {
|
|
173
191
|
attributesCopy[prop] = {
|
|
174
|
-
type: '
|
|
175
|
-
|
|
192
|
+
type: 'object',
|
|
193
|
+
properties: {
|
|
194
|
+
data: {
|
|
195
|
+
type: 'array',
|
|
196
|
+
items: componentSchemaRefName.length ? { $ref: componentSchemaRefName } : {},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
176
199
|
};
|
|
177
200
|
break;
|
|
178
201
|
}
|
|
@@ -15,7 +15,7 @@ module.exports = (isListOfEntities, attributes) => {
|
|
|
15
15
|
items: {
|
|
16
16
|
type: 'object',
|
|
17
17
|
properties: {
|
|
18
|
-
id: { type: '
|
|
18
|
+
id: { type: 'number' },
|
|
19
19
|
attributes: { type: 'object', properties: attributes },
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -25,7 +25,7 @@ module.exports = (isListOfEntities, attributes) => {
|
|
|
25
25
|
return {
|
|
26
26
|
type: 'object',
|
|
27
27
|
properties: {
|
|
28
|
-
id: { type: '
|
|
28
|
+
id: { type: 'number' },
|
|
29
29
|
attributes: { type: 'object', properties: attributes },
|
|
30
30
|
},
|
|
31
31
|
};
|
|
@@ -14,7 +14,7 @@ module.exports = [
|
|
|
14
14
|
{
|
|
15
15
|
name: 'pagination[withCount]',
|
|
16
16
|
in: 'query',
|
|
17
|
-
description: '
|
|
17
|
+
description: 'Return page/pageSize (default: true)',
|
|
18
18
|
deprecated: false,
|
|
19
19
|
required: false,
|
|
20
20
|
schema: {
|
|
@@ -81,4 +81,25 @@ module.exports = [
|
|
|
81
81
|
type: 'string',
|
|
82
82
|
},
|
|
83
83
|
},
|
|
84
|
+
{
|
|
85
|
+
name: 'filters',
|
|
86
|
+
in: 'query',
|
|
87
|
+
description: 'Filters to apply',
|
|
88
|
+
deprecated: false,
|
|
89
|
+
required: false,
|
|
90
|
+
schema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
},
|
|
93
|
+
style: 'deepObject',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'locale',
|
|
97
|
+
in: 'query',
|
|
98
|
+
description: 'Locale to apply',
|
|
99
|
+
deprecated: false,
|
|
100
|
+
required: false,
|
|
101
|
+
schema: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
84
105
|
];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const hasFindMethod = handler => handler.split('.').pop() === 'find';
|
|
3
|
+
const hasFindMethod = (handler) => handler.split('.').pop() === 'find';
|
|
4
4
|
|
|
5
|
-
const isLocalizedPath = routePath => routePath.includes('localizations');
|
|
5
|
+
const isLocalizedPath = (routePath) => routePath.includes('localizations');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
isLocalizedPath,
|