From c988475bf30fd23f729b1f6797e9e79a3ae92ade Mon Sep 17 00:00:00 2001 From: Mark Kaylor Date: Wed, 6 Apr 2022 17:10:27 +0200 Subject: [PATCH] add comment for function --- .../server/services/helpers/build-api-endpoint-path.js | 3 +++ .../server/services/helpers/build-component-schema.js | 3 +++ .../server/services/helpers/utils/loop-content-type-names.js | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/plugins/documentation/server/services/helpers/build-api-endpoint-path.js b/packages/plugins/documentation/server/services/helpers/build-api-endpoint-path.js index 5995ceb41a..e3c5cf359e 100644 --- a/packages/plugins/documentation/server/services/helpers/build-api-endpoint-path.js +++ b/packages/plugins/documentation/server/services/helpers/build-api-endpoint-path.js @@ -171,6 +171,9 @@ const getAllPathsForContentType = apiInfo => { * @returns {object} */ const buildApiEndpointPath = api => { + // A reusable loop for building paths and component schemas + // Uses the api param to build a new set of params for each content type + // Passes these new params to the function provided return loopContentTypeNames(api, getAllPathsForContentType); }; diff --git a/packages/plugins/documentation/server/services/helpers/build-component-schema.js b/packages/plugins/documentation/server/services/helpers/build-component-schema.js index 4a3385b4be..5ecc5456ec 100644 --- a/packages/plugins/documentation/server/services/helpers/build-component-schema.js +++ b/packages/plugins/documentation/server/services/helpers/build-component-schema.js @@ -108,6 +108,9 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => { }; const buildComponentSchema = api => { + // A reusable loop for building paths and component schemas + // Uses the api param to build a new set of params for each content type + // Passes these new params to the function provided return loopContentTypeNames(api, getAllSchemasForContentType); }; diff --git a/packages/plugins/documentation/server/services/helpers/utils/loop-content-type-names.js b/packages/plugins/documentation/server/services/helpers/utils/loop-content-type-names.js index 7973875abd..7b63b7e2ec 100644 --- a/packages/plugins/documentation/server/services/helpers/utils/loop-content-type-names.js +++ b/packages/plugins/documentation/server/services/helpers/utils/loop-content-type-names.js @@ -7,7 +7,7 @@ const _ = require('lodash'); * @param {object} api - Api information to pass to the callback * @param {function} callback - Logic to execute for the given api * - * @returns {function} + * @returns {object} */ const loopContentTypeNames = (api, callback) => { let result = {}; @@ -27,6 +27,7 @@ const loopContentTypeNames = (api, callback) => { // Uppercase the first letter of the api name const apiName = _.upperFirst(api.name); + // Create a unique name if the api name and contentType name don't match const uniqueName = api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`;