-
-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Description
I am using v5.4.6 and an open api spec 3.1.0., and on app luanch I initialize the validtor like so
// 2. Add the OpenApiValidator middleware
app.use(
OpenApiValidator.middleware({
apiSpec,
validateResponses: true // default false
// 3. Provide the path to the controllers directory
// operationHandlers: path.join(__dirname), // default false
}),
);
I then made the same endpoint call 3 times. Each time, I see ajv being constructed, the apiSpec is reparsed and validated and the entire spec is re-added to ajv via:
if ((_a = openApiSpec.components) === null || _a === void 0 ? void 0 : _a.schemas) {
Object.entries(openApiSpec.components.schemas).forEach(([id, schema]) => {
ajv.addSchema(openApiSpec.components.schemas[id], `#/components/schemas/${id}`);
});
Since ajv is a new instance every time, the addSchema
call endups up returning undefined
for let sch = this._cache.get(schema);
I have not come across anything in the docs that would indicate a way to prevent this continual reload, but I am hoping I missed something.
JustinYuYou
Metadata
Metadata
Assignees
Labels
No labels