Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ function isSupportedArrayItemSchema(schema: json.JsonObject): boolean {
return true;
}

if (isJsonObject(schema.items)) {
return isSupportedArrayItemSchema(schema.items);
}

if (json.isJsonArray(schema.items)) {
return schema.items.some((item) => isJsonObject(item) && isSupportedArrayItemSchema(item));
}
Expand Down Expand Up @@ -198,7 +202,7 @@ function getSupportedTypes(
case 'string':
return true;
case 'array':
return isJsonObject(current.items) && isSupportedArrayItemSchema(current.items);
return isSupportedArrayItemSchema(current);
case 'object':
return isStringMap(current);
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ describe('parseJsonSchemaToOptions', () => {
],
},
},
'oneOfAtRoot': {
'oneOf': [{ 'type': 'array', 'items': { 'type': 'string' } }, { 'type': 'boolean' }],
},
},
};
const registry = new schema.CoreSchemaRegistry();
Expand Down Expand Up @@ -199,6 +202,21 @@ describe('parseJsonSchemaToOptions', () => {
});
});

describe('type=array, oneOf at root', () => {
it('parses valid option value', async () => {
expect(
await parse([
'--oneOfAtRoot',
'first',
'--oneOfAtRoot',
'second',
'--oneOfAtRoot',
'third',
]),
).toEqual(jasmine.objectContaining({ 'oneOfAtRoot': ['first', 'second', 'third'] }));
});
});

describe('type=string, enum', () => {
it('parses valid option value', async () => {
expect(await parse(['--ssr', 'never'])).toEqual(
Expand Down