我正在使用https://www.npmjs.com/package/swagger,我正在尝试创建配置.我有swagger.js的这一部分
"dummy\/{id}\/related_dummies": {
"get": {
"tags": [
"RelatedDummy"
],
"operationId": "get_by_parentRelatedDummyCollection",
"produces": [
"application\/ld+json",
"application\/hal+json",
"application\/xml",
"text\/xml",
"application\/json",
"text\/html"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "integer"
}
],
"summary": "Retrieves the collection of RelatedDummy resources.",
"responses": {
"200": {
"description": "RelatedDummy collection response",
"schema": {
"type": "array",
"items": {
"$ref": "#\/definitions\/RelatedDummy"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行swagger验证swagger.js时,我不断收到此错误:
Project Errors
--------------
#/paths: Additional properties not allowed: dummy/{id}/related_dummies
Results: 1 errors, 0 warnings
Run Code Online (Sandbox Code Playgroud)
可能是错误的原因是什么?谢谢
问题是路径dummy/{id}/related_dummies不是以斜杠开头的.
要被识别为有效的路径项对象,它需要/dummy/{id}/related_dummies.
使用示例中的转义语法,名称应为 "\/dummy\/{id}\/related_dummies"
Swagger-OpenAPI 2.0规范的相关部分位于Paths Object定义中.
| 归档时间: |
|
| 查看次数: |
6406 次 |
| 最近记录: |