From f2f2df9a731491a55bdf530244f21e706af88866 Mon Sep 17 00:00:00 2001 From: Taras Date: Thu, 15 Sep 2022 09:23:07 -0400 Subject: [PATCH] Allow value to be non-string Signed-off-by: Taras --- .../modules/core/PlaceholderProcessor.test.ts | 1 - .../src/modules/core/PlaceholderProcessor.ts | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts index e0f7d81968..aa0d6c4766 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.test.ts @@ -396,7 +396,6 @@ describe('PlaceholderProcessor', () => { const processor = new PlaceholderProcessor({ resolvers: { merge: async ({ value }) => { - console.log({ value }); if (value instanceof Object) { return { merged: 'value', ...value }; } diff --git a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts index 39c9dc59ec..cf5679058d 100644 --- a/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts +++ b/plugins/catalog-backend/src/modules/core/PlaceholderProcessor.ts @@ -111,15 +111,19 @@ export class PlaceholderProcessor implements CatalogProcessor { const resolverValue = data[keys[0]]; const resolver = this.options.resolvers[resolverKey]; - if (!resolver || typeof resolverValue !== 'string') { - // If there was no such placeholder resolver or if the value was not a - // string, we err on the side of safety and assume that this is - // something that's best left alone. For example, if the input contains - // JSONSchema, there may be "$ref": "#/definitions/node" nodes in the - // document. + if (!resolver) { + // If there was no such placeholder resolver, we err on the side of safety + // and assume that this is something that's best left alone. For example, if + // the input contains JSONSchema, there may be "$ref": "#/definitions/node" + // nodes in the document. return [data, false]; } + // if (typeof resolverValue !== 'string') { + // treat it as an argument to resolver function + // TODO: make this recursive, but it should resolve from bottom up + // } + const read = async (url: string): Promise => { if (this.options.reader.readUrl) { const response = await this.options.reader.readUrl(url);