Skip to content

Commit 357dcd2

Browse files
committed
Fix array type inferencing
1 parent 1083436 commit 357dcd2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/actors.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,17 @@ export function truncateActorReadme(readme: string, limit = ACTOR_README_MAX_LEN
108108
*/
109109
export function inferArrayItemType(property: SchemaProperties): string | null {
110110
return property.items?.type
111-
|| (property.prefill && typeof property.prefill[0])
112-
|| (property.default && typeof property.default[0])
111+
|| (property.prefill?.length > 0 && typeof property.prefill[0])
112+
|| (property.default?.length > 0 && typeof property.default[0])
113113
|| (property.editor && getEditorItemType(property.editor))
114114
|| null;
115115

116116
function getEditorItemType(editor: string): string | null {
117117
const editorTypeMap: Record<string, string> = {
118118
requestListSources: 'object',
119119
stringList: 'string',
120+
json: 'object',
121+
globs: 'object',
120122
};
121123
return editorTypeMap[editor] || null;
122124
}
@@ -134,6 +136,7 @@ export function addEnumsToDescriptionsWithExamples(properties: { [key: string]:
134136
const value = property.prefill ?? property.default;
135137
if (value && !(Array.isArray(value) && value.length === 0)) {
136138
property.examples = Array.isArray(value) ? value : [value];
139+
property.description = `${property.description}\nExample values: ${JSON.stringify(value)}`;
137140
}
138141
}
139142
return properties;

0 commit comments

Comments
 (0)