@akemona-org/strapi-plugin-documentation 3.7.0 → 3.7.2

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.
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { FormattedMessage } from 'react-intl';
9
9
  import { Wrapper, Title } from './components';
10
10
 
11
- const renderMsg = msg => <p>{msg}</p>;
11
+ const renderMsg = (msg) => <p>{msg}</p>;
12
12
 
13
13
  const Block = ({ children, description, style, title }) => (
14
14
  <div className="col-md-12">
@@ -35,8 +35,8 @@ const StyledButton = styled(Button)`
35
35
  font-size: 13px;
36
36
  font-weight: 500;
37
37
  ${({ type }) => {
38
- if (type === 'openDocumentation') {
39
- return css`
38
+ if (type === 'openDocumentation') {
39
+ return css`
40
40
  margin-right: 10px;
41
41
  border: 1px solid #dfe0e1;
42
42
  &:before {
@@ -46,9 +46,9 @@ const StyledButton = styled(Button)`
46
46
  font-size: 10px;
47
47
  }
48
48
  `;
49
- }
50
- if (type === 'generateDocumentation') {
51
- return css`
49
+ }
50
+ if (type === 'generateDocumentation') {
51
+ return css`
52
52
  background: #e6f0fb;
53
53
  border: 1px solid #aed4fb;
54
54
  color: #007eff;
@@ -59,9 +59,9 @@ const StyledButton = styled(Button)`
59
59
  font-size: 10px;
60
60
  }
61
61
  `;
62
- }
63
- if (type === 'trash') {
64
- return css`
62
+ }
63
+ if (type === 'trash') {
64
+ return css`
65
65
  margin-left: 25px;
66
66
  font-weight: 400;
67
67
  &:before {
@@ -71,13 +71,13 @@ const StyledButton = styled(Button)`
71
71
  font-size: 12 px;
72
72
  }
73
73
  `;
74
- }
74
+ }
75
75
 
76
- return css`
76
+ return css`
77
77
  margin-left: 45px;
78
78
  font-weight: 400;
79
79
  `;
