我正在尝试使用 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)