@strapi/plugin-documentation 0.0.0-4fc90398602f → 0.0.0-8581854cb3
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/utils/getTrad.js +1 -1
- package/admin/src/utils/openWithNewTab.js +1 -1
- package/package.json +4 -4
- package/server/bootstrap.js +4 -2
- package/server/controllers/documentation.js +6 -3
- package/server/public/index.html +14 -27
- package/server/public/login.html +121 -131
- package/server/routes/index.js +0 -1
- package/server/services/documentation.js +5 -5
- package/server/services/helpers/build-api-endpoint-path.js +9 -9
- package/server/services/helpers/build-component-schema.js +4 -7
- package/server/services/helpers/utils/clean-schema-attributes.js +2 -2
- package/server/services/helpers/utils/loop-content-type-names.js +0 -1
- package/server/services/helpers/utils/pascal-case.js +1 -1
- package/server/services/helpers/utils/routes.js +2 -2
|
@@ -79,8 +79,8 @@ describe('Build Component Schema', () => {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const schemaNames = Object.keys(schemas);
|
|
82
|
-
const pluginListResponseValue = schemas
|
|
83
|
-
const apiListResponseValue = schemas
|
|
82
|
+
const pluginListResponseValue = schemas['UsersPermissionsRoleListResponse'];
|
|
83
|
+
const apiListResponseValue = schemas['RestaurantListResponse'];
|
|
84
84
|
|
|
85
85
|
const expectedShape = {
|
|
86
86
|
type: 'object',
|
|
@@ -144,8 +144,8 @@ describe('Build Component Schema', () => {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const schemaNames = Object.keys(schemas);
|
|
147
|
-
const pluginListResponseValue = schemas
|
|
148
|
-
const apiListResponseValue = schemas
|
|
147
|
+
const pluginListResponseValue = schemas['UsersPermissionsRoleRequest'];
|
|
148
|
+
const apiListResponseValue = schemas['RestaurantRequest'];
|
|
149
149
|
|
|
150
150
|
const expectedShape = {
|
|
151
151
|
type: 'object',
|
|
@@ -192,8 +192,8 @@ describe('Build Component Schema', () => {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
const schemaNames = Object.keys(schemas);
|
|
195
|
-
const pluginListResponseValue = schemas
|
|
196
|
-
const apiListResponseValue = schemas
|
|
195
|
+
const pluginListResponseValue = schemas['UsersPermissionsRoleLocalizationResponse'];
|
|
196
|
+
const apiListResponseValue = schemas['RestaurantLocalizationResponse'];
|
|
197
197
|
|
|
198
198
|
const expectedShape = {
|
|
199
199
|
type: 'object',
|
|
@@ -236,8 +236,8 @@ describe('Build Component Schema', () => {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
const schemaNames = Object.keys(schemas);
|
|
239
|
-
const pluginListResponseValue = schemas
|
|
240
|
-
const apiListResponseValue = schemas
|
|
239
|
+
const pluginListResponseValue = schemas['UsersPermissionsRoleLocalizationRequest'];
|
|
240
|
+
const apiListResponseValue = schemas['RestaurantLocalizationRequest'];
|
|
241
241
|
|
|
242
242
|
const expectedShape = {
|
|
243
243
|
type: 'object',
|
package/admin/src/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export default {
|
|
|
22
22
|
defaultMessage: 'Documentation',
|
|
23
23
|
},
|
|
24
24
|
permissions: pluginPermissions.main,
|
|
25
|
-
async
|
|
25
|
+
Component: async () => {
|
|
26
26
|
const component = await import(
|
|
27
27
|
/* webpackChunkName: "documentation-page" */ './pages/PluginPage'
|
|
28
28
|
);
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
},
|
|
45
45
|
id: 'documentation',
|
|
46
46
|
to: `/settings/${pluginId}`,
|
|
47
|
-
async
|
|
47
|
+
Component: async () => {
|
|
48
48
|
const component = await import(
|
|
49
49
|
/* webpackChunkName: "documentation-settings" */ './pages/SettingsPage'
|
|
50
50
|
);
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
},
|
|
57
57
|
async registerTrads({ locales }) {
|
|
58
58
|
const importedTrads = await Promise.all(
|
|
59
|
-
locales.map(
|
|
59
|
+
locales.map(locale => {
|
|
60
60
|
return import(
|
|
61
61
|
/* webpackChunkName: "documentation-translation-[request]" */ `./translations/${locale}.json`
|
|
62
62
|
)
|
|
@@ -49,7 +49,7 @@ const PluginPage = () => {
|
|
|
49
49
|
openWithNewTab(`${slash}${data?.prefix}/v${data?.currentVersion}`);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const handleRegenerateDoc =
|
|
52
|
+
const handleRegenerateDoc = version => {
|
|
53
53
|
regenerateDocMutation.mutate({ version, prefix: data?.prefix });
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -64,7 +64,7 @@ const PluginPage = () => {
|
|
|
64
64
|
setIsConfirmButtonLoading(false);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const handleClickDelete =
|
|
67
|
+
const handleClickDelete = version => {
|
|
68
68
|
setVersionToDelete(version);
|
|
69
69
|
setShowConfirmDelete(!showConfirmDelete);
|
|
70
70
|
};
|
|
@@ -123,7 +123,7 @@ const PluginPage = () => {
|
|
|
123
123
|
<Tbody>
|
|
124
124
|
{data.docVersions
|
|
125
125
|
.sort((a, b) => (a.generatedDate < b.generatedDate ? 1 : -1))
|
|
126
|
-
.map(
|
|
126
|
+
.map(doc => (
|
|
127
127
|
<Tr key={doc.version}>
|
|
128
128
|
<Td width="50%">
|
|
129
129
|
<Typography>{doc.version}</Typography>
|
|
@@ -36,7 +36,7 @@ const SettingsPage = () => {
|
|
|
36
36
|
const { submitMutation, data, isLoading } = useReactQuery();
|
|
37
37
|
const [passwordShown, setPasswordShown] = useState(false);
|
|
38
38
|
|
|
39
|
-
const handleUpdateSettingsSubmit =
|
|
39
|
+
const handleUpdateSettingsSubmit = body => {
|
|
40
40
|
submitMutation.mutate({
|
|
41
41
|
prefix: data?.prefix,
|
|
42
42
|
body,
|
|
@@ -143,9 +143,9 @@ const SettingsPage = () => {
|
|
|
143
143
|
}
|
|
144
144
|
endAction={
|
|
145
145
|
<FieldActionWrapper
|
|
146
|
-
onClick={
|
|
146
|
+
onClick={e => {
|
|
147
147
|
e.stopPropagation();
|
|
148
|
-
setPasswordShown(
|
|
148
|
+
setPasswordShown(prev => !prev);
|
|
149
149
|
}}
|
|
150
150
|
label={formatMessage(
|
|
151
151
|
passwordShown
|
|
@@ -5,7 +5,7 @@ const deleteDoc = ({ prefix, version }) => {
|
|
|
5
5
|
return request(`${prefix}/deleteDoc/${version}`, { method: 'DELETE' });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
const fetchDocumentationVersions = async
|
|
8
|
+
const fetchDocumentationVersions = async toggleNotification => {
|
|
9
9
|
try {
|
|
10
10
|
const data = await request(`/${pluginId}/getInfos`, { method: 'GET' });
|
|
11
11
|
|
|
@@ -10,7 +10,7 @@ const useReactQuery = () => {
|
|
|
10
10
|
fetchDocumentationVersions(toggleNotification)
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
const handleError =
|
|
13
|
+
const handleError = err => {
|
|
14
14
|
toggleNotification({
|
|
15
15
|
type: 'warning',
|
|
16
16
|
message: err.response.payload.message,
|
|
@@ -27,7 +27,7 @@ const useReactQuery = () => {
|
|
|
27
27
|
|
|
28
28
|
const deleteMutation = useMutation(deleteDoc, {
|
|
29
29
|
onSuccess: () => handleSuccess('info', 'notification.delete.success'),
|
|
30
|
-
onError:
|
|
30
|
+
onError: error => handleError(error),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const submitMutation = useMutation(updateSettings, {
|
|
@@ -37,7 +37,7 @@ const useReactQuery = () => {
|
|
|
37
37
|
|
|
38
38
|
const regenerateDocMutation = useMutation(regenerateDoc, {
|
|
39
39
|
onSuccess: () => handleSuccess('info', 'notification.generate.success'),
|
|
40
|
-
onError:
|
|
40
|
+
onError: error => handleError(error),
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
return { data, isLoading, deleteMutation, submitMutation, regenerateDocMutation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-documentation",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-8581854cb3",
|
|
4
4
|
"description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"test": "echo \"no tests yet\""
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@strapi/helper-plugin": "0.0.0-
|
|
28
|
-
"@strapi/utils": "0.0.0-
|
|
27
|
+
"@strapi/helper-plugin": "0.0.0-8581854cb3",
|
|
28
|
+
"@strapi/utils": "0.0.0-8581854cb3",
|
|
29
29
|
"bcryptjs": "2.4.3",
|
|
30
30
|
"cheerio": "^1.0.0-rc.12",
|
|
31
31
|
"fs-extra": "10.0.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
|
|
59
59
|
"kind": "plugin"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "8581854cb3c817ae42b829ea686a1b0702ed9245"
|
|
62
62
|
}
|
package/server/bootstrap.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable no-unreachable */
|
|
2
|
-
|
|
3
2
|
'use strict';
|
|
4
3
|
|
|
5
4
|
// Add permissions
|
|
@@ -50,5 +49,8 @@ module.exports = async ({ strapi }) => {
|
|
|
50
49
|
pluginStore.set({ key: 'config', value: { restrictedAccess: false } });
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
await strapi
|
|
52
|
+
await strapi
|
|
53
|
+
.plugin('documentation')
|
|
54
|
+
.service('documentation')
|
|
55
|
+
.generateFullDoc();
|
|
54
56
|
};
|
|
@@ -43,7 +43,10 @@ module.exports = {
|
|
|
43
43
|
const version =
|
|
44
44
|
major && minor && patch
|
|
45
45
|
? `${major}.${minor}.${patch}`
|
|
46
|
-
: strapi
|
|
46
|
+
: strapi
|
|
47
|
+
.plugin('documentation')
|
|
48
|
+
.service('documentation')
|
|
49
|
+
.getDocumentationVersion();
|
|
47
50
|
|
|
48
51
|
const openAPISpecsPath = path.join(
|
|
49
52
|
strapi.dirs.app.extensions,
|
|
@@ -174,7 +177,7 @@ module.exports = {
|
|
|
174
177
|
|
|
175
178
|
const service = strapi.service('plugin::documentation.documentation');
|
|
176
179
|
|
|
177
|
-
const documentationVersions = service.getDocumentationVersions().map(
|
|
180
|
+
const documentationVersions = service.getDocumentationVersions().map(el => el.version);
|
|
178
181
|
|
|
179
182
|
if (_.isEmpty(version)) {
|
|
180
183
|
return ctx.badRequest('Please provide a version.');
|
|
@@ -198,7 +201,7 @@ module.exports = {
|
|
|
198
201
|
|
|
199
202
|
const service = strapi.service('plugin::documentation.documentation');
|
|
200
203
|
|
|
201
|
-
const documentationVersions = service.getDocumentationVersions().map(
|
|
204
|
+
const documentationVersions = service.getDocumentationVersions().map(el => el.version);
|
|
202
205
|
|
|
203
206
|
if (_.isEmpty(version)) {
|
|
204
207
|
return ctx.badRequest('Please provide a version.');
|
package/server/public/index.html
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
<!-- HTML for static distribution bundle build --><!DOCTYPE html>
|
|
2
|
-
<
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
1
|
+
<!-- HTML for static distribution bundle build --><!DOCTYPE html><html lang="en"><head>
|
|
2
|
+
<meta charset="UTF-8">
|
|
5
3
|
<title>Swagger UI</title>
|
|
6
|
-
<link
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
href="<%=backendUrl%>/plugins/documentation/swagger-ui.css"
|
|
10
|
-
/>
|
|
11
|
-
<link
|
|
12
|
-
rel="icon"
|
|
13
|
-
type="image/png"
|
|
14
|
-
href="<%=backendUrl%>/plugins/documentation/favicon-32x32.png"
|
|
15
|
-
sizes="32x32"
|
|
16
|
-
/>
|
|
17
|
-
<link
|
|
18
|
-
rel="icon"
|
|
19
|
-
type="image/png"
|
|
20
|
-
href="<%=backendUrl%>/plugins/documentation/favicon-16x16.png"
|
|
21
|
-
sizes="16x16"
|
|
22
|
-
/>
|
|
4
|
+
<link rel="stylesheet" type="text/css" href="<%=backendUrl%>/plugins/documentation/swagger-ui.css">
|
|
5
|
+
<link rel="icon" type="image/png" href="<%=backendUrl%>/plugins/documentation/favicon-32x32.png" sizes="32x32">
|
|
6
|
+
<link rel="icon" type="image/png" href="<%=backendUrl%>/plugins/documentation/favicon-16x16.png" sizes="16x16">
|
|
23
7
|
<style>
|
|
24
|
-
html
|
|
8
|
+
html
|
|
9
|
+
{
|
|
25
10
|
box-sizing: border-box;
|
|
26
11
|
overflow: -moz-scrollbars-vertical;
|
|
27
12
|
overflow-y: scroll;
|
|
@@ -29,12 +14,14 @@
|
|
|
29
14
|
|
|
30
15
|
*,
|
|
31
16
|
*:before,
|
|
32
|
-
*:after
|
|
17
|
+
*:after
|
|
18
|
+
{
|
|
33
19
|
box-sizing: inherit;
|
|
34
20
|
}
|
|
35
21
|
|
|
36
|
-
body
|
|
37
|
-
|
|
22
|
+
body
|
|
23
|
+
{
|
|
24
|
+
margin:0;
|
|
38
25
|
background: #fafafa;
|
|
39
26
|
}
|
|
40
27
|
</style>
|
|
@@ -64,7 +51,7 @@
|
|
|
64
51
|
}
|
|
65
52
|
</script>
|
|
66
53
|
|
|
67
|
-
<script src="<%=backendUrl%>/plugins/documentation/swagger-ui-bundle.js"
|
|
68
|
-
<script src="<%=backendUrl%>/plugins/documentation/swagger-ui-standalone-preset.js"
|
|
54
|
+
<script src="<%=backendUrl%>/plugins/documentation/swagger-ui-bundle.js"> </script>
|
|
55
|
+
<script src="<%=backendUrl%>/plugins/documentation/swagger-ui-standalone-preset.js"> </script>
|
|
69
56
|
</body>
|
|
70
57
|
</html>
|
package/server/public/login.html
CHANGED
|
@@ -1,145 +1,135 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
padding: 0;
|
|
12
|
-
}
|
|
1
|
+
<!DOCTYPE html><html><head>
|
|
2
|
+
<title>Login - Documentation</title>
|
|
3
|
+
<link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet">
|
|
4
|
+
<style>
|
|
5
|
+
html {
|
|
6
|
+
font-size: 62.5%;
|
|
7
|
+
height: 100%;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
}
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
body {
|
|
13
|
+
height: 100%;
|
|
14
|
+
margin: 0;
|
|
15
|
+
background-color: #ffffff;
|
|
16
|
+
font-family: 'Lato';
|
|
17
|
+
font-size: 1.4rem;
|
|
18
|
+
font-weight: 400;
|
|
19
|
+
text-rendering: optimizeLegibility;
|
|
20
|
+
-webkit-font-smoothing: antialiased;
|
|
21
|
+
-moz-osx-font-smoothing: grayscale;
|
|
22
|
+
}
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
.login {
|
|
25
|
+
height: 100%;
|
|
26
|
+
background-color: #F6F9FC;
|
|
27
|
+
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
.login .login-form {
|
|
30
|
+
height: calc(100% - 70px);
|
|
31
|
+
padding: 68px 0 0;
|
|
32
|
+
text-align: center;
|
|
33
|
+
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
.login .login-form form {
|
|
36
|
+
position: relative;
|
|
37
|
+
max-width: 460px;
|
|
38
|
+
padding: 26px 30px;
|
|
39
|
+
margin: 55px auto 0;
|
|
40
|
+
background-color: #ffffff;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
box-shadow: 0px 2px 4px rgba(91, 107, 174, .15);
|
|
43
|
+
text-align: center;
|
|
44
|
+
}
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
.login .login-form form:before {
|
|
47
|
+
position: absolute;
|
|
48
|
+
content: '';
|
|
49
|
+
top: 0px;
|
|
50
|
+
left: 0;
|
|
51
|
+
display: inline-block;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 2px;
|
|
54
|
+
background-color: #2B66CC;
|
|
55
|
+
}
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
.login .login-form form .error {
|
|
58
|
+
display: block;
|
|
59
|
+
color: #FF4E00;
|
|
60
|
+
padding-bottom: 20px;
|
|
61
|
+
}
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
.login .login-form .sub-title {
|
|
64
|
+
margin-top: 35px;
|
|
65
|
+
font-size: 1.6rem;
|
|
66
|
+
font-weight: 400;
|
|
67
|
+
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
.login .login-form .logo{
|
|
70
|
+
max-height: 40px;
|
|
71
|
+
}
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
.login .login-form form label {
|
|
74
|
+
display: block;
|
|
75
|
+
margin-bottom: 18px;
|
|
76
|
+
width: 100%;
|
|
77
|
+
text-align: left;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
}
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
.login .login-form form input {
|
|
82
|
+
outline: none;
|
|
83
|
+
width: calc(100% - 30px);
|
|
84
|
+
height: 36px;
|
|
85
|
+
padding: 0 15px;
|
|
86
|
+
border: 1px solid #ECECEC;
|
|
87
|
+
border-radius: 2px;
|
|
88
|
+
margin-bottom: 20px;
|
|
89
|
+
line-height: 36px;
|
|
90
|
+
text-align: left;
|
|
91
|
+
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
93
|
+
.login .login-form form input[type=submit] {
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
display: inline-block;
|
|
96
|
+
width: auto;
|
|
97
|
+
margin: 12px auto 0;
|
|
98
|
+
padding: 0 75px;
|
|
99
|
+
background: transparent;
|
|
100
|
+
border-radius: 36px;
|
|
101
|
+
border: 1px solid #2B66CC;
|
|
102
|
+
color: #2B66CC;
|
|
103
|
+
text-transform: uppercase;
|
|
104
|
+
font-size: 1.4rem;
|
|
105
|
+
font-weight: 700;
|
|
106
|
+
transition: all .2s ease-out;
|
|
107
|
+
}
|
|
110
108
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<input
|
|
133
|
-
type="password"
|
|
134
|
-
name="password"
|
|
135
|
-
placeholder="•••••••••"
|
|
136
|
-
/>
|
|
137
|
-
<input type="submit" value="Login" />
|
|
138
|
-
</form>
|
|
109
|
+
.login .login-form form input[type=submit]:hover {
|
|
110
|
+
background: #2B66CC;
|
|
111
|
+
color: #ffffff;
|
|
112
|
+
}
|
|
113
|
+
</style>
|
|
114
|
+
</head>
|
|
115
|
+
<body>
|
|
116
|
+
<div class="login">
|
|
117
|
+
<section class="login-form">
|
|
118
|
+
<div class="container">
|
|
119
|
+
<div class="row">
|
|
120
|
+
<div class="col-lg-6 col-lg-offset-3 col-md-12">
|
|
121
|
+
<img alt="Strapi logo" class="logo" src="https://strapi.io/assets/images/logo_login.png">
|
|
122
|
+
<h2 class="sub-title">Enter the password to access the documentation.</h2>
|
|
123
|
+
<form method="post" action="<%=actionUrl%>">
|
|
124
|
+
<span class="error">Wrong password...</span>
|
|
125
|
+
<label>Password</label>
|
|
126
|
+
<input type="password" name="password" placeholder="•••••••••">
|
|
127
|
+
<input type="submit" value="Login">
|
|
128
|
+
</form>
|
|
129
|
+
</div>
|
|
139
130
|
</div>
|
|
140
131
|
</div>
|
|
141
|
-
</
|
|
142
|
-
</
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</html>
|
|
132
|
+
</section>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
</body></html>
|
package/server/routes/index.js
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = ({ strapi }) => {
|
|
|
38
38
|
getDocumentationVersions() {
|
|
39
39
|
return fs
|
|
40
40
|
.readdirSync(this.getFullDocumentationPath())
|
|
41
|
-
.map(
|
|
41
|
+
.map(version => {
|
|
42
42
|
try {
|
|
43
43
|
const doc = JSON.parse(
|
|
44
44
|
fs.readFileSync(
|
|
@@ -52,7 +52,7 @@ module.exports = ({ strapi }) => {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
|
-
.filter(
|
|
55
|
+
.filter(x => x);
|
|
56
56
|
},
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -99,7 +99,7 @@ module.exports = ({ strapi }) => {
|
|
|
99
99
|
|
|
100
100
|
getPluginAndApiInfo() {
|
|
101
101
|
const plugins = _.get(config, 'x-strapi-config.plugins');
|
|
102
|
-
const pluginsToDocument = plugins.map(
|
|
102
|
+
const pluginsToDocument = plugins.map(plugin => {
|
|
103
103
|
return {
|
|
104
104
|
name: plugin,
|
|
105
105
|
getter: 'plugin',
|
|
@@ -107,7 +107,7 @@ module.exports = ({ strapi }) => {
|
|
|
107
107
|
};
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
const apisToDocument = Object.keys(strapi.api).map(
|
|
110
|
+
const apisToDocument = Object.keys(strapi.api).map(api => {
|
|
111
111
|
return {
|
|
112
112
|
name: api,
|
|
113
113
|
getter: 'api',
|
|
@@ -186,7 +186,7 @@ module.exports = ({ strapi }) => {
|
|
|
186
186
|
|
|
187
187
|
const finalDoc = { ...config, paths };
|
|
188
188
|
|
|
189
|
-
registeredDocs.forEach(
|
|
189
|
+
registeredDocs.forEach(doc => {
|
|
190
190
|
// Add tags
|
|
191
191
|
finalDoc.tags = finalDoc.tags || [];
|
|
192
192
|
finalDoc.tags.push(...(doc.tags || []));
|
|
@@ -15,12 +15,12 @@ const { hasFindMethod, isLocalizedPath } = require('./utils/routes');
|
|
|
15
15
|
* @param {string} routePath - The route's path property
|
|
16
16
|
* @returns {string}
|
|
17
17
|
*/
|
|
18
|
-
const parsePathWithVariables =
|
|
18
|
+
const parsePathWithVariables = routePath => {
|
|
19
19
|
return pathToRegexp
|
|
20
20
|
.parse(routePath)
|
|
21
|
-
.map(
|
|
21
|
+
.map(token => {
|
|
22
22
|
if (_.isObject(token)) {
|
|
23
|
-
return
|
|
23
|
+
return token.prefix + '{' + token.name + '}';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return token;
|
|
@@ -35,11 +35,11 @@ const parsePathWithVariables = (routePath) => {
|
|
|
35
35
|
*
|
|
36
36
|
* @returns {object } Swagger path params object
|
|
37
37
|
*/
|
|
38
|
-
const getPathParams =
|
|
38
|
+
const getPathParams = routePath => {
|
|
39
39
|
return pathToRegexp
|
|
40
40
|
.parse(routePath)
|
|
41
|
-
.filter(
|
|
42
|
-
.map(
|
|
41
|
+
.filter(token => _.isObject(token))
|
|
42
|
+
.map(param => {
|
|
43
43
|
return {
|
|
44
44
|
name: param.name,
|
|
45
45
|
in: 'path',
|
|
@@ -83,7 +83,7 @@ const getPathWithPrefix = (prefix, route) => {
|
|
|
83
83
|
*/
|
|
84
84
|
const getPaths = ({ routeInfo, uniqueName, contentTypeInfo }) => {
|
|
85
85
|
// Get the routes for the current content type
|
|
86
|
-
const contentTypeRoutes = routeInfo.routes.filter(
|
|
86
|
+
const contentTypeRoutes = routeInfo.routes.filter(route => {
|
|
87
87
|
return (
|
|
88
88
|
route.path.includes(contentTypeInfo.pluralName) ||
|
|
89
89
|
route.path.includes(contentTypeInfo.singularName)
|
|
@@ -152,7 +152,7 @@ const getPaths = ({ routeInfo, uniqueName, contentTypeInfo }) => {
|
|
|
152
152
|
*
|
|
153
153
|
* @returns {object} Open API paths
|
|
154
154
|
*/
|
|
155
|
-
const getAllPathsForContentType =
|
|
155
|
+
const getAllPathsForContentType = apiInfo => {
|
|
156
156
|
let paths = {};
|
|
157
157
|
|
|
158
158
|
const pathsObject = getPaths(apiInfo);
|
|
@@ -175,7 +175,7 @@ const getAllPathsForContentType = (apiInfo) => {
|
|
|
175
175
|
*
|
|
176
176
|
* @returns {object}
|
|
177
177
|
*/
|
|
178
|
-
const buildApiEndpointPath =
|
|
178
|
+
const buildApiEndpointPath = api => {
|
|
179
179
|
// A reusable loop for building paths and component schemas
|
|
180
180
|
// Uses the api param to build a new set of params for each content type
|
|
181
181
|
// Passes these new params to the function provided
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
const _ = require('lodash');
|
|
4
3
|
|
|
5
4
|
const cleanSchemaAttributes = require('./utils/clean-schema-attributes');
|
|
@@ -21,11 +20,9 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
|
|
21
20
|
// Store response and request schemas in an object
|
|
22
21
|
let schemas = {};
|
|
23
22
|
// Get all the route methods
|
|
24
|
-
const routeMethods = routeInfo.routes.map(
|
|
23
|
+
const routeMethods = routeInfo.routes.map(route => route.method);
|
|
25
24
|
// Check for localized paths
|
|
26
|
-
const hasLocalizationPath = routeInfo.routes.filter((route)
|
|
27
|
-
isLocalizedPath(route.path)
|
|
28
|
-
).length;
|
|
25
|
+
const hasLocalizationPath = routeInfo.routes.filter(route => isLocalizedPath(route.path)).length;
|
|
29
26
|
// When the route methods contain any post or put requests
|
|
30
27
|
if (routeMethods.includes('POST') || routeMethods.includes('PUT')) {
|
|
31
28
|
const attributesToOmit = [
|
|
@@ -92,7 +89,7 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
// Check for routes that need to return a list
|
|
95
|
-
const hasListOfEntities = routeInfo.routes.filter(
|
|
92
|
+
const hasListOfEntities = routeInfo.routes.filter(route => hasFindMethod(route.handler)).length;
|
|
96
93
|
if (hasListOfEntities) {
|
|
97
94
|
// Build the list response schema
|
|
98
95
|
schemas = {
|
|
@@ -149,7 +146,7 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
|
|
149
146
|
return schemas;
|
|
150
147
|
};
|
|
151
148
|
|
|
152
|
-
const buildComponentSchema =
|
|
149
|
+
const buildComponentSchema = api => {
|
|
153
150
|
// A reusable loop for building paths and component schemas
|
|
154
151
|
// Uses the api param to build a new set of params for each content type
|
|
155
152
|
// Passes these new params to the function provided
|
|
@@ -13,7 +13,7 @@ const getSchemaData = require('./get-schema-data');
|
|
|
13
13
|
const cleanSchemaAttributes = (attributes, { typeMap = new Map(), isRequest = false } = {}) => {
|
|
14
14
|
const attributesCopy = _.cloneDeep(attributes);
|
|
15
15
|
|
|
16
|
-
for (const prop
|
|
16
|
+
for (const prop in attributesCopy) {
|
|
17
17
|
const attribute = attributesCopy[prop];
|
|
18
18
|
if (attribute.default) {
|
|
19
19
|
delete attributesCopy[prop].default;
|
|
@@ -113,7 +113,7 @@ const cleanSchemaAttributes = (attributes, { typeMap = new Map(), isRequest = fa
|
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
case 'dynamiczone': {
|
|
116
|
-
const components = attribute.components.map(
|
|
116
|
+
const components = attribute.components.map(component => {
|
|
117
117
|
const componentAttributes = strapi.components[component].attributes;
|
|
118
118
|
return {
|
|
119
119
|
type: 'object',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const hasFindMethod =
|
|
3
|
+
const hasFindMethod = handler => handler.split('.').pop() === 'find';
|
|
4
4
|
|
|
5
|
-
const isLocalizedPath =
|
|
5
|
+
const isLocalizedPath = routePath => routePath.includes('localizations');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
isLocalizedPath,
|