Reputation: 9044
I would be wanting a tool which can mock a RESTFul server and it should return the preset JSON data which I have mapped for a particular URL.
For ex: If I call http://ccccc.com/api/users , the mockup tool should return users ( which I have already preset ) in JSON format.
This might be useful when I create client side code with backbone or jquery to get back the models using an ajax call.
Any suggestions for this kind of mockup tool ?
Note: Creating a servlet which reads the incoming GET url and reads the preset JSON from a file and outputting it as JSON string is possible. But I am looking for a tool which will do this for me.
Upvotes: 2
Views: 1479
Reputation: 69
https://github.com/homerquan/kakuen
Mock up RESTful webservices simply by editing text files, e.g.,
GET_#book#123#authors.json ==> GET /book/123/authors POST_#book@id=123.json ==> POST /book?id=123
For json, a schema-based mockup is supported, e.g., in sample_server/mocks/GET__#search@q=js.json e.g.,
"@KAKUEN_ITEM(offset)": {
"@KAKUEN_TYPE": "natural",
"@KAKUEN_PARAM": {
"min": 1,
"max": 20
}
}
will be offset:12
Upvotes: 0
Reputation: 35920
Sinon.js is what you're looking for. In particular the sinon.fakeServer API.
Upvotes: 5