import fs from 'fs';
import yaml from 'js-yaml'; // Wait, let's see if js-yaml is available. If not, I'll use a different approach.

try {
    const file = fs.readFileSync('src/docs/swagger.yaml', 'utf8');
    // Simple check to see if it starts with openapi
    if (!file.startsWith('openapi:')) {
        console.error('File does not start with openapi:');
        process.exit(1);
    }
    console.log('YAML file starts correctly.');
    // Check if paths: exists
    if (!file.includes('paths:')) {
        console.error('File does not contain paths:');
        process.exit(1);
    }
    console.log('YAML file contains paths.');
    
    // Check for inconsistent indentation or weird characters
    const lines = file.split('\n');
    lines.forEach((line, index) => {
        if (line.includes('\t')) {
            console.error(`Line ${index + 1} contains a tab character. YAML does not allow tabs.`);
        }
    });
    
    console.log('Basic validation passed.');
} catch (e) {
    console.error('Validation failed:', e.message);
    process.exit(1);
}
