I have a demo project here https://github.com/donalthurley/pact-demo which shows the problem I'm having.
The general problem is that I am trying to develop an API that complies to a PACT contract where the contract is using a URL path that includes a context.
The spring boot controller API maps the request without the context in the path see https://github.com/donalthurley/pact-demo/blob/master/src/main/java/com/example/demo/DemoController.java#L22
The PACT contract specifies the same request with the context 'demo' prepended to the URL path see https://github.com/donalthurley/pact-demo/blob/master/src/main/resources/demo-pact.json#L14
When pact generates the unit tests it fails in this case with a 404.
If the context is removed from the PACT contract then the generated tests succeed.
My question is this, is there any way I can tell the PACT generation to use the 'demo' context so that the generated tests will work?
This earlier answer How to set the context path in Spring Boot WebMvcTest would suggest that this is not possible but I would like to confirm that as I don't understand why this shouldn't be supported.
In my humble opinion, you shouldn't include the context in the pact, the same way like your controller does.
I guess you are using some API-gateway, So all dealing with the context should be ended once you leave the API-gateway. In your service level the context is already irrelevant.