MCPcopy Create free account
hub / github.com/echoVic/blade-code / generateExampleValue

Method generateExampleValue

src/tools/format-converter.ts:231–255  ·  view source on GitHub ↗

* 根据参数模式生成示例值

(schema: any)

Source from the content-addressed store, hash-verified

229 * 根据参数模式生成示例值
230 */
231 private static generateExampleValue(schema: any): any {
232 if (schema.enum && schema.enum.length > 0) {
233 return schema.enum[0];
234 }
235
236 if (schema.default !== undefined) {
237 return schema.default;
238 }
239
240 switch (schema.type) {
241 case 'string':
242 return schema.description ? `示例${schema.description}` : '示例文本';
243 case 'number':
244 case 'integer':
245 return 42;
246 case 'boolean':
247 return true;
248 case 'array':
249 return [];
250 case 'object':
251 return {};
252 default:
253 return null;
254 }
255 }
256}

Callers 1

generateExampleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected