小编Den*_*ets的帖子

yaml 解析时出错。预期为 <块结束>,但发现为 <标量>

我正在尝试使用 got-swag (npm 包)测试 swagger api

当我尝试使用 json 模式验证 json 响应时,当单独的 yaml 文件合并为一个 yaml 和 json 文件时,我收到一个 parseError 。起源是 -validate() 行。validate() 源自 got-swag 包,但它在其底层jsonschema.validate( data, schema ); 中失败;依赖性

 x-tests:
        - description: Should return array of ferries
          steps:
            - get('/api/get/link/ferries')
            - equal(res.statusCode, 200)
            - ok(res.json.length > 0)
            - validate(res.json,  $ref: '#/definitions/ferry')
Run Code Online (Sandbox Code Playgroud)

这是产生的错误:

           throw new exports.ParserError('while parsing a block mapping', this.marks.slice(-1)[0], "expected <block end>, but found " + token.id, token.start_mark);
        ^
while parsing a block mapping
  on line 29, column …
Run Code Online (Sandbox Code Playgroud)

javascript parsing json yaml swagger

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

javascript ×1

json ×1

parsing ×1

swagger ×1

yaml ×1