Skip to content

Commit

Permalink
adds support for using in requestBody
Browse files Browse the repository at this point in the history
  • Loading branch information
trebler committed Aug 19, 2019
1 parent 0bb25be commit dd02c20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/middlewares/openapi.request.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ export class RequestValidator {

private buildMiddleware(path, pathSchema, contentType) {
const parameters = this.parametersToSchema(path, pathSchema.parameters);
const requestBody = pathSchema.requestBody;
let requestBody = pathSchema.requestBody;

if (requestBody && requestBody.hasOwnProperty('$ref')) {
const id = requestBody.$ref.replace(/^.+\//i, '');
requestBody = this._apiDocs.components.requestBodies[id];
}

let body = this.requestBodyToSchema(path, contentType, requestBody);
let requiredAdds = requestBody && requestBody.required ? ['body'] : [];
Expand Down

0 comments on commit dd02c20

Please sign in to comment.