add comment for function

This commit is contained in:
Mark Kaylor 2022-04-06 17:10:27 +02:00
parent 492a3c63b9
commit c988475bf3
3 changed files with 8 additions and 1 deletions

View File

@ -171,6 +171,9 @@ const getAllPathsForContentType = apiInfo => {
* @returns {object} * @returns {object}
*/ */
const buildApiEndpointPath = api => { 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); return loopContentTypeNames(api, getAllPathsForContentType);
}; };

View File

@ -108,6 +108,9 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
}; };
const buildComponentSchema = api => { 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); return loopContentTypeNames(api, getAllSchemasForContentType);
}; };

View File

@ -7,7 +7,7 @@ const _ = require('lodash');
* @param {object} api - Api information to pass to the callback * @param {object} api - Api information to pass to the callback
* @param {function} callback - Logic to execute for the given api * @param {function} callback - Logic to execute for the given api
* *
* @returns {function} * @returns {object}
*/ */
const loopContentTypeNames = (api, callback) => { const loopContentTypeNames = (api, callback) => {
let result = {}; let result = {};
@ -27,6 +27,7 @@ const loopContentTypeNames = (api, callback) => {
// Uppercase the first letter of the api name // Uppercase the first letter of the api name
const apiName = _.upperFirst(api.name); const apiName = _.upperFirst(api.name);
// Create a unique name if the api name and contentType name don't match // Create a unique name if the api name and contentType name don't match
const uniqueName = const uniqueName =
api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`; api.name === contentTypeName ? apiName : `${apiName} - ${_.upperFirst(contentTypeName)}`;