If the paths defined are relative to URL defined under server tag, the stubs are not getting recognized and loaded during tests. #1470
-
I have an order.yaml with the following :openapi: 3.0.1
When I define a stub with the following approach in an external file. The following stub is not picked up and while running the te{ When the test run starts the stub files are not picked up with following errorAPI Specification Summary: .\local-spec\order.yaml Loading stub expectations from src\test\resources\order_examples Also while running the tests, I get the following errorNo matching REST stub or contract found for method GET and path /orders/customer/1001 (assuming you're looking for a REST API since no SOAPAction header was detected) The Stubs are picked up when I change the path as follows:openapi: 3.0.1
As per the above I find the relative paths are not considered while picking up the stubs. Suppose the user has no way of changing the contract and has to rely on externalizing the stubs. How can the user configure the stubs so that it gets picked up during the run? I have attached the order.yaml (as order.txt) with relative paths and the logs of the two runs and sample stub. for reference |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
hello @prateekkarmakar , thanks for reaching out. The problem where we cannot change the spec to add path prefixes (to simulate gateways, etc.), add headers, etc. is quite common. The best approach IMHO for this is to use OpenAPI Overlays to add these changes externally. Specmatic supports overlays and here is the documentation. In your specific case, we can add the Please reach out to us if you need any help on this. Regards, |
Beta Was this translation helpful? Give feedback.
-
Can You share an example for the above I have tried some things but its not working neither in the OpenAPI documentation there is any reference. I tried things like this overlay: 1.0.0
but I get the following error The OpenAPI file ..\local-specs\order.yaml was read successfully but with some issues |
Beta Was this translation helpful? Give feedback.
hello @prateekkarmakar , thanks for reaching out.
The problem where we cannot change the spec to add path prefixes (to simulate gateways, etc.), add headers, etc. is quite common. The best approach IMHO for this is to use OpenAPI Overlays to add these changes externally.
Specmatic supports overlays and here is the documentation. In your specific case, we can add the
/orders/customer
prefix to your path externally through an overlay file and Specmatic will apply this change on your OpenAPI spec at runtime and there by pick up your example JSONs (which can continue have/orders/customer/
). Hope this helps.Please reach out to us if you need any help on this.
Regards,
HariKrishnan