SwaggerParser.fromFile constructor

SwaggerParser.fromFile(
  1. String path
)

Implementation

factory SwaggerParser.fromFile(String path) {
  final content = File(path).readAsStringSync();

  if (path.endsWith('.yaml') || path.endsWith('.yml')) {
    final yamlMap = loadYaml(content);
    return SwaggerParser(_convertYamlToMap(yamlMap));
  }

  return SwaggerParser(jsonDecode(content));
}