mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
wip handle localization endpoints
This commit is contained in:
parent
a4d386a00a
commit
f3b295f823
@ -7,7 +7,7 @@ const pascalCase = require('./utils/pascal-case');
|
||||
const queryParams = require('./utils/query-params');
|
||||
const loopContentTypeNames = require('./utils/loop-content-type-names');
|
||||
const getApiResponses = require('./utils/get-api-responses');
|
||||
const hasFindMethod = require('./utils/has-find-method');
|
||||
const { hasFindMethod } = require('./utils/routes');
|
||||
|
||||
/**
|
||||
* @description Parses a route with ':variable'
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
const cleanSchemaAttributes = require('./utils/clean-schema-attributes');
|
||||
const loopContentTypeNames = require('./utils/loop-content-type-names');
|
||||
const pascalCase = require('./utils/pascal-case');
|
||||
const hasFindMethod = require('./utils/has-find-method');
|
||||
const { hasFindMethod } = require('./utils/routes');
|
||||
|
||||
/**
|
||||
* @decription Get all open api schema objects for a given content type
|
||||
@ -67,9 +67,21 @@ const getAllSchemasForContentType = ({ routeInfo, attributes, uniqueName }) => {
|
||||
};
|
||||
}
|
||||
|
||||
if (hasLocalizationPath) {
|
||||
schemas = {
|
||||
...schemas,
|
||||
[`${pascalCase(uniqueName)}LocalizationResponse`]: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
...cleanSchemaAttributes(attributes),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Check for routes that need to return a list
|
||||
const hasListOfEntities = routeInfo.routes.filter((route) => hasFindMethod(route.handler)).length;
|
||||
|
||||
if (hasListOfEntities) {
|
||||
// Build the list response schema
|
||||
schemas = {
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const hasFindMethod = (handler) => handler.split('.').pop() === 'find';
|
||||
|
||||
module.exports = hasFindMethod;
|
||||
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const hasFindMethod = (handler) => handler.split('.').pop() === 'find';
|
||||
|
||||
const isLocalizedPath = (routePath) => routePath.includes('localizations');
|
||||
|
||||
module.exports = {
|
||||
isLocalizedPath,
|
||||
hasFindMethod,
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user