stringify method

String stringify(
  1. OpenAPIDocument<Map<String, dynamic>> document, {
  2. bool toYaml = false,
})

Converts an OpenAPIDocument to a JSON or YAML string.

Implementation

String stringify(OpenAPIDocument document, {bool toYaml = false}) {
  final map = document.toMap();
  if (toYaml) {
    return _writer.write(map);
  }
  return jsonEncode(
    map,
    toEncodable: (object) {
      if (object is OpenApiObject) {
        return object.toMap();
      }
      return object;
    },
  );
}