mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 13:45:25 +00:00
fix custom settings override
This commit is contained in:
parent
73b2d7f99b
commit
46f09b3a45
@ -20,6 +20,10 @@ module.exports = ({ strapi }) => {
|
|||||||
return path.join(strapi.dirs.extensions, 'documentation', 'documentation');
|
return path.join(strapi.dirs.extensions, 'documentation', 'documentation');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getCustomDocumentationPath() {
|
||||||
|
return path.join(strapi.dirs.extensions, 'documentation', 'config', 'settings.json');
|
||||||
|
},
|
||||||
|
|
||||||
getDocumentationVersions() {
|
getDocumentationVersions() {
|
||||||
return fs
|
return fs
|
||||||
.readdirSync(this.getFullDocumentationPath())
|
.readdirSync(this.getFullDocumentationPath())
|
||||||
@ -103,6 +107,16 @@ module.exports = ({ strapi }) => {
|
|||||||
return [...apisToDocument, ...pluginsToDocument];
|
return [...apisToDocument, ...pluginsToDocument];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getCustomSettings() {
|
||||||
|
const customConfigPath = this.getCustomDocumentationPath();
|
||||||
|
const pathExists = await fs.pathExists(customConfigPath);
|
||||||
|
if (pathExists) {
|
||||||
|
return fs.readJson(customConfigPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description - Creates the Swagger json files
|
* @description - Creates the Swagger json files
|
||||||
*/
|
*/
|
||||||
@ -133,20 +147,24 @@ module.exports = ({ strapi }) => {
|
|||||||
'full_documentation.json'
|
'full_documentation.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
const settings = _.cloneDeep(defaultConfig);
|
const defaultSettings = _.cloneDeep(defaultConfig);
|
||||||
|
|
||||||
const serverUrl = getAbsoluteServerUrl(strapi.config);
|
const serverUrl = getAbsoluteServerUrl(strapi.config);
|
||||||
const apiPath = strapi.config.get('api.rest.prefix');
|
const apiPath = strapi.config.get('api.rest.prefix');
|
||||||
|
|
||||||
_.set(settings, 'servers', [
|
_.set(defaultSettings, 'servers', [
|
||||||
{
|
{
|
||||||
url: `${serverUrl}${apiPath}`,
|
url: `${serverUrl}${apiPath}`,
|
||||||
description: 'Development server',
|
description: 'Development server',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
_.set(settings, ['info', 'x-generation-date'], new Date().toISOString());
|
_.set(defaultSettings, ['info', 'x-generation-date'], new Date().toISOString());
|
||||||
_.set(settings, ['info', 'version'], version);
|
_.set(defaultSettings, ['info', 'version'], version);
|
||||||
|
|
||||||
|
const customSettings = await this.getCustomSettings();
|
||||||
|
|
||||||
|
const settings = _.merge(defaultSettings, customSettings);
|
||||||
|
|
||||||
await fs.ensureFile(fullDocJsonPath);
|
await fs.ensureFile(fullDocJsonPath);
|
||||||
await fs.writeJson(fullDocJsonPath, { ...settings, paths }, { spaces: 2 });
|
await fs.writeJson(fullDocJsonPath, { ...settings, paths }, { spaces: 2 });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user