forked from loafle/openapi-generator-original
fixed zapier objects array mapping (#16780)
This commit is contained in:
parent
f180aa0eec
commit
bbf9ccd0c0
@ -83,7 +83,7 @@ module.exports = {
|
||||
const {keyPrefix} = utils.buildKeyAndLabel(prefix)
|
||||
return {
|
||||
{{#vars}}
|
||||
'{{baseName}}': {{#isPrimitiveType}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/isPrimitiveType}}{{^isPrimitiveType}}{{^allowableValues}}{{^isArray}}utils.removeIfEmpty({{complexType}}.mapping(bundle, `${keyPrefix}{{baseName}}`)){{/isArray}}{{#isArray}}utils.removeKeyPrefixes(bundle.inputData?.[`${keyPrefix}{{baseName}}`], `${keyPrefix}{{baseName}}`){{/isArray}}{{/allowableValues}}{{#allowableValues}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/allowableValues}}{{/isPrimitiveType}},
|
||||
'{{baseName}}': {{#isPrimitiveType}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/isPrimitiveType}}{{^isPrimitiveType}}{{^allowableValues}}{{^isArray}}utils.removeIfEmpty({{complexType}}.mapping(bundle, `${keyPrefix}{{baseName}}`)){{/isArray}}{{#isArray}}{{^isEnumRef}}utils.childMapping(bundle.inputData?.[`${keyPrefix}{{baseName}}`], `${keyPrefix}{{baseName}}`, {{complexType}}){{/isEnumRef}}{{#isEnumRef}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/isEnumRef}}{{/isArray}}{{/allowableValues}}{{#allowableValues}}bundle.inputData?.[`${keyPrefix}{{baseName}}`]{{/allowableValues}}{{/isPrimitiveType}},
|
||||
{{/vars}}
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
const _ = require('lodash')
|
||||
|
||||
const replacePathParameters = (url) => url.replace(/{([^{}]+)}/g, (keyExpr, key) => `{{bundle.inputData.${key}}}`)
|
||||
const removeKeyPrefixes = (objectsArray, currentPath) => objectsArray == undefined || typeof objectsArray[0] != 'object' ? objectsArray : objectsArray.map((obj) => Object.keys(obj).reduce((res, key) =>_.set(res, key.replace(`${currentPath}.`, ''), obj[key]), {}))
|
||||
const childMapping = (objectsArray, prefix, model) => objectsArray.map(object => model.mapping({inputData: object}, prefix))
|
||||
const removeIfEmpty = (obj) => _.isEmpty(JSON.parse(JSON.stringify(obj))) ? undefined : obj
|
||||
const buildKeyAndLabel = (prefix, isInput = true, isArrayChild = false) => {
|
||||
const keyPrefix = !_.isEmpty(prefix) && (!isArrayChild || isInput) ? `${prefix}${isInput ? '.' : '__'}` : prefix
|
||||
@ -25,7 +25,7 @@ const searchMiddleware = (action) => {
|
||||
|
||||
module.exports = {
|
||||
replacePathParameters: replacePathParameters,
|
||||
removeKeyPrefixes: removeKeyPrefixes,
|
||||
childMapping: childMapping,
|
||||
removeIfEmpty: removeIfEmpty,
|
||||
buildKeyAndLabel: buildKeyAndLabel,
|
||||
hasSearchRequisites: hasSearchRequisites,
|
||||
|
@ -47,7 +47,7 @@ module.exports = {
|
||||
'category': utils.removeIfEmpty(Category.mapping(bundle, `${keyPrefix}category`)),
|
||||
'name': bundle.inputData?.[`${keyPrefix}name`],
|
||||
'photoUrls': bundle.inputData?.[`${keyPrefix}photoUrls`],
|
||||
'tags': utils.removeKeyPrefixes(bundle.inputData?.[`${keyPrefix}tags`], `${keyPrefix}tags`),
|
||||
'tags': utils.childMapping(bundle.inputData?.[`${keyPrefix}tags`], `${keyPrefix}tags`, Tag),
|
||||
'status': bundle.inputData?.[`${keyPrefix}status`],
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
const _ = require('lodash')
|
||||
|
||||
const replacePathParameters = (url) => url.replace(/{([^{}]+)}/g, (keyExpr, key) => `{{bundle.inputData.${key}}}`)
|
||||
const removeKeyPrefixes = (objectsArray, currentPath) => objectsArray == undefined || typeof objectsArray[0] != 'object' ? objectsArray : objectsArray.map((obj) => Object.keys(obj).reduce((res, key) =>_.set(res, key.replace(`${currentPath}.`, ''), obj[key]), {}))
|
||||
const childMapping = (objectsArray, prefix, model) => objectsArray.map(object => model.mapping({inputData: object}, prefix))
|
||||
const removeIfEmpty = (obj) => _.isEmpty(JSON.parse(JSON.stringify(obj))) ? undefined : obj
|
||||
const buildKeyAndLabel = (prefix, isInput = true, isArrayChild = false) => {
|
||||
const keyPrefix = !_.isEmpty(prefix) && (!isArrayChild || isInput) ? `${prefix}${isInput ? '.' : '__'}` : prefix
|
||||
@ -25,7 +25,7 @@ const searchMiddleware = (action) => {
|
||||
|
||||
module.exports = {
|
||||
replacePathParameters: replacePathParameters,
|
||||
removeKeyPrefixes: removeKeyPrefixes,
|
||||
childMapping: childMapping,
|
||||
removeIfEmpty: removeIfEmpty,
|
||||
buildKeyAndLabel: buildKeyAndLabel,
|
||||
hasSearchRequisites: hasSearchRequisites,
|
||||
|
Loading…
x
Reference in New Issue
Block a user