2

I am trying to put mappings json files in a subdirectories due to different requirements based on diff profiles.

I have it working with default /mappings directory and all mappings work ok in postman.

WiremockConfiguration options = options()
.usingFilesUnderDirectory(System.getPtoperty(“user.dir”) + “/app/src/main/resources”

src/main/resources

-mappings

—folderA

—folderB

—folderC

But once I try to place json files under sub directory of “mappings” folder, no mappings get picked up and /__admin/mappings endpoint show a total of 0.

WiremockConfiguration options = options()
.usingFilesUnderDirectory(System.getPtoperty(“user.dir”) + “/app/src/main/resources**/mappings/aws**”

(Note the path difference)

I am just wondering if mappings folder subdirectories are even supported in wire mock or have I configured something incorrectly? It seems something too simple to be not supported by wiremock!

Many thanks

Skyblue
  • 31
  • 6

2 Answers2

1

I have fixed it but for anyone facing similar problem u need to make “mappings” subdirectory of your custom folders.

src/main/resources

-my_wiremock_mappings

—folderA

—— mappings (should contain json files)

—folderB

—— mappings

—folderC

—— mappings

WiremockConfiguration options = options()
.usingFilesUnderDirectory(System.getPtoperty(“user.dir”) + “/app/src/main/resources/my_wiremock_mappings/folderA”

There is no need to add “mappings” to the path.

Skyblue
  • 31
  • 6
0

If you use a classpath ant pattern, you have to add *.json at the end.

@AutoConfigureWireMock(port = 8081, stubs = "classpath:/stubs/**/*.json")

https://github.com/spring-cloud/spring-cloud-contract/blob/main/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/WireMockConfiguration.java#L213