fix(api): Validate static data value for resource workflow (#3736)

This commit is contained in:
Ricardo Espinoza 2022-07-20 02:57:29 -04:00 committed by GitHub
parent 994c89a6c6
commit 7ba9a055cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -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: {

View file

@ -33,9 +33,14 @@ properties:
settings:
$ref: './workflowSettings.yml'
staticData:
type: string
example: { lastId: 1 }
nullable: true
anyOf:
- type: string
format: 'jsonString'
nullable: true
- type: object
nullable: true
example: '{ iterationId: 2 }'
tags:
type: array
items: