Skip to content

Commit 39031ef

Browse files
committed
fix(xml-generator): force required=true for primitive property types
1 parent 74fc30a commit 39031ef

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

packages/pluggable-widgets-mcp/src/generators/xml-generator.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ function generateProperty(prop: PropertyDefinition, indent: string): string {
4444
const attrs: string[] = [`key="${escapeXml(prop.key)}"`, `type="${prop.type}"`];
4545

4646
// Add optional attributes
47-
if (prop.required !== undefined) {
48-
attrs.push(`required="${prop.required}"`);
47+
// Primitive types (integer, boolean, decimal) have no null representation in Mendix —
48+
// Studio Pro rejects required="false" on them. Force required="true" for these types.
49+
const PRIMITIVE_TYPES = ["integer", "boolean", "decimal"];
50+
const effectiveRequired = PRIMITIVE_TYPES.includes(prop.type) ? true : prop.required;
51+
if (effectiveRequired !== undefined) {
52+
attrs.push(`required="${effectiveRequired}"`);
4953
}
5054
if (prop.defaultValue !== undefined) {
5155
attrs.push(`defaultValue="${escapeXml(String(prop.defaultValue))}"`);
@@ -113,7 +117,7 @@ export function generateWidgetXml(widget: WidgetDefinition): GeneratorResult {
113117
// Derive defaults
114118
const organization = widget.organization ?? "mendix";
115119
const widgetNameLower = widget.name.toLowerCase();
116-
const widgetId = widget.id ?? `com.${organization}.widget.custom.${widgetNameLower}.${widget.name}`;
120+
const widgetId = widget.id ?? `${organization}.${widgetNameLower}.${widget.name}`;
117121
const studioCategory = widget.studioCategory ?? "Display";
118122
const needsEntityContext = widget.needsEntityContext ?? false;
119123
const offlineCapable = widget.offlineCapable ?? true;

0 commit comments

Comments
 (0)