Dredd failing to parse apiblueprint response body

83 views Asked by At

My .apib document has the following response defined:

 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         }

However it fails when running dredd with the error:

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

However this matches the structure in the apiblueprint examples.

Any idea of what I'm doing wrong?

1

There are 1 answers

1
category On BEST ANSWER

Simply indented the body by 12 spaces:

 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             }