80
- }}
80
+ }}
81
81
  `;
82
82
 
83
83
  export { Wrapper, StyledButton };
@@ -8,13 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import ButtonContainer from './ButtonContainer';
9
9
  import { Wrapper } from './components';
10
10
 
11
- function Row({
12
- currentDocVersion,
13
- data,
14
- isHeader,
15
- onClickDelete,
16
- onUpdateDoc,
17
- }) {
11
+ function Row({ currentDocVersion, data, isHeader, onClickDelete, onUpdateDoc }) {
18
12
  const { version, generatedDate } = data;
19
13
 
20
14
  return (
@@ -67,7 +67,7 @@ export class HomePage extends React.Component {
67
67
  onClick: this.openCurrentDocumentation,
68
68
  type: 'button',
69
69
  key: 'button-open',
70
- Component: props => (
70
+ Component: (props) => (
71
71
  <CheckPermissions permissions={pluginPermissions.open}>
72
72
  <Button {...props} />
73
73
  </CheckPermissions>
@@ -81,7 +81,7 @@ export class HomePage extends React.Component {
81
81
  onClick: () => {},
82
82
  type: 'submit',
83
83
  key: 'button-submit',
84
- Component: props => (
84
+ Component: (props) => (
85
85
  <CheckPermissions permissions={pluginPermissions.update}>
86
86
  <Button {...props} />
87
87
  </CheckPermissions>
@@ -106,7 +106,7 @@ export class HomePage extends React.Component {
106
106
  return openWithNewTab(`${slash}${prefix}/v${currentDocVersion}`);
107
107
  };
108
108
 
109
- shouldHideInput = inputName => {
109
+ shouldHideInput = (inputName) => {
110
110
  return !this.getRestrictedAccessValue() && inputName === 'password';
111
111
  };
112
112
 
@@ -137,7 +137,7 @@ export class HomePage extends React.Component {
137
137
  );
138
138
  };
139
139
 
140
- renderRow = data => {
140
+ renderRow = (data) => {
141
141
  const { currentDocVersion, onClickDeleteDoc, onUpdateDoc } = this.props;
142
142
 
143
143
  return (
@@ -152,14 +152,8 @@ export class HomePage extends React.Component {
152
152
  };
153
153
 
154
154
  render() {
155
- const {
156
- docVersions,
157
- form,
158
- isLoading,
159
- onConfirmDeleteDoc,
160
- onSubmit,
161
- versionToDelete,
162
- } = this.props;
155
+ const { docVersions, form, isLoading, onConfirmDeleteDoc, onSubmit, versionToDelete } =
156
+ this.props;
163
157
 
164
158
  const { formatMessage } = this.context;
165
159
 
@@ -39,7 +39,7 @@ function homePageReducer(state = initialState, action) {
39
39
  return state.update('versionToDelete', () => action.version);
40
40
  case SET_FORM_ERRORS:
41
41
  return state
42
- .update('didCheckErrors', v => !v)
42
+ .update('didCheckErrors', (v) => !v)
43
43
  .update('formErrors', () => fromJS(action.errors));
44
44
  default:
45
45
  return state;
@@ -4,31 +4,22 @@ import pluginId from '../../pluginId';
4
4
  /**
5
5
  * Direct selector to the homePage state domain
6
6
  */
7
- const selectHomePageDomain = () => state => state.get(`${pluginId}_homePage`);
7
+ const selectHomePageDomain = () => (state) => state.get(`${pluginId}_homePage`);
8
8
 
9
9
  /**
10
10
  * Default selector used by HomePage
11
11
  */
12
12
 
13
- const selectHomePage = () => createSelector(
14
- selectHomePageDomain(),
15
- (substate) => substate.toJS(),
16
- );
13
+ const selectHomePage = () => createSelector(selectHomePageDomain(), (substate) => substate.toJS());
17
14
 
18
- const makeSelectForm = () => createSelector(
19
- selectHomePageDomain(),
20
- substate => substate.get('form').toJS(),
21
- );
15
+ const makeSelectForm = () =>
16
+ createSelector(selectHomePageDomain(), (substate) => substate.get('form').toJS());
22
17
 
23
- const makeSelectPrefix = () => createSelector(
24
- selectHomePageDomain(),
25
- substate => substate.get('prefix'),
26
- );
18
+ const makeSelectPrefix = () =>
19
+ createSelector(selectHomePageDomain(), (substate) => substate.get('prefix'));
27
20
 
28
- const makeSelectVersionToDelete = () => createSelector(
29
- selectHomePageDomain(),
30
- substate => substate.get('versionToDelete'),
31
- );
21
+ const makeSelectVersionToDelete = () =>
22
+ createSelector(selectHomePageDomain(), (substate) => substate.get('versionToDelete'));
32
23
 
33
24
  export default selectHomePage;
34
25
  export { makeSelectForm, makeSelectVersionToDelete, makeSelectPrefix };
@@ -15,7 +15,7 @@ import lifecycles from './lifecycles';
15
15
  import reducers from './reducers';
16
16
  import trads from './translations';
17
17
 
18
- export default strapi => {
18
+ export default (strapi) => {
19
19
  const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
20
20
  const icon = pluginPkg.strapi.icon;
21
21
  const name = pluginPkg.strapi.name;
@@ -1,5 +1,5 @@
1
1
  import pluginPkg from '../../package.json';
2
2
 
3
- const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, '');
3
+ const pluginId = pluginPkg.name.replace(/^@akemona-org\/strapi-plugin-/i, '');
4
4
 
5
5
  export default pluginId;
@@ -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}`;
@@ -27,7 +27,7 @@ module.exports = async () => {
27
27
  const services = strapi.plugins['documentation'].services.documentation;
28
28
  // Generate plugins' documentation
29
29
  const pluginsWithDocumentationNeeded = services.getPluginsWithDocumentationNeeded();
30
- pluginsWithDocumentationNeeded.forEach(plugin => {
30
+ pluginsWithDocumentationNeeded.forEach((plugin) => {
31
31
  const isDocExisting = services.checkIfPluginDocumentationFolderExists(plugin);
32
32
 
33
33
  if (!isDocExisting) {
@@ -49,7 +49,7 @@ module.exports = async () => {
49
49
  // Retrieve all the apis from the apis directory
50
50
  const apis = services.getApis();
51
51
  // Generate APIS' documentation
52
- apis.forEach(api => {
52
+ apis.forEach((api) => {
53
53
  const isDocExisting = services.checkIfDocumentationFolderExists(api);
54
54
 
55
55
  if (!isDocExisting) {
@@ -81,9 +81,9 @@ module.exports = async () => {
81
81
  * @param {Object} documentation
82
82
  * @returns {String}
83
83
  */
84
- const getDocTagsToString = documentation => {
84
+ const getDocTagsToString = (documentation) => {
85
85
  return _.get(documentation, 'tags', [])
86
- .map(tag => {
86
+ .map((tag) => {
87
87
  return tag.name.toLowerCase();
88
88
  })
89
89
  .sort((a, b) => a - b)
@@ -16,7 +16,7 @@ const _ = require('lodash');
16
16
  const koaStatic = require('koa-static');
17
17
 
18
18
  module.exports = {
19
- getInfos: async ctx => {
19
+ getInfos: async (ctx) => {
20
20
  try {
21
21
  const service = strapi.plugins.documentation.services.documentation;
22
22
  const docVersions = service.retrieveDocumentationVersions();
@@ -174,9 +174,9 @@ module.exports = {
174
174
  );
175
175
  },
176
176
 
177
- regenerateDoc: async ctx => {
177
+ regenerateDoc: async (ctx) => {
178
178
  const service = strapi.plugins.documentation.services.documentation;
179
- const documentationVersions = service.retrieveDocumentationVersions().map(el => el.version);
179
+ const documentationVersions = service.retrieveDocumentationVersions().map((el) => el.version);
180
180
  const {
181
181
  request: {
182
182
  body: { version },
@@ -218,10 +218,10 @@ module.exports = {
218
218
  }
219
219
  },
220
220
 
221
- deleteDoc: async ctx => {
221
+ deleteDoc: async (ctx) => {
222
222
  strapi.reload.isWatching = false;
223
223
  const service = strapi.plugins.documentation.services.documentation;
224
- const documentationVersions = service.retrieveDocumentationVersions().map(el => el.version);
224
+ const documentationVersions = service.retrieveDocumentationVersions().map((el) => el.version);
225
225
  const {
226
226
  request: {
227
227
  params: { version },
@@ -255,7 +255,7 @@ module.exports = {
255
255
  }
256
256
  },
257
257
 
258
- updateSettings: async ctx => {
258
+ updateSettings: async (ctx) => {
259
259
  const {
260
260
  admin,
261
261
  body: { restrictedAccess, password },
@@ -13,7 +13,7 @@ const koaStatic = require('koa-static');
13
13
  // Variables.
14
14
  const initialRoutes = [];
15
15
 
16
- module.exports = strapi => {
16
+ module.exports = (strapi) => {
17
17
  return {
18
18
  beforeInitialize() {
19
19
  strapi.config.middleware.load.before.push('documentation');
@@ -36,10 +36,11 @@ module.exports = strapi => {
36
36
  // Set prefix to empty to be able to customise it.
37
37
  if (_.get(strapi.plugins, ['documentation', 'config', 'x-strapi-config', 'path'])) {
38
38
  route.config.prefix = '';
39
- route.path = `/${strapi.plugins.documentation.config['x-strapi-config'].path}${route.path}`.replace(
40
- '//',
41
- '/'
42
- );
39
+ route.path =
40
+ `/${strapi.plugins.documentation.config['x-strapi-config'].path}${route.path}`.replace(
41
+ '//',
42
+ '/'
43
+ );
43
44
  }
44
45
 
45
46
  return route;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.7.0",
6
+ "version": "3.7.2",
7
7
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
8
8
  "strapi": {
9
9
  "name": "Documentation",
@@ -14,7 +14,7 @@
14
14
  "test": "echo \"no tests yet\""
15
15
  },
16
16
  "dependencies": {
17
- "@akemona-org/strapi-helper-plugin": "3.7.0",
17
+ "@akemona-org/strapi-helper-plugin": "3.7.2",
18
18
  "@buffetjs/core": "3.3.8",
19
19
  "@buffetjs/custom": "3.3.8",
20
20
  "@buffetjs/hooks": "3.3.8",
@@ -85,5 +85,5 @@
85
85
  "npm": ">=6.0.0"
86
86
  },
87
87
  "license": "SEE LICENSE IN LICENSE",
88
- "gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
88
+ "gitHead": "4ab59dbae5135819558c6ae27b45a556ff27cf55"
89
89
  }
@@ -10,9 +10,13 @@ const path = require('path');
10
10
  const _ = require('lodash');
11
11
  const moment = require('moment');
12
12
  const pathToRegexp = require('path-to-regexp');
13
+ // eslint-disable-next-line import/extensions
13
14
  const defaultSettings = require('../config/settings.json');
15
+ // eslint-disable-next-line import/extensions
14
16
  const defaultComponents = require('./utils/components.json');
17
+ // eslint-disable-next-line import/extensions
15
18
  const form = require('./utils/forms.json');
19
+ // eslint-disable-next-line import/extensions
16
20
  const parametersOptions = require('./utils/parametersOptions.json');
17
21
 
18
22
  // keys to pick from the extended config
@@ -24,23 +28,23 @@ const customComparator = (value1, value2) => {
24
28
  if (value1.length !== value2.length) {
25
29
  return false;
26
30
  }
27
- return value1.every(el1 => value2.findIndex(el2 => customIsEqual(el1, el2)) >= 0);
31
+ return value1.every((el1) => value2.findIndex((el2) => customIsEqual(el1, el2)) >= 0);
28
32
  }
29
33
  };
30
34
 
31
35
  module.exports = {
32
- areObjectsEquals: function(obj1, obj2) {
36
+ areObjectsEquals: function (obj1, obj2) {
33
37
  // stringify to remove nested empty objects
34
38
  return customIsEqual(this.cleanObject(obj1), this.cleanObject(obj2));
35
39
  },
36
40
 
37
- cleanObject: obj => JSON.parse(JSON.stringify(obj)),
41
+ cleanObject: (obj) => JSON.parse(JSON.stringify(obj)),
38
42
 
39
43
  arrayCustomizer: (objValue, srcValue) => {
40
44
  if (_.isArray(objValue)) return objValue.concat(srcValue);
41
45
  },
42
46
 
43
- checkIfAPIDocNeedsUpdate: function(apiName) {
47
+ checkIfAPIDocNeedsUpdate: function (apiName) {
44
48
  const prevDocumentation = this.createDocObject(this.retrieveDocumentation(apiName));
45
49
  const currentDocumentation = this.createDocObject(this.createDocumentationFile(apiName, false));
46
50
 
@@ -51,7 +55,7 @@ module.exports = {
51
55
  * Check if the documentation folder with its related version of an API exists
52
56
  * @param {String} apiName
53
57
  */
54
- checkIfDocumentationFolderExists: function(apiName) {
58
+ checkIfDocumentationFolderExists: function (apiName) {
55
59
  try {
56
60
  fs.accessSync(this.getDocumentationPath(apiName));
57
61
  return true;
@@ -60,7 +64,7 @@ module.exports = {
60
64
  }
61
65
  },
62
66
 
63
- checkIfPluginDocumentationFolderExists: function(pluginName) {
67
+ checkIfPluginDocumentationFolderExists: function (pluginName) {
64
68
  try {
65
69
  fs.accessSync(this.getPluginDocumentationPath(pluginName));
66
70
  return true;
@@ -69,7 +73,7 @@ module.exports = {
69
73
  }
70
74
  },
71
75
 
72
- checkIfPluginDocNeedsUpdate: function(pluginName) {
76
+ checkIfPluginDocNeedsUpdate: function (pluginName) {
73
77
  const prevDocumentation = this.createDocObject(this.retrieveDocumentation(pluginName, true));
74
78
  const currentDocumentation = this.createDocObject(
75
79
  this.createPluginDocumentationFile(pluginName, false)
@@ -78,7 +82,7 @@ module.exports = {
78
82
  return !this.areObjectsEquals(prevDocumentation, currentDocumentation);
79
83
  },
80
84
 
81
- checkIfApiDefaultDocumentationFileExist: function(apiName, docName) {
85
+ checkIfApiDefaultDocumentationFileExist: function (apiName, docName) {
82
86
  try {
83
87
  fs.accessSync(this.getAPIOverrideDocumentationPath(apiName, docName));
84
88
  return true;
@@ -87,7 +91,7 @@ module.exports = {
87
91
  }
88
92
  },
89
93
 
90
- checkIfPluginDefaultDocumentFileExists: function(pluginName, docName) {
94
+ checkIfPluginDefaultDocumentFileExists: function (pluginName, docName) {
91
95
  try {
92
96
  fs.accessSync(this.getPluginOverrideDocumentationPath(pluginName, docName));
93
97
  return true;
@@ -100,7 +104,7 @@ module.exports = {
100
104
  * Check if the documentation folder exists in the documentation plugin
101
105
  * @returns {Boolean}
102
106
  */
103
- checkIfMergedDocumentationFolderExists: function() {
107
+ checkIfMergedDocumentationFolderExists: function () {
104
108
  try {
105
109
  fs.accessSync(this.getMergedDocumentationPath());
106
110
  return true;
@@ -114,7 +118,7 @@ module.exports = {
114
118
  * @param {String} targetDir
115
119
  *
116
120
  */
117
- createDocumentationDirectory: function(targetDir) {
121
+ createDocumentationDirectory: function (targetDir) {
118
122
  const sep = path.sep;
119
123
  const initDir = path.isAbsolute(targetDir) ? sep : '';
120
124
  const baseDir = '.';
@@ -153,7 +157,7 @@ module.exports = {
153
157
  * Create the apiName.json and unclassified.json files inside an api's documentation/version folder
154
158
  * @param {String} apiName
155
159
  */
156
- createDocumentationFile: function(apiName, writeFile = true) {
160
+ createDocumentationFile: function (apiName, writeFile = true) {
157
161
  // Retrieve all the routes from an API
158
162
  const apiRoutes = this.getApiRoutes(apiName);
159
163
  const apiDocumentation = this.generateApiDocumentation(apiName, apiRoutes);
@@ -178,7 +182,7 @@ module.exports = {
178
182
  }, []);
179
183
  },
180
184
 
181
- createPluginDocumentationFile: function(pluginName, writeFile = true) {
185
+ createPluginDocumentationFile: function (pluginName, writeFile = true) {
182
186
  const pluginRoutes = this.getPluginRoutesWithDescription(pluginName);
183
187
  const pluginDocumentation = this.generatePluginDocumentation(pluginName, pluginRoutes);
184
188
 
@@ -211,20 +215,20 @@ module.exports = {
211
215
  }, []);
212
216
  },
213
217
 
214
- createDocObject: function(array) {
218
+ createDocObject: function (array) {
215
219
  // use custom merge for arrays
216
220
  return array.reduce((acc, curr) => _.mergeWith(acc, curr, this.arrayCustomizer), {});
217
221
  },
218
222
 
219
- deleteDocumentation: async function(version = this.getDocumentationVersion()) {
223
+ deleteDocumentation: async function (version = this.getDocumentationVersion()) {
220
224
  const recursiveDeleteFiles = async (folderPath, removeCompleteFolder = true) => {
221
225
  // Check if folderExist
222
226
  try {
223
227
  const arrayOfPromises = [];
224
228
  fs.accessSync(folderPath);
225
- const items = fs.readdirSync(folderPath).filter(x => x[0] !== '.');
229
+ const items = fs.readdirSync(folderPath).filter((x) => x[0] !== '.');
226
230
 
227
- items.forEach(item => {
231
+ items.forEach((item) => {
228
232
  const itemPath = path.join(folderPath, item);
229
233
 
230
234
  // Check if directory
@@ -264,12 +268,12 @@ module.exports = {
264
268
  const apis = this.getApis();
265
269
  const plugins = this.getPluginsWithDocumentationNeeded();
266
270
 
267
- apis.forEach(api => {
271
+ apis.forEach((api) => {
268
272
  const apiPath = path.join(strapi.config.appPath, 'api', api, 'documentation', version);
269
273
  arrayOfPromises.push(recursiveDeleteFiles(apiPath));
270
274
  });
271
275
 
272
- plugins.forEach(plugin => {
276
+ plugins.forEach((plugin) => {
273
277
  const pluginPath = path.join(
274
278
  strapi.config.appPath,
275
279
  'extensions',
@@ -303,10 +307,10 @@ module.exports = {
303
307
  * @param {String} endPoint
304
308
  * @returns {String} (/products/{id})
305
309
  */
306
- formatApiEndPoint: endPoint => {
310
+ formatApiEndPoint: (endPoint) => {
307
311
  return pathToRegexp
308
312
  .parse(endPoint)
309
- .map(token => {
313
+ .map((token) => {
310
314
  if (_.isObject(token)) {
311
315
  return token.prefix + '{' + token.name + '}'; // eslint-disable-line prefer-template
312
316
  }
@@ -326,7 +330,7 @@ module.exports = {
326
330
  formatTag: (plugin, name, withoutSpace = false) => {
327
331
  const formattedPluginName = plugin
328
332
  .split('-')
329
- .map(i => _.upperFirst(i))
333
+ .map((i) => _.upperFirst(i))
330
334
  .join('');
331
335
  const formattedName = _.upperFirst(name);
332
336
 
@@ -337,7 +341,7 @@ module.exports = {
337
341
  return `${formattedPluginName} - ${formattedName}`;
338
342
  },
339
343
 
340
- generateAssociationSchema: function(attributes, getter) {
344
+ generateAssociationSchema: function (attributes, getter) {
341
345
  return Object.keys(attributes).reduce(
342
346
  (acc, curr) => {
343
347
  const attribute = attributes[curr];
@@ -353,7 +357,7 @@ module.exports = {
353
357
  const newGetter = getter.slice();
354
358
  newGetter.splice(newGetter.length - 1, 1, 'associations');
355
359
  const relationNature = _.get(strapi, newGetter).filter(
356
- association => association.alias === curr
360
+ (association) => association.alias === curr
357
361
  )[0].nature;
358
362
 
359
363
  switch (relationNature) {
@@ -386,7 +390,7 @@ module.exports = {
386
390
  * @param {Array} routes
387
391
  * @returns {Object}
388
392
  */
389
- generateApiDocumentation: function(apiName, routes) {
393
+ generateApiDocumentation: function (apiName, routes) {
390
394
  return routes.reduce((acc, current) => {
391
395
  const [controllerName, controllerMethod] = current.handler.split('.');
392
396
  // Retrieve the tag key in the config object
@@ -396,7 +400,7 @@ module.exports = {
396
400
  let verb;
397
401
 
398
402
  if (Array.isArray(current.method)) {
399
- verb = current.method.map(method => method.toLowerCase());
403
+ verb = current.method.map((method) => method.toLowerCase());
400
404
  } else {
401
405
  verb = current.method.toLowerCase();
402
406
  }
@@ -436,7 +440,7 @@ module.exports = {
436
440
 
437
441
  // Swagger is not support key with ',' symbol, for array of methods need generate documentation for each method
438
442
  if (Array.isArray(verb)) {
439
- verb.forEach(method => {
443
+ verb.forEach((method) => {
440
444
  _.set(acc, [key, 'paths', endPoint, method], verbObject);
441
445
  });
442
446
  } else {
@@ -477,7 +481,7 @@ module.exports = {
477
481
  }
478
482
 
479
483
  if (Array.isArray(verb)) {
480
- verb.forEach(method => {
484
+ verb.forEach((method) => {
481
485
  _.set(acc, [key, 'paths', endPoint, method, 'requestBody'], requestBody);
482
486
  });
483
487
  } else {
@@ -490,7 +494,7 @@ module.exports = {
490
494
 
491
495
  if (!verb.includes('post')) {
492
496
  if (Array.isArray(verb)) {
493
- verb.forEach(method => {
497
+ verb.forEach((method) => {
494
498
  _.set(acc, [key, 'paths', endPoint, method, 'parameters'], parameters);
495
499
  });
496
500
  } else {
@@ -502,7 +506,7 @@ module.exports = {
502
506
  }, {});
503
507
  },
504
508
 
505
- generateFullDoc: function(version = this.getDocumentationVersion()) {
509
+ generateFullDoc: function (version = this.getDocumentationVersion()) {
506
510
  const apisDoc = this.retrieveDocumentationFiles(false, version);
507
511
  const pluginsDoc = this.retrieveDocumentationFiles(true, version);
508
512
  const appDoc = [...apisDoc, ...pluginsDoc];
@@ -512,7 +516,7 @@ module.exports = {
512
516
  _.set(defaultSettings, ['info', 'x-generation-date'], moment().format('L LTS'));
513
517
  _.set(defaultSettings, ['info', 'version'], version);
514
518
  const tags = appDoc.reduce((acc, current) => {
515
- const tags = current.tags.filter(el => {
519
+ const tags = current.tags.filter((el) => {
516
520
  return _.findIndex(acc, ['name', el.name || '']) === -1;
517
521
  });
518
522
 
@@ -536,7 +540,7 @@ module.exports = {
536
540
  * @param {Array} associations
537
541
  * @returns {Object}
538
542
  */
539
- generateMainComponent: function(attributes, associations) {
543
+ generateMainComponent: function (attributes, associations) {
540
544
  return Object.keys(attributes).reduce(
541
545
  (acc, current) => {
542
546
  const attribute = attributes[current];
@@ -558,7 +562,7 @@ module.exports = {
558
562
 
559
563
  if (attribute.model || attribute.collection) {
560
564
  const currentAssociation = associations.filter(
561
- association => association.alias === current
565
+ (association) => association.alias === current
562
566
  )[0];
563
567
  const relationNature = currentAssociation.nature;
564
568
  const name = currentAssociation.model || currentAssociation.collection;
@@ -612,7 +616,7 @@ module.exports = {
612
616
  } else if (type === 'dynamiczone') {
613
617
  const { components, min, max } = attribute;
614
618
 
615
- const cmps = components.map(component => {
619
+ const cmps = components.map((component) => {
616
620
  const schema = this.generateMainComponent(
617
621
  strapi.components[component].attributes,
618
622
  strapi.components[component].associations
@@ -659,7 +663,7 @@ module.exports = {
659
663
  );
660
664
  },
661
665
 
662
- generatePluginDocumentation: function(pluginName, routes) {
666
+ generatePluginDocumentation: function (pluginName, routes) {
663
667
  return routes.reduce((acc, current) => {
664
668
  const {
665
669
  config: { description, prefix },
@@ -671,7 +675,7 @@ module.exports = {
671
675
  let verb;
672
676
 
673
677
  if (Array.isArray(current.method)) {
674
- verb = current.method.map(method => method.toLowerCase());
678
+ verb = current.method.map((method) => method.toLowerCase());
675
679
  } else {
676
680
  verb = current.method.toLowerCase();
677
681
  }
@@ -713,7 +717,7 @@ module.exports = {
713
717
  if (_.isEmpty(defaultDocumentation)) {
714
718
  if (!verb.includes('post')) {
715
719
  if (Array.isArray(verb)) {
716
- verb.forEach(method => {
720
+ verb.forEach((method) => {
717
721
  _.set(acc, [key, 'paths', endPoint, method, 'parameters'], parameters);
718
722
  });
719
723
  } else {
@@ -761,7 +765,7 @@ module.exports = {
761
765
  }
762
766
 
763
767
  if (Array.isArray(verb)) {
764
- verb.forEach(method => {
768
+ verb.forEach((method) => {
765
769
  _.set(acc, [key, 'paths', endPoint, method, 'requestBody'], requestBody);
766
770
  });
767
771
  } else {
@@ -774,7 +778,7 @@ module.exports = {
774
778
  }, {});
775
779
  },
776
780
 
777
- generatePluginResponseSchema: function(tag) {
781
+ generatePluginResponseSchema: function (tag) {
778
782
  const { actionType, name, plugin } = _.isObject(tag) ? tag : { tag };
779
783
  const getter = plugin ? ['plugins', plugin, 'models', name.toLowerCase()] : ['models', name];
780
784
  const isModelRelated =
@@ -827,7 +831,7 @@ module.exports = {
827
831
  };
828
832
  },
829
833
 
830
- generatePluginVerbResponses: function(routeObject) {
834
+ generatePluginVerbResponses: function (routeObject) {
831
835
  const {
832
836
  config: { tag },
833
837
  } = routeObject;
@@ -902,7 +906,7 @@ module.exports = {
902
906
  * @param {String} tag
903
907
  * @returns {Object}
904
908
  */
905
- generateResponses: function(verb, routeObject, tag) {
909
+ generateResponses: function (verb, routeObject, tag) {
906
910
  const endPoint = routeObject.path.split('/')[1];
907
911
  const description = this.generateResponseDescription(verb, tag, endPoint);
908
912
  const schema = this.generateResponseSchema(verb, routeObject, tag, endPoint);
@@ -960,7 +964,7 @@ module.exports = {
960
964
  * Retrieve all privates attributes from a model
961
965
  * @param {Object} attributes
962
966
  */
963
- getPrivateAttributes: function(attributes) {
967
+ getPrivateAttributes: function (attributes) {
964
968
  const privateAttributes = Object.keys(attributes).reduce((acc, current) => {
965
969
  if (attributes[current].private === true) {
966
970
  acc.push(current);
@@ -977,7 +981,7 @@ module.exports = {
977
981
  * @param {String} tag
978
982
  * @returns {Object}
979
983
  */
980
- generateResponseComponent: function(tag, pluginName = '', isPlugin = false) {
984
+ generateResponseComponent: function (tag, pluginName = '', isPlugin = false) {
981
985
  // The component's name have to be capitalised
982
986
  const [plugin, name] = isPlugin ? this.getModelAndNameForPlugin(tag, pluginName) : [null, null];
983
987
  const upperFirstTag = isPlugin ? this.formatTag(plugin, name, true) : _.upperFirst(tag);
@@ -992,10 +996,10 @@ module.exports = {
992
996
  const modelAssociations = _.get(strapi, associationGetter);
993
997
  const { attributes } = this.getModelAttributes(attributesObject);
994
998
  const associationsWithUpload = modelAssociations
995
- .filter(association => {
999
+ .filter((association) => {
996
1000
  return association.plugin === 'upload';
997
1001
  })
998
- .map(obj => obj.alias);
1002
+ .map((obj) => obj.alias);
999
1003
 
1000
1004
  // We always create two nested components from the main one
1001
1005
  const mainComponent = this.generateMainComponent(attributes, modelAssociations, upperFirstTag);
@@ -1015,7 +1019,7 @@ module.exports = {
1015
1019
  // Special component only for POST || PUT verbs since the upload is made with a different route
1016
1020
  const postComponent = Object.keys(mainComponent).reduce((acc, current) => {
1017
1021
  if (current === 'required') {
1018
- const required = mainComponent.required.slice().filter(attr => {
1022
+ const required = mainComponent.required.slice().filter((attr) => {
1019
1023
  return associationsWithUpload.indexOf(attr) === -1 && attr !== 'id' && attr !== '_id';
1020
1024
  });
1021
1025
 
@@ -1077,11 +1081,11 @@ module.exports = {
1077
1081
  * @param {String} endPoint
1078
1082
  * @returns {String}
1079
1083
  */
1080
- generateResponseDescription: function(verb, tag, endPoint) {
1084
+ generateResponseDescription: function (verb, tag, endPoint) {
1081
1085
  const isModelRelated = strapi.models[tag] !== undefined && tag === endPoint;
1082
1086
 
1083
1087
  if (Array.isArray(verb)) {
1084
- verb = verb.map(method => method.toLocaleLowerCase());
1088
+ verb = verb.map((method) => method.toLocaleLowerCase());
1085
1089
  }
1086
1090
 
1087
1091
  if (verb.includes('get') || verb.includes('put') || verb.includes('post')) {
@@ -1105,7 +1109,7 @@ module.exports = {
1105
1109
  * @param {String} endPoint
1106
1110
  * @returns {Object}
1107
1111
  */
1108
- generateResponseSchema: function(verb, routeObject, tag) {
1112
+ generateResponseSchema: function (verb, routeObject, tag) {
1109
1113
  const { handler } = routeObject;
1110
1114
  let [controller, handlerMethod] = handler.split('.');
1111
1115
  let upperFirstTag = _.upperFirst(tag);
@@ -1205,7 +1209,7 @@ module.exports = {
1205
1209
  };
1206
1210
  },
1207
1211
 
1208
- generateTags: function(name, docName, tag = '', isPlugin = false) {
1212
+ generateTags: function (name, docName, tag = '', isPlugin = false) {
1209
1213
  return [
1210
1214
  {
1211
1215
  name: isPlugin ? tag : _.upperFirst(docName),
@@ -1287,10 +1291,10 @@ module.exports = {
1287
1291
  * @param {String} controllerMethod
1288
1292
  * @param {String} endPoint
1289
1293
  */
1290
- generateVerbParameters: function(verb, controllerMethod, endPoint) {
1294
+ generateVerbParameters: function (verb, controllerMethod, endPoint) {
1291
1295
  const params = pathToRegexp
1292
1296
  .parse(endPoint)
1293
- .filter(token => _.isObject(token))
1297
+ .filter((token) => _.isObject(token))
1294
1298
  .reduce((acc, current) => {
1295
1299
  const param = {
1296
1300
  name: current.name,
@@ -1321,7 +1325,7 @@ module.exports = {
1321
1325
  return Object.keys(strapi.api || {});
1322
1326
  },
1323
1327
 
1324
- getAPIOverrideComponentsDocumentation: function(apiName, docName) {
1328
+ getAPIOverrideComponentsDocumentation: function (apiName, docName) {
1325
1329
  try {
1326
1330
  const documentation = JSON.parse(
1327
1331
  fs.readFileSync(this.getAPIOverrideDocumentationPath(apiName, docName), 'utf8')
@@ -1333,7 +1337,7 @@ module.exports = {
1333
1337
  }
1334
1338
  },
1335
1339
 
1336
- getAPIDefaultTagsDocumentation: function(name, docName) {
1340
+ getAPIDefaultTagsDocumentation: function (name, docName) {
1337
1341
  try {
1338
1342
  const documentation = JSON.parse(
1339
1343
  fs.readFileSync(this.getAPIOverrideDocumentationPath(name, docName), 'utf8')
@@ -1345,7 +1349,7 @@ module.exports = {
1345
1349
  }
1346
1350
  },
1347
1351
 
1348
- getAPIDefaultVerbDocumentation: function(apiName, docName, routePath, verb) {
1352
+ getAPIDefaultVerbDocumentation: function (apiName, docName, routePath, verb) {
1349
1353
  try {
1350
1354
  const documentation = JSON.parse(
1351
1355
  fs.readFileSync(this.getAPIOverrideDocumentationPath(apiName, docName), 'utf8')
@@ -1357,7 +1361,7 @@ module.exports = {
1357
1361
  }
1358
1362
  },
1359
1363
 
1360
- getAPIOverrideDocumentationPath: function(apiName, docName) {
1364
+ getAPIOverrideDocumentationPath: function (apiName, docName) {
1361
1365
  return path.join(
1362
1366
  strapi.config.appPath,
1363
1367
  'api',
@@ -1374,11 +1378,11 @@ module.exports = {
1374
1378
  * @param {String}
1375
1379
  * @returns {Array}
1376
1380
  */
1377
- getApiRoutes: apiName => {
1381
+ getApiRoutes: (apiName) => {
1378
1382
  return _.get(strapi, ['api', apiName, 'config', 'routes'], []);
1379
1383
  },
1380
1384
 
1381
- getDocumentationOverridesPath: function(apiName) {
1385
+ getDocumentationOverridesPath: function (apiName) {
1382
1386
  return path.join(
1383
1387
  strapi.config.appPath,
1384
1388
  'api',
@@ -1394,7 +1398,7 @@ module.exports = {
1394
1398
  * @param {String} apiName
1395
1399
  * @returns {Path}
1396
1400
  */
1397
- getDocumentationPath: function(apiName) {
1401
+ getDocumentationPath: function (apiName) {
1398
1402
  return path.join(
1399
1403
  strapi.config.appPath,
1400
1404
  'api',
@@ -1420,7 +1424,7 @@ module.exports = {
1420
1424
  /**
1421
1425
  * Retrieve the documentation plugin documentation directory
1422
1426
  */
1423
- getMergedDocumentationPath: function(version = this.getDocumentationVersion()) {
1427
+ getMergedDocumentationPath: function (version = this.getDocumentationVersion()) {
1424
1428
  return path.join(
1425
1429
  strapi.config.appPath,
1426
1430
  'extensions',
@@ -1435,10 +1439,10 @@ module.exports = {
1435
1439
  * @param {Objet} modelAttributes
1436
1440
  * @returns {Object} { associations: [{ name: 'foo', getter: [], tag: 'foos' }], attributes }
1437
1441
  */
1438
- getModelAttributes: function(modelAttributes) {
1442
+ getModelAttributes: function (modelAttributes) {
1439
1443
  const associations = [];
1440
1444
  const attributes = Object.keys(modelAttributes)
1441
- .map(attr => {
1445
+ .map((attr) => {
1442
1446
  const attribute = modelAttributes[attr];
1443
1447
  const isField = !_.has(attribute, 'model') && !_.has(attribute, 'collection');
1444
1448
 
@@ -1467,7 +1471,7 @@ module.exports = {
1467
1471
  * @param {String} type
1468
1472
  * @returns {String}
1469
1473
  */
1470
- getType: type => {
1474
+ getType: (type) => {
1471
1475
  switch (type) {
1472
1476
  case 'string':
1473
1477
  case 'byte':
@@ -1501,7 +1505,7 @@ module.exports = {
1501
1505
  * @param {String} type
1502
1506
  * @returns {String}
1503
1507
  */
1504
- getFormat: type => {
1508
+ getFormat: (type) => {
1505
1509
  switch (type) {
1506
1510
  case 'date':
1507
1511
  return 'date';
@@ -1514,7 +1518,7 @@ module.exports = {
1514
1518
  }
1515
1519
  },
1516
1520
 
1517
- getPluginDefaultVerbDocumentation: function(pluginName, docName, routePath, verb) {
1521
+ getPluginDefaultVerbDocumentation: function (pluginName, docName, routePath, verb) {
1518
1522
  try {
1519
1523
  const documentation = JSON.parse(
1520
1524
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1526,7 +1530,7 @@ module.exports = {
1526
1530
  }
1527
1531
  },
1528
1532
 
1529
- getPluginDefaultTagsDocumentation: function(pluginName, docName) {
1533
+ getPluginDefaultTagsDocumentation: function (pluginName, docName) {
1530
1534
  try {
1531
1535
  const documentation = JSON.parse(
1532
1536
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1538,7 +1542,7 @@ module.exports = {
1538
1542
  }
1539
1543
  },
1540
1544
 
1541
- getPluginOverrideComponents: function(pluginName, docName) {
1545
+ getPluginOverrideComponents: function (pluginName, docName) {
1542
1546
  try {
1543
1547
  const documentation = JSON.parse(
1544
1548
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1550,7 +1554,7 @@ module.exports = {
1550
1554
  }
1551
1555
  },
1552
1556
 
1553
- getPluginOverrideDocumentationPath: function(pluginName, docName) {
1557
+ getPluginOverrideDocumentationPath: function (pluginName, docName) {
1554
1558
  const defaultPath = path.join(
1555
1559
  strapi.config.appPath,
1556
1560
  'extensions',
@@ -1570,7 +1574,7 @@ module.exports = {
1570
1574
  /**
1571
1575
  * Given a plugin retrieve its documentation version
1572
1576
  */
1573
- getPluginDocumentationPath: function(pluginName) {
1577
+ getPluginDocumentationPath: function (pluginName) {
1574
1578
  return path.join(
1575
1579
  strapi.config.appPath,
1576
1580
  'extensions',
@@ -1584,7 +1588,7 @@ module.exports = {
1584
1588
  * Retrieve all plugins that have a description inside one of its route
1585
1589
  * @return {Arrray}
1586
1590
  */
1587
- getPluginsWithDocumentationNeeded: function() {
1591
+ getPluginsWithDocumentationNeeded: function () {
1588
1592
  return Object.keys(strapi.plugins).reduce((acc, current) => {
1589
1593
  const isDocumentationNeeded = this.isPluginDocumentationNeeded(current);
1590
1594
 
@@ -1601,9 +1605,9 @@ module.exports = {
1601
1605
  * @param {String} pluginName
1602
1606
  * @returns {Array}
1603
1607
  */
1604
- getPluginRoutesWithDescription: function(pluginName) {
1608
+ getPluginRoutesWithDescription: function (pluginName) {
1605
1609
  return _.get(strapi, ['plugins', pluginName, 'config', 'routes'], []).filter(
1606
- route => _.get(route, ['config', 'description']) !== undefined
1610
+ (route) => _.get(route, ['config', 'description']) !== undefined
1607
1611
  );
1608
1612
  },
1609
1613
 
@@ -1623,7 +1627,7 @@ module.exports = {
1623
1627
  * @param {String} plugin
1624
1628
  * @returns {Array}
1625
1629
  */
1626
- getModelForPlugin: function(string, pluginName) {
1630
+ getModelForPlugin: function (string, pluginName) {
1627
1631
  const [plugin, model] = this.getModelAndNameForPlugin(string, pluginName);
1628
1632
 
1629
1633
  return ['plugins', plugin, 'models', _.lowerCase(model)];
@@ -1634,7 +1638,7 @@ module.exports = {
1634
1638
  * @param {String} pluginName
1635
1639
  * @returns {Boolean}
1636
1640
  */
1637
- isPluginDocumentationNeeded: function(pluginName) {
1641
+ isPluginDocumentationNeeded: function (pluginName) {
1638
1642
  const { pluginsForWhichToGenerateDoc } = strapi.plugins.documentation.config['x-strapi-config'];
1639
1643
  if (
1640
1644
  Array.isArray(pluginsForWhichToGenerateDoc) &&
@@ -1664,7 +1668,7 @@ module.exports = {
1664
1668
  return _.merge(cleanedObj, srcObj);
1665
1669
  },
1666
1670
 
1667
- mergePaths: function(initObj, srcObj) {
1671
+ mergePaths: function (initObj, srcObj) {
1668
1672
  return Object.keys(initObj.paths).reduce((acc, current) => {
1669
1673
  if (_.has(_.get(srcObj, ['paths'], {}), current)) {
1670
1674
  const verbs = Object.keys(initObj.paths[current]).reduce((acc1, curr) => {
@@ -1695,7 +1699,7 @@ module.exports = {
1695
1699
  * @param {Object} srcObj
1696
1700
  * @returns {Object}
1697
1701
  */
1698
- mergeVerbObject: function(initObj, srcObj) {
1702
+ mergeVerbObject: function (initObj, srcObj) {
1699
1703
  return _.mergeWith(initObj, srcObj, (objValue, srcValue) => {
1700
1704
  if (_.isPlainObject(objValue)) {
1701
1705
  return Object.assign(objValue, srcValue);
@@ -1705,7 +1709,7 @@ module.exports = {
1705
1709
  });
1706
1710
  },
1707
1711
 
1708
- retrieveDocumentation: function(name, isPlugin = false) {
1712
+ retrieveDocumentation: function (name, isPlugin = false) {
1709
1713
  const documentationPath = isPlugin
1710
1714
  ? [strapi.config.appPath, 'extensions', name, 'documentation', this.getDocumentationVersion()]
1711
1715
  : [strapi.config.appPath, 'api', name, 'documentation', this.getDocumentationVersion()];
@@ -1713,7 +1717,7 @@ module.exports = {
1713
1717
  try {
1714
1718
  const documentationFiles = fs
1715
1719
  .readdirSync(path.resolve(documentationPath.join('/')))
1716
- .filter(el => el.includes('.json'));
1720
+ .filter((el) => el.includes('.json'));
1717
1721
 
1718
1722
  return documentationFiles.reduce((acc, current) => {
1719
1723
  try {
@@ -1737,7 +1741,10 @@ module.exports = {
1737
1741
  * @param {Boolean} isPlugin
1738
1742
  * @returns {Array}
1739
1743
  */
1740
- retrieveDocumentationFiles: function(isPlugin = false, version = this.getDocumentationVersion()) {
1744
+ retrieveDocumentationFiles: function (
1745
+ isPlugin = false,
1746
+ version = this.getDocumentationVersion()
1747
+ ) {
1741
1748
  const array = isPlugin ? this.getPluginsWithDocumentationNeeded() : this.getApis();
1742
1749
 
1743
1750
  return array.reduce((acc, current) => {
@@ -1748,9 +1755,9 @@ module.exports = {
1748
1755
  try {
1749
1756
  const documentationFiles = fs
1750
1757
  .readdirSync(path.resolve(documentationPath.join('/')))
1751
- .filter(el => el.includes('.json'));
1758
+ .filter((el) => el.includes('.json'));
1752
1759
 
1753
- documentationFiles.forEach(el => {
1760
+ documentationFiles.forEach((el) => {
1754
1761
  try {
1755
1762
  let documentation = JSON.parse(
1756
1763
  fs.readFileSync(path.resolve([...documentationPath, el].join('/')), 'utf8')
@@ -1822,10 +1829,10 @@ module.exports = {
1822
1829
  }, []);
1823
1830
  },
1824
1831
 
1825
- retrieveDocumentationVersions: function() {
1832
+ retrieveDocumentationVersions: function () {
1826
1833
  return fs
1827
1834
  .readdirSync(this.getFullDocumentationPath())
1828
- .map(version => {
1835
+ .map((version) => {
1829
1836
  try {
1830
1837
  const doc = JSON.parse(
1831
1838
  fs.readFileSync(
@@ -1839,10 +1846,10 @@ module.exports = {
1839
1846
  return null;
1840
1847
  }
1841
1848
  })
1842
- .filter(x => x);
1849
+ .filter((x) => x);
1843
1850
  },
1844
1851
 
1845
- retrieveFrontForm: async function() {
1852
+ retrieveFrontForm: async function () {
1846
1853
  const config = await strapi
1847
1854
  .store({
1848
1855
  environment: '',