simonplend / express-json-validator-middleware

Express middleware for validating requests against JSON schema

Home Page:https://npm.im/express-json-validator-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for readOnly and writeOnly keywords

anshumanpandey opened this issue · comments

It would be great to have support for readOnly and writeOnly keywords as described on the OpenApi site

You can use the readOnly and writeOnly keywords to mark specific properties as read-only or write-only. This is useful, for example, when GET returns more properties than used in POST – you can use the same schema in both GET and POST and mark the extra properties as readOnly. readOnly properties are included in responses but not in requests, and writeOnly properties may be sent in requests but not in responses.

@anshumanpandey My understanding is that readOnly and writeOnly are annotation keywords (reference). What support would you like to see? Are you receiving an error if you use them in your schemas?

The Ajv documentation suggests that it supports these keywords. You might want to try the beta release I published last month, which upgrades Ajv to v8.

Does the beta and Ajv 8 bring a solution to #96 (comment) any closer?

@trasherdk I've dropped a comment here: #96 (comment)