toMap method

Map<String, Object?> toMap({
  1. bool byAlias = false,
})

Implementation

Map<String, Object?> toMap({bool byAlias = false}) {
  final Map<String, Object?> result = <String, Object?>{
    'name': name,
    'description': description,
  };
  if (license != null) {
    result['license'] = license;
  }
  if (compatibility != null) {
    result['compatibility'] = compatibility;
  }
  if (allowedTools != null) {
    result[byAlias ? 'allowed-tools' : 'allowed_tools'] = allowedTools;
  }
  if (metadata.isNotEmpty) {
    result['metadata'] = Map<String, String>.from(metadata);
  }
  if (extraFields.isNotEmpty) {
    for (final MapEntry<String, Object?> entry in extraFields.entries) {
      result[entry.key] = entry.value;
    }
  }
  return result;
}