[TOC]
## 接口说明
> 新增一个 stub mapping 。
## 接口定义
请求入参,参见 Request JSON Schema 。
~~~[api]
post:/mappings
<<<
request(success)
**Request Body**
{
"name": "wiremock create a stub example",
"priority": 5,
"persistent": true,
"request": {
"method": "POST",
"urlPath": "/thing/100",
"headers": {
"Accept": {
"contains": "json"
}
},
"cookies": {
"X-Auth-Token": {
"equalTo": "123usidsldie98le"
}
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"delayDistribution": {
"lower": "100",
"upper": "300",
"type": "uniform"
},
"body": "{\n \"test\":\"liyun\",\n \"node\":{\n \"subnode\":\"subnodevalue\"\n }\n}",
"transformers": ["response-template"]
},
"scenarioName": "订单",
"requiredScenarioState": "Started",
"newScenarioState": "second"
}
<<<
response(success)
**Response Body**
{
"id" : "03ba2797-e4f3-46f8-a680-fee52ac7ce1e",
"name" : "wiremock create a stub example",
"request" : {
"urlPath" : "/thing/100",
"method" : "POST",
"headers" : {
"Accept" : {
"contains" : "json"
}
},
"cookies" : {
"X-Auth-Token" : {
"equalTo" : "123usidsldie98le"
}
}
},
"response" : {
"status" : 200,
"body" : "{\n \"test\":\"liyun\",\n \"node\":{\n \"subnode\":\"subnodevalue\"\n }\n}",
"headers" : {
"Content-Type" : "application/json"
},
"delayDistribution" : {
"type" : "uniform",
"lower" : 100,
"upper" : 300
},
"transformers" : [ "response-template" ]
},
"uuid" : "03ba2797-e4f3-46f8-a680-fee52ac7ce1e",
"persistent" : true,
"priority" : 5,
"scenarioName" : "订单",
"requiredScenarioState" : "Started",
"newScenarioState" : "second"
}
~~~
## [JSON Schema](https://jsonschema.net/)
### Request JSON Schema
同 [Stub Mapping](StubMapping.md) 。
### Response JSON Schema
同 [Stub Mapping](StubMapping.md) 。
- Admin API
- Stub Mapping API
- /mappings
- GET
- POST
- DELETE
- /mappings/reset
- /mappings/{stubMappingId}
- GET
- PUT
- DELETE
- /mocklab/mappings/normal
- /mocklab/mappings/notify
- Record API
- /recordings/start
- /recordings/stop
- /recordings/status
- /recordings/snapshot
- Settings API
- /mocklab/settings
- JSON Schema
- Stub Mapping
- Stub Mappings
- Stub Mappings meta
- 官方 API 文档
- 文章模板
- API 文章模板