Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resolving basePath in OAS comparison #86

Closed
mefellows opened this issue Dec 21, 2022 · 1 comment
Closed

Support resolving basePath in OAS comparison #86

mefellows opened this issue Dec 21, 2022 · 1 comment
Labels
bi-directional BDCT improvements OAS OpenAPI related issues

Comments

@mefellows
Copy link
Contributor

mefellows commented Dec 21, 2022

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 mefellows added bi-directional BDCT improvements OAS OpenAPI related issues labels Dec 21, 2022
@mefellows
Copy link
Contributor Author

Closing as wontfix. See pactflow/swagger-mock-validator#28 for details on why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bi-directional BDCT improvements OAS OpenAPI related issues
Projects
None yet
Development

No branches or pull requests

1 participant