问题描述
我正在使用wiremock(Docker)docker.io/rodolpheche/wiremock:2.27.2-alpine
。我通过Docker Compose进行了设置,并且一切正常。
我正在尝试建立一个存根/映射,以根据相应的JSON模式检查JSON输入。基本上,这是存根/映射:
{
"name": "Create Character Stub","request": {
"headers": {
"accept": {
"caseInsensitive": true,"equalTo": "application/json"
},"content-type": {
"caseInsensitive": true,"equalTo": "application/json"
}
},"method": "POST","url": "/api/characters","body": {
// [start] I made this up,but that's what I'm trying to achieve
"type": "JSON_SCHEMA","location": ""schemas/create-character.json""
// [end]
}
},"response": {
"headers": {
"location": "{{ request.path }}/{{ randomValue type='UUID' }}"
},"status": 201,"transformers": ["response-template"]
}
}
...这是JSON模式(摘录):
{
"$schema": "http://json-schema.org/draft/2019-09/schema#","type": "object","description": "Character entity","properties": {
"first_name": {
"type": "string","description": ""
},"last_name": {
"type": "string","age": {
"type": "number","description": ""
}
},"additionalProperties": false,"required": ["first_name","last_name","age"]
}
有没有办法用wiremock做到这一点?我一直在寻找类似的东西。 found距离我最近一点是要使用JSON路径,但这与检查正确的架构并不完全相同-可能是冗长的JSON请求任务。
我搜索了wiremock的GitHub存储库中的问题,但只能看到this one(已关闭)。不过,我仍然没有一种方法可以完全按照自己的意愿进行。我只输入了一个JSON模式。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)