@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.
@@ -79,8 +79,8 @@ describe('Build Component Schema', () => {
79
79
  }
80
80
 
81
81
  const schemaNames = Object.keys(schemas);
82
- const pluginListResponseValue = schemas.UsersPermissionsRoleListResponse;
83
- const apiListResponseValue = schemas.RestaurantListResponse;
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.UsersPermissionsRoleRequest;
148
- const apiListResponseValue = schemas.RestaurantRequest;
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.UsersPermissionsRoleLocalizationResponse;
196
- const apiListResponseValue = schemas.RestaurantLocalizationResponse;
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.UsersPermissionsRoleLocalizationRequest;
240
- const apiListResponseValue = schemas.RestaurantLocalizationRequest;
239
+ const pluginListResponseValue = schemas['UsersPermissionsRoleLocalizationRequest'];
240
+ const apiListResponseValue = schemas['RestaurantLocalizationRequest'];
241
241
 
242
242
  const expectedShape = {
243
243
  type: 'object',
@@ -22,7 +22,7 @@ export default {
22
22
  defaultMessage: 'Documentation',
23
23
  },
24
24
  permissions: pluginPermissions.main,
25
- async Component() {
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 Component() {
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((locale) => {
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 = (version) => {
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 = (version) => {
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((doc) => (
126
+ .map(doc => (
127
127
  <Tr key={doc.version}>
128
128
  <Td width="50%">
129
129
  <Typography>{doc.version}</Typography>
@@ -23,7 +23,7 @@ const client = new QueryClient({
23
23
  },
24
24
  });
25
25
 
26
- const makeApp = (history) => (
26
+ const makeApp = history => (
27
27
  <Router history={history}>
28
28
  <ThemeProvider theme={lightTheme}>
29
29
  <QueryClientProvider client={client}>
@@ -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 = (body) => {
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={(e) => {
146
+ onClick={e => {
147
147
  e.stopPropagation();
148
- setPasswordShown((prev) => !prev);
148
+ setPasswordShown(prev => !prev);
149
149
  }}
150
150
  label={formatMessage(
151
151
  passwordShown
@@ -23,7 +23,7 @@ const client = new QueryClient({
23
23
  },
24
24
  });
25
25
 
26
- const makeApp = (history) => (
26
+ const makeApp = history => (
27
27
  <Router history={history}>
28
28
  <ThemeProvider theme={lightTheme}>
29
29
  <QueryClientProvider client={client}>
@@ -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 (toggleNotification) => {
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 = (err) => {
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: (error) => handleError(error),
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: (error) => handleError(error),
40
+ onError: error => handleError(error),
41
41
  });
42
42
 
43
43
  return { data, isLoading, deleteMutation, submitMutation, regenerateDocMutation };
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../pluginId';
2
2
 
3
- const getTrad = (id) => `${pluginId}.${id}`;
3
+ const getTrad = id => `${pluginId}.${id}`;
4
4
 
5
5
  export default getTrad;
@@ -1,6 +1,6 @@
1
1
  import { startsWith } from 'lodash';
2
2
 
3
- const openWithNewTab = (path) => {
3
+ const openWithNewTab = path => {
4
4
  const url = (() => {
5
5
  if (startsWith(path, '/')) {
6
6
  return `${strapi.backendURL}${path}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "0.0.0-4fc90398602f",
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-4fc90398602f",
28
- "@strapi/utils": "0.0.0-4fc90398602f",
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": "4fc90398602f4a07f8ae8f04968c48d669992707"
61
+ "gitHead": "8581854cb3c817ae42b829ea686a1b0702ed9245"
62
62
  }
@@ -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.plugin('documentation').service('documentation').generateFullDoc();
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.plugin('documentation').service('documentation').getDocumentationVersion();
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((el) => el.version);
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((el) => el.version);
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.');
@@ -1,27 +1,12 @@
1
- <!-- HTML for static distribution bundle build --><!DOCTYPE html>
2
- <html lang="en">
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
- rel="stylesheet"
8
- type="text/css"
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
- margin: 0;
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"></script>
68
- <script src="<%=backendUrl%>/plugins/documentation/swagger-ui-standalone-preset.js"></script>
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>
@@ -1,145 +1,135 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Login - Documentation</title>
5
- <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" />
6
- <style>
7
- html {
8
- font-size: 62.5%;
9
- height: 100%;
10
- margin: 0;
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
- body {
15
- height: 100%;
16
- margin: 0;
17
- background-color: #ffffff;
18
- font-family: 'Lato';
19
- font-size: 1.4rem;
20
- font-weight: 400;
21
- text-rendering: optimizeLegibility;
22
- -webkit-font-smoothing: antialiased;
23
- -moz-osx-font-smoothing: grayscale;
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
- .login {
27
- height: 100%;
28
- background-color: #f6f9fc;
29
- }
24
+ .login {
25
+ height: 100%;
26
+ background-color: #F6F9FC;
27
+ }
30
28
 
31
- .login .login-form {
32
- height: calc(100% - 70px);
33
- padding: 68px 0 0;
34
- text-align: center;
35
- }
29
+ .login .login-form {
30
+ height: calc(100% - 70px);
31
+ padding: 68px 0 0;
32
+ text-align: center;
33
+ }
36
34
 
37
- .login .login-form form {
38
- position: relative;
39
- max-width: 460px;
40
- padding: 26px 30px;
41
- margin: 55px auto 0;
42
- background-color: #ffffff;
43
- border-radius: 3px;
44
- box-shadow: 0px 2px 4px rgba(91, 107, 174, 0.15);
45
- text-align: center;
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
- .login .login-form form:before {
49
- position: absolute;
50
- content: '';
51
- top: 0px;
52
- left: 0;
53
- display: inline-block;
54
- width: 100%;
55
- height: 2px;
56
- background-color: #2b66cc;
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
- .login .login-form form .error {
60
- display: block;
61
- color: #ff4e00;
62
- padding-bottom: 20px;
63
- }
57
+ .login .login-form form .error {
58
+ display: block;
59
+ color: #FF4E00;
60
+ padding-bottom: 20px;
61
+ }
64
62
 
65
- .login .login-form .sub-title {
66
- margin-top: 35px;
67
- font-size: 1.6rem;
68
- font-weight: 400;
69
- }
63
+ .login .login-form .sub-title {
64
+ margin-top: 35px;
65
+ font-size: 1.6rem;
66
+ font-weight: 400;
67
+ }
70
68
 
71
- .login .login-form .logo {
72
- max-height: 40px;
73
- }
69
+ .login .login-form .logo{
70
+ max-height: 40px;
71
+ }
74
72
 
75
- .login .login-form form label {
76
- display: block;
77
- margin-bottom: 18px;
78
- width: 100%;
79
- text-align: left;
80
- font-weight: 600;
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
- .login .login-form form input {
84
- outline: none;
85
- width: calc(100% - 30px);
86
- height: 36px;
87
- padding: 0 15px;
88
- border: 1px solid #ececec;
89
- border-radius: 2px;
90
- margin-bottom: 20px;
91
- line-height: 36px;
92
- text-align: left;
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
- .login .login-form form input[type='submit'] {
96
- cursor: pointer;
97
- display: inline-block;
98
- width: auto;
99
- margin: 12px auto 0;
100
- padding: 0 75px;
101
- background: transparent;
102
- border-radius: 36px;
103
- border: 1px solid #2b66cc;
104
- color: #2b66cc;
105
- text-transform: uppercase;
106
- font-size: 1.4rem;
107
- font-weight: 700;
108
- transition: all 0.2s ease-out;
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
- .login .login-form form input[type='submit']:hover {
112
- background: #2b66cc;
113
- color: #ffffff;
114
- }
115
- </style>
116
- </head>
117
- <body>
118
- <div class="login">
119
- <section class="login-form">
120
- <div class="container">
121
- <div class="row">
122
- <div class="col-lg-6 col-lg-offset-3 col-md-12">
123
- <img
124
- alt="Strapi logo"
125
- class="logo"
126
- src="https://strapi.io/assets/images/logo_login.png"
127
- />
128
- <h2 class="sub-title">Enter the password to access the documentation.</h2>
129
- <form method="post" action="<%=actionUrl%>">
130
- <span class="error">Wrong password...</span>
131
- <label>Password</label>
132
- <input
133
- type="password"
134
- name="password"
135
- placeholder="&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;"
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="&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;&#x2022;">
127
+ <input type="submit" value="Login">
128
+ </form>
129
+ </div>
139
130
  </div>
140
131
  </div>
141
- </div>
142
- </section>
143
- </div>
144
- </body>
145
- </html>
132
+ </section>
133
+ </div>
134
+
135
+ </body></html>
@@ -1,5 +1,4 @@
1
1
  'use strict';
2
-
3
2
  const restrictAccess = require('../middlewares/restrict-access');
4
3
 
5
4
  module.exports = [
@@ -38,7 +38,7 @@ module.exports = ({ strapi }) => {
38
38
  getDocumentationVersions() {
39
39
  return fs
40
40
  .readdirSync(this.getFullDocumentationPath())
41
- .map((version) => {
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((x) => x);
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((plugin) => {
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((api) => {
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((doc) => {
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 = (routePath) => {
18
+ const parsePathWithVariables = routePath => {
19
19
  return pathToRegexp
20
20
  .parse(routePath)
21
- .map((token) => {
21
+ .map(token => {
22
22
  if (_.isObject(token)) {
23
- return `${token.prefix}{${token.name}}`;
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 = (routePath) => {
38
+ const getPathParams = routePath => {
39
39
  return pathToRegexp
40
40
  .parse(routePath)
41
- .filter((token) => _.isObject(token))
42
- .map((param) => {
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((route) => {
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 = (apiInfo) => {
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 = (api) => {
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((route) => route.method);
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((route) => hasFindMethod(route.handler)).length;
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 = (api) => {
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 of Object.keys(attributesCopy)) {
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((component) => {
116
+ const components = attribute.components.map(component => {
117
117
  const componentAttributes = strapi.components[component].attributes;
118
118
  return {
119
119
  type: 'object',
@@ -1,5 +1,4 @@
1
1
  'use strict';
2
-
3
2
  const _ = require('lodash');
4
3
 
5
4
  /**
@@ -2,7 +2,7 @@
2
2
 
3
3
  const _ = require('lodash');
4
4
 
5
- const pascalCase = (string) => {
5
+ const pascalCase = string => {
6
6
  return _.upperFirst(_.camelCase(string));
7
7
  };
8
8
 
@@ -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,