如何使用Wiremock在同一个URL的一个json文件中实现多存根?

问题描述 投票:0回答:1

我正在尝试在带有多个存根的maps文件夹下创建一个mapping.json,如下所示。但我面临以下错误

Wiremock:v2.5.1(独立)

Mapping.json文件外观,

[
{
  "scenarioName": "Savings account Stub",
  "request": {
    "url": "/ws/*****",
    "method": "POST",
    "bodyPatterns" : [{
      "contains" : "AccountRequest"
    }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "******"
  }
},
{
  "scenarioName": "Current account Stub",
  "request": {
    "method": "POST",
    "url": "/ws/*****",
    "bodyPatterns": [
      {
        "contains": "AccountListRequest"
      }
    ]
  },
  "response": {
    "status": 200,
    "bodyFileName": "******"
  }
}]

错误:

Exception in thread "main" wiremock.com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.github.tomakehurst.wiremock.stubbing.StubMapping out of START_ARRAY token

是否有可能在单个映射文件中为同一URL创建多个存根?谁能告诉我确切的问题是什么?

java wiremock wiremock-standalone
1个回答
0
投票

[Looking at the stubbing documentation,我想您希望您的mappings.json看起来像...

{ 
    "mappings": [
        {
        "request": {},
        "request": {}
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.