OpenApi.fromFile constructor
OpenApi.fromFile({
- required String source,
Create an OpenApi object from an existing JSON/YAML OpenAPI spec file
Implementation
factory OpenApi.fromFile({required String source}) {
final file = File(source);
final ext = p.extension(source).toLowerCase();
final format = OpenApiFormat.fromExtention(ext);
if (format == null) {
throw Exception('Unsupported file type: $ext');
}
return OpenApi.fromString(
source: file.readAsStringSync(),
format: format,
);
}