Skip to content

Commit 1bf2b57

Browse files
authored
fix(input_schema): disable isSecret for array properties (#483)
Solves: apify/apify-core#15613 The issue was with `arrayProperty` because it enables additional properties (`"additionalProperties": true`) so not defined properties were accepted including `isSecret`. This PR fixes `arrayProperty` ensuring that not defined properties are prohibited Adding also missing test that check this
1 parent 0c27c05 commit 1bf2b57

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

packages/input_schema/src/schema.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,7 @@
174174
"type": "object",
175175
"properties": {
176176
"type": { "enum": ["array"] },
177-
"editor": { "enum": ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "select", "hidden"] },
178-
"title": { "type": "string" },
179-
"description": { "type": "string" },
180-
"default": { "type": "array" },
181-
"prefill": { "type": "array" },
182-
"example": { "type": "array" },
183-
"nullable": { "type": "boolean" },
184-
"minItems": { "type": "integer" },
185-
"maxItems": { "type": "integer" },
186-
"uniqueItems": { "type": "boolean" },
187-
188-
"sectionCaption": { "type": "string" },
189-
"sectionDescription": { "type": "string" }
177+
"editor": { "enum": ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "select", "hidden"] }
190178
},
191179
"additionalProperties": true,
192180
"required": ["type", "title", "description", "editor"],
@@ -196,8 +184,22 @@
196184
}
197185
},
198186
"then": {
187+
"additionalProperties": false,
199188
"required": ["items"],
200189
"properties": {
190+
"type": { "enum": ["array"] },
191+
"editor": { "enum": ["select"] },
192+
"title": { "type": "string" },
193+
"description": { "type": "string" },
194+
"default": { "type": "array" },
195+
"prefill": { "type": "array" },
196+
"example": { "type": "array" },
197+
"nullable": { "type": "boolean" },
198+
"minItems": { "type": "integer" },
199+
"maxItems": { "type": "integer" },
200+
"uniqueItems": { "type": "boolean" },
201+
"sectionCaption": { "type": "string" },
202+
"sectionDescription": { "type": "string" },
201203
"items": {
202204
"type": "object",
203205
"additionalProperties": false,
@@ -218,7 +220,21 @@
218220
}
219221
},
220222
"else": {
223+
"additionalProperties": false,
221224
"properties": {
225+
"type": { "enum": ["array"] },
226+
"editor": { "enum": ["json", "requestListSources", "pseudoUrls", "globs", "keyValue", "stringList", "hidden"] },
227+
"title": { "type": "string" },
228+
"description": { "type": "string" },
229+
"default": { "type": "array" },
230+
"prefill": { "type": "array" },
231+
"example": { "type": "array" },
232+
"nullable": { "type": "boolean" },
233+
"minItems": { "type": "integer" },
234+
"maxItems": { "type": "integer" },
235+
"uniqueItems": { "type": "boolean" },
236+
"sectionCaption": { "type": "string" },
237+
"sectionDescription": { "type": "string" },
222238
"placeholderKey": { "type": "string" },
223239
"placeholderValue": { "type": "string" },
224240
"patternKey": { "type": "string" },

test/input_schema_definition.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ describe('input_schema.json', () => {
235235
});
236236
});
237237

238+
it('should allow only string type', () => {
239+
[{ type: 'string', editor: 'textfield' }].forEach((fields) => {
240+
expect(isSchemaValid(fields, true)).toBe(true);
241+
});
242+
[
243+
{ type: 'array', editor: 'stringList' },
244+
{ type: 'object', editor: 'json' },
245+
{ type: 'boolean' },
246+
{ type: 'integer' },
247+
].forEach((fields) => {
248+
expect(isSchemaValid(fields, true)).toBe(false);
249+
});
250+
});
251+
238252
it('should not allow some fields', () => {
239253
['minLength', 'maxLength'].forEach((intField) => {
240254
expect(isSchemaValid({ [intField]: 10 }, true)).toBe(false);

0 commit comments

Comments
 (0)