pactflow / roadmap

Public Pactflow issue tracker and roadmap
MIT License
15 stars 0 forks source link

Support resolving `basePath` in OAS comparison #86

Closed mefellows closed 1 year ago

mefellows commented 1 year ago

Comparison of Pact interactions to OAS endpoints does not consider any basePath in its comparison.

In OAS 3 (and also 2), all API endpoints are considered to be relative to the base URL. For example, assuming the base URL of https://api.example.com/v1, the /users endpoint refers to https://api.example.com/v1/users.

Our comparison does not consider the impact of basePath as there may be multiple servers with different context paths and there is no clear way to resolve this ambiguity. In this example, a pact interaction with path /v1/users/ will not match an OAS that only has /users/ in its resource path.

Ways to resolve ambiguity

  1. If there is only a single server, we use the path component from that
  2. If there are multiple servers, all with the same base path. e.g. https://server1/base/path and https://server2/base/path then we can assume a /base/path is the correct one
  3. If there are multiple servers with different base paths, then we have some additional options a. Fail with an error b. Allow a user to annotate the OAS with x-pactflow-<property> which specifies the basePath for the purposes of cross-contract validation
mefellows commented 1 year ago

Closing as wontfix. See https://github.com/pactflow/swagger-mock-validator/issues/28 for details on why.