Dart 服务 API:如何通过 API 服务访问 /fixes?

Dart Services API: how to access the /fixes through the API service?

我正在看:

https://github.com/dart-lang/dart-services

我正在尝试调整给定的示例 (https://dartpad.dartlang.org/2a7fd9328e0a567ee79b) 以从“/api/dartservices/v1/fixes”而不是“/api/dartservices/v1/analyze”中提取信息。

抱歉,如果我在这里遗漏了一些明显的东西但将示例中的路径更改为:

"https://dart-services.appspot.com/api/dartservices/v1/fixes";

returns 一个错误。有谁知道我如何从“/api/dartservices/v1/fixes”而不是“/api/dartservices/v1/analyze”获取信息?或者有人有这个工作的例子吗?

谢谢。

使用 DartPad 示例发送的数据将 POST 请求发送到 https://dart-services.appspot.com/api/dartservices/v1/fixes 会产生错误消息 "Missing parameter: 'offset'".

查看服务 https://dart-services.appspot.com/api/discovery/v1/apis/dartservices/v1/rest 的发现文档,我看到 analyzefixes 操作都采用 SourceRequest:

"SourceRequest": {
   "id": "SourceRequest",
   "type": "object",
   "properties": {
    "source": {
     "type": "string",
     "description": "The Dart source.",
     "required": true
    },
    "offset": {
     "type": "integer",
     "description": "An optional offset into the source code.",
     "format": "int32"
    },
    "strongMode": {
     "type": "boolean",
     "description": "An optional signal whether the source should be processed in strong mode"
    }
   }

offset 未标记为必需,因此在 fixes 的实现中可能存在错误。

要使 DartPad 示例正常工作,请更改:

Map m = {'source': textArea.value};

Map m = {'source': textArea.value, 'offset': 0};