Schema Adapters
DynamicForm 3.0 provides concrete schema adapters on top of Adapter Foundation:
JsonSchema / OpenAPI / Metadata
-> Schema Adapter
-> ModuleFormConfig
-> compileFormConfig
-> FormConfig
-> processFormConfig
-> DynamicForm
Schema adapters convert input into structured ModuleFormConfig. Module expansion, group assembly, rule compilation, dependency inference, component registration, and runtime behavior remain owned by the compiler/runtime pipeline.
Schema required is mapped to field-level required semantics. Adapters do not generate Ant Design rules directly; the default Ant Design renderer merges required into final validation rules.
JsonSchemaAdapter
Supports top-level object schemas:
import { adaptModuleConfigs } from '@whynotsnow/dynamic-form';
const moduleConfigs = adaptModuleConfigs(
{
type: 'object',
required: ['name'],
properties: {
name: {
type: 'string',
title: 'Name',
metadata: {
module: 'TextInputModule',
options: { placeholder: 'Enter name' }
}
}
}
},
{ adapterType: 'json-schema' }
);
Fields must explicitly declare module type through metadata.module or x-dynamic-form.module. The adapter does not infer UI components from schema types such as string, number, or boolean.
Top-level x-dynamic-form.groups declares groups, while property-level x-dynamic-form.groupId declares membership. Schema data may configure initialVisible and group-owned show/hide rules, but cannot carry function effects. Inject functions through groupOverrides after adaptation and before compilation:
compileAdaptedFormConfig(schema, {
adapterType: 'json-schema',
moduleRegistry,
groupOverrides: {
companyInfo: {
effect: (changedValue, values) => ({ visible: values.enabled === true })
}
}
});
groupOverrides deduplicates merged dependents, appends override rules after schema rules, and replaces the adapter effect. Unknown group IDs fail immediately.
OpenApiAdapter
Supports OpenAPI components.schemas:
const moduleConfigs = adaptModuleConfigs(openApiDocument, {
adapterType: 'openapi',
context: {
metadata: { schemaName: 'User' }
}
});
If the OpenAPI document contains only one schema, schemaName may be omitted. If multiple schemas exist, schemaName is required.
MetadataAdapter
Supports project-specific metadata:
const moduleConfigs = adaptModuleConfigs(
{
fields: [
{
id: 'name',
type: 'TextInputModule',
options: { label: 'Name' },
overrides: { required: true }
}
]
},
{ adapterType: 'metadata' }
);
Each field must provide id and type, with optional options, rules, and overrides.
Boundaries
- No nested object schema expansion.
- No object array item schema expansion.
- No validation rule engine.
- Except for field-level
requiredsemantics,minLength,maxLength,pattern,minimum, andmaximumare not implicitly translated into Ant Design rules. Declare them explicitly through metadata or module rules so adapters do not silently choose messages, triggers, or component value semantics. - No async/API rules.
- No automatic UI or module type inference from schema types.
- Single-level groups and mixed fields are supported. Nested groups and multi-group field membership are not supported.