Replies: 1 comment
-
This is a problem with the router, static routes should take preference over dynamic routes. Please open an issue following the template given when creating one. For now, you could turn off RequestValidation and manage it in the controllers, like so: // Controler.js
export function findSamplePath(req, res) {
if (res.locals.oas.params?.id === "_health") {
getSamplePathHealth(req, res) // Call to the controller that handles /samplePath/_health
} else {
/* Controller logic */
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HI, OAS tools community.
In my API JSON file, I have the following definition for these two endpoints. (/samplePath/_health & /samplePath/{id}
But when I call
/samplePath/_health
. I got this error:{"error":"TypeError: Cannot read property 'forEach' of undefined"}
Which is thrown from here: oas-validator.js
I added some console.logs in the oas-validator.js and oas-params.js
Then I got the following info.
Seems like oas tools treats the
/samplePath/_health
endpoint's_health
as a path param.🚀 ~ file: oas-params.js:13 ~ OASParams ~ methodParams undefined
🚀 ~ file: oas-params.js:14 ~ OASParams ~ pathParams undefined
🚀 ~ file: oas-params.js:13 ~ OASParams ~ methodParams [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' }
}
]
🚀 ~ file: oas-params.js:14 ~ OASParams ~ pathParams undefined
[12/12/2022 23:17:40.874 +00:00] [info] : Requested GET /templates/_health
🚀 ~ file: oas-validator.js:52 ~ OASRequestValidator ~ res.locals.oas.params { id: '_health' }
[12/12/2022 23:17:40.875 +00:00] [error] : TypeError: Cannot read property 'forEach' of undefined
How could I solve this issue?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions