p-meier / hapi-api-version

An API versioning plugin for hapi.
Apache License 2.0
74 stars 26 forks source link

How to support api versioning with Path Parameter #37

Open bvora-systemone opened 2 years ago

bvora-systemone commented 2 years ago

There is issue with the apis which is containing path parameters. While we are trying to access such apis using hapi-api-versioning its not detecting path parameter.

Due to that its throwing 404 error. Ex, client is requesting this endpoint /api/user/{userId} (/api/user/62). So its path parameter {userId} is not detected in server.ext('onRequest', ...).

Eventually it's ending up with 404 error. Which is more likely not handled in hapi-api-versioning.

Seeking support. Thank you in Advance

timcosta commented 2 years ago

Hello! Can you please provide some more detail about what you are trying to do, stating what the current behavior is, and what the expected behavior is?

It may be helpful to look at this diagram about the Hapi request lifecycle https://futurestud.io/downloads/hapi/request-lifecycle

In onRequest the path parameters haven't been parsed yet, which is why this package uses custom parsing to extract the api version from the path parameter.

Also, you stated you were using hapi-api-versioning in your message, which is a different package than hapi-api-version. Can you confirm you are opening an issue in the right repo? https://www.npmjs.com/package/hapi-api-versioning is not this repo.