From b2dccf80c79f0f221b5da8307d903f0b6fda5618 Mon Sep 17 00:00:00 2001 From: John Vu Date: Tue, 29 Aug 2023 15:04:00 -0700 Subject: [PATCH] Fix searchTasksForWorkspace custom_fields query param search for is_set, value, starts_with, ends_with, less_than, greater_than --- codegen/templates/api.mustache | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/codegen/templates/api.mustache b/codegen/templates/api.mustache index d7f4891c..d05eba00 100644 --- a/codegen/templates/api.mustache +++ b/codegen/templates/api.mustache @@ -61,14 +61,16 @@ export class {{classname}} { {{#vendorExtensions.x-codegen-isSearchTasksForWorkspace}} // Checks if the user provided custom field query parameters and adds it to the request for (const [key, value] of Object.entries(opts)) { - // If user provided in format: custom_fields..value - if (/^custom_fields\.(.*?)\.value$/.test(key)) { + var matchDotCase = /custom_fields\.(.*?)\..*/; + var matchSnakeCase = /custom_fields_(.*?)_.*/; + // If the provided custom fields query param key is in the following format: custom_fields.. (EX: custom_fields.123.is_set) + if (matchDotCase.test(key)) { queryParams[key] = value; - // If user provided in format: custom_fields__value - } else if (/^custom_fields_(.*?)_value$/.test(key)) { - let removed_prefix = key.replace('custom_fields_',''); - let custom_field_gid = removed_prefix.replace('_value',''); - queryParams[`custom_fields.${custom_field_gid}.value`] = value; + // If the provided custom fields query param key is in the following format: custom_fields__ (EX: custom_fields_123_is_set) + } else if (matchSnakeCase.test(key)) { + var custom_field_gid = matchSnakeCase.exec(key)[1]; + var custom_field_query_param_key = key.replace(`custom_fields_${custom_field_gid}_`, `custom_fields.${custom_field_gid}.`); + queryParams[custom_field_query_param_key] = value; } } {{/vendorExtensions.x-codegen-isSearchTasksForWorkspace}}