Skip to content

Commit 6f7926a

Browse files
committed
Minor fix on schema adapter for root objects without properties
1 parent 956da96 commit 6f7926a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

jschema/__tests__/properties/object.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,19 @@ describe('Object properties', () => {
268268
expect(screen.queryByText('PropertyTitle')).toBeNull();
269269
expect(screen.queryByText('k1')).not.toBeNull();
270270
});
271+
272+
it('Display root schema having only additionalProperties', async function () {
273+
const { component } = renderSchema(
274+
{
275+
type: 'object',
276+
additionalProperties: {
277+
type: 'string'
278+
}
279+
},
280+
{ k1: 'foo', k2: 'bar' }
281+
);
282+
expect(component.getArguments()).deep.eq({ k1: 'foo', k2: 'bar' });
283+
expect(screen.queryByText('k1')).not.toBeNull();
284+
expect(screen.queryByText('k2')).not.toBeNull();
285+
});
271286
});

jschema/src/lib/components/jschema_adapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function adaptJsonSchema(originalJsonSchema, propertiesToIgnore = []) {
2121
*/
2222
export function stripIgnoredProperties(originalJsonSchema, propertiesToIgnore = []) {
2323
const adaptedSchema = deepCopy(originalJsonSchema);
24-
for (const k of Object.keys(adaptedSchema.properties)) {
24+
for (const k of Object.keys(adaptedSchema.properties || {})) {
2525
if (propertiesToIgnore.includes(k)) {
2626
delete adaptedSchema.properties[k];
2727
}

0 commit comments

Comments
 (0)