express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

readOnly in $ref: is ignored

Open tkarls opened this issue 3 years ago • 0 comments

Describe the bug when using readOnly:true inside a $ref: then the readOnly:true attribute is ignored (i.e. the attribute is enforced for post/put requests)

To Reproduce Have a required attribute that receives its definition via a $ref. The definition must include readOnly: true

Actual behavior The read only attribute is ignored

Expected behavior A post/put request omitting the attribute should pass validation A post/put request containing the attribute should fail validation (atrribute is read only)

Examples and context

Using the following psudo spec triggers the problem

genericReadOnlyId:
  type: string
  title: ID
  readOnly: true

someObject:
  type: object
  required:
      - id
  properties
    id:
      $ref: "#/genericReadOnlyId"

tkarls avatar May 02 '22 17:05 tkarls