import 'dart:io'; import 'package:koi_swagger_parser/koi_swagger_parser.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; void main() { final fixtures = [ 'openapi_30_compat.yaml', 'e2e_openapi.json', 'dba_openapi.json', ]; for (final fixtureName in fixtures) { test('fixture corpus parses and renders $fixtureName', () async { final tempDirectory = await Directory.systemTemp.createTemp( 'koi_swagger_parser_corpus_', ); addTearDown(() => tempDirectory.delete(recursive: true)); final source = p.join( Directory.current.path, 'test', 'fixtures', fixtureName, ); final output = p.join(tempDirectory.path, 'lib', 'src'); final config = File( p.join(tempDirectory.path, 'koi_swagger_parser.yaml'), ); await config.writeAsString(''' input: swagger_urls: - url: $source output: base_dir: $output api_dir: ${p.join(output, 'api')} models_dir: ${p.join(output, 'models')} manifest_path: ${p.join(tempDirectory.path, '.generated', 'manifest.json')} generation: api: response_wrapper: mode: passthrough models: class_prefix: Koi formatting: run_dart_format: false '''); final result = await const KoiSwaggerParser().generate( configPath: config.path, dryRun: true, ); expect(result.operationsCount, greaterThan(0)); expect(result.modelsCount, greaterThan(0)); expect(result.generatedFiles, isNotEmpty); expect( result.diagnostics.where( (diagnostic) => diagnostic.severity == DiagnosticSeverity.error, ), isEmpty, ); }); } }