From d5c92f3bd4d8e731ec0aee009e7e7649ca591bbc Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 29 Jan 2017 17:40:14 +0100 Subject: [PATCH] Updated Admin API Reference (markdown) --- Admin-API-Reference.md | 92 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/Admin-API-Reference.md b/Admin-API-Reference.md index 3938e7b..5a53d25 100644 --- a/Admin-API-Reference.md +++ b/Admin-API-Reference.md @@ -13,8 +13,7 @@ The mappings defined in the mock service. * `POST /__admin/mappings` --> Create a new stub mapping * `DELETE /__admin/mappings` --> TODO * `GET /__admin/mappings/{guid}` --> Get a single stub mapping -* `PUT /__admin/mappings/{guid}` --> TODO -* `POST /__admin/mappings/{guid}` --> TODO +* `PUT /__admin/mappings/{guid}` --> Update a stub mapping * `DELETE /__admin/mappings/{guid}` --> TODO ### /__admin/requests @@ -119,16 +118,95 @@ Example response: ] ``` +## `POST /__admin/mappings` +Create a new stub mapping +Example request: +```js +{ + "Guid": "dae02a0d-8a33-46ed-aab0-afbecc8643e3", + "Request": { + "Url": "/testabc", + "Methods": [ + "put" + ], + "Headers": [ + { + "Name": "Content-Type", + "Matchers": [ + { + "Name": "WildcardMatcher", + "Pattern": "application/*" + } + ] + } + ], + "Cookies": [], + "Params": [ + { + "Name": "start", + "Values": [ "1000", "1001" ] + } + ], + "Body": { + "Matcher": { + "Name": "JsonPathMatcher", + "Pattern": "$.things[?(@.name == 'RequiredThing')]" + } + } + }, + "Response": { + "UseTransformer": true, + "StatusCode": 205, + "BodyAsJson": { "result": "test - {{request.path}}" }, + "Headers": { + "Content-Type": "application/json", "a" : "b" + } + } + } +``` +## `DELETE /__admin/mappings` +TODO +### `GET /__admin/mappings/{guid}` +Get a single stub mapping +### `PUT /__admin/mappings/{guid}` +Update a single stub mapping + +Example request +```js +{ + "Request": { + "Path": { + "Matchers": [] + }, + "Methods": [ + "get" + ], + "Headers": [], + "Cookies": [], + "Params": [ + { + "Name": "start", + "Values": [] + } + ], + "Body": {} + }, + "Response": { + "StatusCode": 205, + "Body": "{\"msg\": \"Hello world?\"", + "UseTransformer": true, + "Headers": { + "Transformed-Postman-Token": "token is {{request.headers.Postman-Token}}", + "Content-Type": "application/json" + } + } +} +``` -### `GET /__admin/mappings` --> Gets all defined mappings -### `POST /__admin/mappings` --> Create a new stub mapping -### `DELETE /__admin/mappings` --> TODO -### `GET /__admin/mappings/{guid}` --> Get a single stub mapping -### `PUT /__admin/mappings/{guid}` --> TODO ### `POST /__admin/mappings/{guid}` --> TODO ### `DELETE /__admin/mappings/{guid}` --> TODO