Dredd 无法解析 apiblueprint 响应正文

Dredd failing to parse apiblueprint response body

我的 .apib 文档定义了以下响应:

 21 + Response 200 (application/json)
 22 
 23     + Body
 24 
 25         {
 26             "Datetime: "2017-04-23T18:25:43.700Z",
 27             "UserId": "1",
 28             "Goal": "25",
 29             "MaxReps": "8",
 30             "Workout":
 31                 [
 32                     {
 33                         "SequenceNo": "1",
 34                         "Action": "Pullups",
 35                         "Units": "3"
 36                     },
 37                     {
 38                         "SequenceNo": "2",
 39                         "Action": "Rest",
 40                         "Units": "60"
 41                     },
 42                     {
 43                         "SequenceNo": "3",
 44                         "Action": "Pullups",
 45                         "Units": "5"
 46                     },
 47                     {
 48                         "SequenceNo": "4",
 49                         "Action": "Rest",
 50                         "Units": "60"
 51                     },
 52                     {
 53                         "SequenceNo": "5",
 54                         "Action": "Pullups",
 55                         "Units": "4"
 56                     }
 57                 ]
 58         }

但是当 运行 dredd 时失败并出现错误:

warn: Parser warning in file '/root/pullapi/api-description.apib': (warning code 10) message-body asset is expected to be a pre-formatted cod
e block, every of its line indented by exactly 12 spaces or 3 tabs on lines 25-58

然而,这与 apiblueprint examples 中的结构匹配。

知道我做错了什么吗?

简单地将正文缩进 12 个空格:

 21 + Response 200 (application/json)
 22 
 23     + Body
 24 
 25             {
 26               "Datetime: "2017-04-23T18:25:43.700Z",
 27               "UserId": "1",
 28               "Goal": "25",
 29               "MaxReps": "8",
 30               "Workout":
 31                 [
 32                   {
 33                     "SequenceNo": "1",
 34                     "Action": "Pullups",
 35                     "Units": "3"
 36                   },
 37                   {
 38                     "SequenceNo": "2",
 39                     "Action": "Rest",
 40                     "Units": "60"
 41                   },
 42                   {
 43                     "SequenceNo": "3",
 44                     "Action": "Pullups",
 45                     "Units": "5"
 46                   },
 47                   {
 48                     "SequenceNo": "4",
 49                     "Action": "Rest",
 50                     "Units": "60"
 51                   },
 52                   {
 53                     "SequenceNo": "5",
 54                     "Action": "Pullups",
 55                     "Units": "4"
 56                   }
 57                 ]
 58             }