0

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

知道我做错了什么吗?

4

1 回答 1

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             }
于 2017-09-18T14:29:49.170 回答