Skip to content

Commit

Permalink
(fix) cdimascio#415 Cannot read property 'push' of undefined bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ex1st committed Oct 26, 2020
1 parent 2ee83f2 commit 59f1124
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/middlewares/parsers/request.schema.preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ export class RequestSchemaPreprocessor {

if (parameters.length === 0) return;

const v = pathItem[pathItemKey];
let v = pathItem[pathItemKey];
if (v === parameters) return;
const ref = v?.parameters?.$ref;

const operationParameters = <
Array<OpenAPIV3.ParameterObject | OpenAPIV3.ReferenceObject>
>(ref ? this.ajv.getSchema(ref)?.schema : v.parameters);
const op = ref && this.ajv.getSchema(ref)?.schema;
if (op)
v = op;
v.parameters = v.parameters || [];

for (const param of parameters) {
operationParameters.push(param);
v.parameters.push(param);
}
}

Expand Down

0 comments on commit 59f1124

Please sign in to comment.