Dredd未能解析apiblueprint响应体

时间:2017-09-18 13:36:36

标签: parsing response apiblueprint dredd

我的.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中的结构相匹配。

知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

简单地将身体缩进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             }