Skip to content
Merged
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 @@ -301,8 +301,17 @@ export default defineComponent({
// TODO: create issue against jsonforms to add propertyNames into the JsonSchema interface
// propertyNames exist in draft-6 but not defined in the JsonSchema
if (typeof (control.value.schema as any).propertyNames === 'object') {
let propertyNames = (control.value.schema as any).propertyNames;
if (typeof propertyNames.$ref === 'string') {
propertyNames =
Resolve.schema(
control.value.rootSchema,
propertyNames.$ref,
control.value.rootSchema,
) ?? propertyNames;
}
result = {
...(control.value.schema as any).propertyNames,
...propertyNames,
...result,
};
} else if (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { clearAllIds } from '@jsonforms/core';
import { extendedVuetifyRenderers } from '../../../src';
import { mountJsonForms } from '../util';

// Test use of `$ref` in additional-properties `propertyNames`
describe('AdditionalProperties nested $ref propertyNames', () => {
const schema = {
type: 'object' as const,
$defs: {
attrName: {
type: 'string' as const,
pattern: '^[A-Za-z_][A-Za-z0-9_]*$',
},
},
properties: {
secretFiles: {
type: 'object' as const,
additionalProperties: { type: 'string' as const },
propertyNames: { $ref: '#/$defs/attrName' },
},
},
};
const uischema = { type: 'Control' as const, scope: '#' };

beforeEach(() => {
clearAllIds();
});

it('mounts a map whose key type is a `$ref` into the root `$defs`', () => {
expect(() =>
mountJsonForms({ secretFiles: {} }, schema, extendedVuetifyRenderers, uischema),
).not.toThrow();
});
});
Loading