Reputation: 6010
I'm trying to mock an API with the combination of Api Blueprint and Drakov. However, for one particular endpoint, I don't know beforehand what the request payload will be. See the below code.
# Group Stuff
Description about stuff.
## Main Stuff Resource [stuff/{userId}/response/{responseId}]
+ Parameters
+ userId: specialUser (string, required) - ID of user
+ responseId: 0f9d78ee-005056ad6f10 (string, required) - ID for a particular response.
### Submit Survey Form [POST]
+ Attributes
+ attribute1 (array[object]) - Description for attribute 1
+ attribute2 (array[object]) - Description for attribute 1
+ Request (application/json)
{attribute1:[],attribute2[]}
+ Response 201 (text/plain; charset=utf8)
+ Headers
X-XSS-Protection: 0
Vary:Origin,Accept-Encoding
Access-Control-Allow-Credentials:true
+ Body
http://fakeurl.com
The above code works, but only when the request payload is exactly {attribute1:[],attribute2:[]}
. Even different whitespacing seems to tip it up, returning a 404
to the user and an error log from Drakov: [WARNING] JSON body could not be parsed. Using body as is.
I've tried removing the Attributes
section , removing the Request
section, removing the JSON example from the Request
section, removing everything except for the Response
section, as well as using the Schema
section. None of these seems to work, and I can't find any mention of this in the API Blueprint docs.
How can I always return that response to a POST request at that endpoint, given that I don't know what the format of the request payload or the contents of attribute1
and attribute2
will be?
Upvotes: 0
Views: 351
Reputation: 146
Hey @LanceLafontaine I am one of the Drakov maintainers.
Have you tried changing the request to be { "attribute1": [], "attribute2": [] }
(In the Blueprint API spec file)
Feel free to post an issue as well on the Drakov repo http://github.com/Aconex/drakov/issues
It's been a short while since I've looked at the parsing code, but I don't think the Attribute
section is being parsed by Drakov, it will try to match on the Request
section based on what your've posted.
Upvotes: 1