ciyidogan commited on
Commit
de6b186
·
verified ·
1 Parent(s): 8f0659d

Update flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts

Browse files
flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.ts CHANGED
@@ -311,24 +311,31 @@ export default class ApiEditDialogComponent implements OnInit {
311
 
312
  replaceVariablesForValidation(jsonStr: string): string {
313
  let processed = jsonStr;
314
-
315
- // Numeric değişkenler için
316
- const numericVars = ['passenger_count', 'count', 'timeout_seconds', 'retry_count'];
317
- numericVars.forEach(varName => {
318
- const regex = new RegExp(`{{\\s*variables\\.${varName}\\s*}}`, 'g');
319
- processed = processed.replace(regex, '1');
320
- });
321
-
322
- // Boolean değişkenler için
323
- const booleanVars = ['enabled', 'published'];
324
- booleanVars.forEach(varName => {
325
- const regex = new RegExp(`{{\\s*variables\\.${varName}\\s*}}`, 'g');
326
- processed = processed.replace(regex, 'true');
 
 
 
 
 
 
 
 
 
 
327
  });
328
-
329
- // Diğer tüm değişkenler için string değer
330
- processed = processed.replace(/\{\{[^}]+\}\}/g, '"placeholder"');
331
-
332
  return processed;
333
  }
334
 
 
311
 
312
  replaceVariablesForValidation(jsonStr: string): string {
313
  let processed = jsonStr;
314
+
315
+ // Tüm {{...}} template değişkenlerini uygun placeholder ile değiştir
316
+ processed = processed.replace(/\{\{([^}]+)\}\}/g, (match, variablePath) => {
317
+ // Değişken tipini tahmin et
318
+ if (variablePath.includes('variables.')) {
319
+ const varName = variablePath.split('.').pop()?.toLowerCase() || '';
320
+
321
+ // Bilinen sayısal değişkenler
322
+ const numericVars = ['count', 'passenger_count', 'timeout_seconds', 'retry_count', 'amount', 'price', 'quantity', 'age', 'id'];
323
+ const booleanVars = ['enabled', 'published', 'is_active', 'confirmed', 'canceled', 'deleted', 'required'];
324
+
325
+ if (numericVars.some(v => varName.includes(v))) {
326
+ return '1';
327
+ } else if (booleanVars.some(v => varName.includes(v))) {
328
+ return 'true';
329
+ } else {
330
+ // String olarak ele al
331
+ return '"placeholder"';
332
+ }
333
+ }
334
+
335
+ // Auth token'lar ve config değerleri her zaman string
336
+ return '"placeholder"';
337
  });
338
+
 
 
 
339
  return processed;
340
  }
341