As a developer, I would like to add a custom extension to my api.yaml file, so that the application can use it for a generic operation.
We have created several micro-services using express-openapi-validator. We would like to add our own custom extension to the openApi file and then have the node.js application read that extension. The format would look something like:
/my-endpoint:
get:
operationId: processGetMyEndpoint
x-eov-operation-handler: myController
x-custom-extension: custom-value
Then, in the code:
function processGetMyEndpoint(req, res) {
const customExtensionValue = getCustomExtension(req);
// Code that uses that extension
}
Is that possible using https://www.npmjs.com/package/express-openapi-validator?
I have tried reading through the docs and the example file but could not find anything. Has anyone else added and retrieved a custom extension?
I found the answer, the schema information is available via req.openapi.schema
. I can get the extension through that.