From 7ba9a055cdeb2b0713857747a5b722dab65d3678 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Wed, 20 Jul 2022 02:57:29 -0400 Subject: [PATCH] fix(api): Validate static data value for resource workflow (#3736) --- packages/cli/src/PublicApi/index.ts | 11 +++++++++++ .../v1/handlers/workflows/spec/schemas/workflow.yml | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/PublicApi/index.ts b/packages/cli/src/PublicApi/index.ts index 19681e798d..b416b86510 100644 --- a/packages/cli/src/PublicApi/index.ts +++ b/packages/cli/src/PublicApi/index.ts @@ -64,6 +64,17 @@ function createApiRouter( validate: (identifier: string) => validator.isUUID(identifier) || validator.isEmail(identifier), }, + { + name: 'jsonString', + validate: (data: string) => { + try { + JSON.parse(data); + return true; + } catch (e) { + return false; + } + }, + }, ], validateSecurity: { handlers: { diff --git a/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml b/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml index c15ce8120b..bac8120af8 100644 --- a/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml +++ b/packages/cli/src/PublicApi/v1/handlers/workflows/spec/schemas/workflow.yml @@ -33,9 +33,14 @@ properties: settings: $ref: './workflowSettings.yml' staticData: - type: string + example: { lastId: 1 } nullable: true - example: '{ iterationId: 2 }' + anyOf: + - type: string + format: 'jsonString' + nullable: true + - type: object + nullable: true tags: type: array items: