@strapi/plugin-documentation 4.0.7 → 4.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
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": "4.0.7",
28
- "@strapi/utils": "4.0.7",
27
+ "@strapi/helper-plugin": "4.0.8",
28
+ "@strapi/utils": "4.0.8",
29
29
  "bcryptjs": "2.4.3",
30
30
  "cheerio": "^1.0.0-rc.5",
31
31
  "fs-extra": "^9.1.0",
@@ -57,5 +57,5 @@
57
57
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
58
58
  "kind": "plugin"
59
59
  },
60
- "gitHead": "af0cba8c5b2ba7b371523e8f55413ef0fce98e1e"
60
+ "gitHead": "669bb2f0440d3b21a23c8d665fdba98bd3d8cc71"
61
61
  }
@@ -20,6 +20,10 @@ module.exports = ({ strapi }) => {
20
20
  return path.join(strapi.dirs.extensions, 'documentation', 'documentation');
21
21
  },
22
22
 
23
+ getCustomDocumentationPath() {
24
+ return path.join(strapi.dirs.extensions, 'documentation', 'config', 'settings.json');
25
+ },
26
+
23
27
  getDocumentationVersions() {
24
28
  return fs
25
29
  .readdirSync(this.getFullDocumentationPath())
@@ -103,6 +107,16 @@ module.exports = ({ strapi }) => {
103
107
  return [...apisToDocument, ...pluginsToDocument];
104
108
  },
105
109
 
110
+ async getCustomSettings() {
111
+ const customConfigPath = this.getCustomDocumentationPath();
112
+ const pathExists = await fs.pathExists(customConfigPath);
113
+ if (pathExists) {
114
+ return fs.readJson(customConfigPath);
115
+ }
116
+
117
+ return {};
118
+ },
119
+
106
120
  /**
107
121
  * @description - Creates the Swagger json files
108
122
  */
@@ -133,20 +147,24 @@ module.exports = ({ strapi }) => {
133
147
  'full_documentation.json'
134
148
  );
135
149
 
136
- const settings = _.cloneDeep(defaultConfig);
150
+ const defaultSettings = _.cloneDeep(defaultConfig);
137
151
 
138
152
  const serverUrl = getAbsoluteServerUrl(strapi.config);
139
153
  const apiPath = strapi.config.get('api.rest.prefix');
140
154
 
141
- _.set(settings, 'servers', [
155
+ _.set(defaultSettings, 'servers', [
142
156
  {
143
157
  url: `${serverUrl}${apiPath}`,
144
158
  description: 'Development server',
145
159
  },
146
160
  ]);
147
161
 
148
- _.set(settings, ['info', 'x-generation-date'], new Date().toISOString());
149
- _.set(settings, ['info', 'version'], version);
162
+ _.set(defaultSettings, ['info', 'x-generation-date'], new Date().toISOString());
163
+ _.set(defaultSettings, ['info', 'version'], version);
164
+
165
+ const customSettings = await this.getCustomSettings();
166
+
167
+ const settings = _.merge(defaultSettings, customSettings);
150
168
 
151
169
  await fs.ensureFile(fullDocJsonPath);
152
170
  await fs.writeJson(fullDocJsonPath, { ...settings, paths }, { spaces: 2 });