Skip to content

Commit

Permalink
update read.only work to ensure all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Oct 18, 2019
1 parent 5220222 commit 1026adb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/middlewares/openapi.request.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ export class RequestValidator {
requestBody = this._apiDocs.components.requestBodies[id];
}

if (requestBody) {
const bodySchema =
requestBody &&
requestBody.content &&
requestBody.content[contentType] &&
requestBody.content[contentType].schema['$ref'];

if (bodySchema) {
// check request body for readonly properties
const r = this.ajv.getSchema(
requestBody.content['application/json'].schema['$ref'],
);
Object.keys(r.schema.properties).forEach(itemKey => {
const r = this.ajv.getSchema(bodySchema);
Object.keys(r.schema.properties || {}).forEach(itemKey => {
const readOnly = r.schema.properties[itemKey].hasOwnProperty(
'readOnly',
);
Expand Down
2 changes: 1 addition & 1 deletion test/read.only.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createApp } from './common/app';

const packageJson = require('../package.json');

describe.only(packageJson.name, () => {
describe(packageJson.name, () => {
let app = null;

before(async () => {
Expand Down

0 comments on commit 1026adb

Please sign in to comment.