buildObjectSchema static method
Builds a Schema.object() expression from a list of parameter maps. Each param map has: 'name', 'type', 'schemaMap', 'isOptional', 'parameterMetadata'
Implementation
static String buildObjectSchema(List<Map<String, dynamic>> params) {
if (params.isEmpty) {
return 'Schema.object()';
}
final properties = params
.map((p) {
final name = p['name'] as String;
final schemaMap = p['schemaMap'] as Map<String, dynamic>?;
final metadata = p['parameterMetadata'] as Map<String, dynamic>?;
String schemaCode;
if (schemaMap != null) {
schemaCode = fromSchemaMap(schemaMap);
} else {
final type = p['type'] as String;
schemaCode = fromType(type);
}
// Apply metadata enhancements if present
if (metadata != null && metadata.isNotEmpty) {
schemaCode = _applyMetadataToSchema(schemaCode, metadata);
}
return "'$name': $schemaCode";
})
.join(',\n ');
final required = params
.where((p) => p['isOptional'] != true)
.map((p) => "'${p['name']}'")
.join(', ');
if (required.isEmpty) {
return 'Schema.object(\n properties: {\n $properties,\n },\n )';
}
return 'Schema.object(\n properties: {\n $properties,\n },\n required: [$required],\n )';
}