- edited description
SchemaValidator fails to validate schema with array as a root element with items containing readOnly/writeOnly properties
Issue #240
resolved
Schema with array as a root element with items containing readOnly/writeOnly properties are not validated properly.
Validator would not honor readOnly/writeOnly properties appropriately (Inside request/response schemas)
Example:
[
{
"notReadOnly":"abc",
"readOnly": "123"
}
]
above validating above json as response schema against swagger below would complain about absence of writeOnly property.
openapi: 3.0.0
info:
version: 1.0.0
title: RequiredReadOnly
servers:
- url: /
paths:
/readOnly:
patch:
summary: patch an item
requestBody:
description: patched
content:
application/json:
schema:
$ref: '#/components/schemas/ReadOnlyArray'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/ReadOnlyArray'
'401':
description: Not authenticated
'403':
description: Not authorized
components:
schemas:
ReadOnly:
type: object
properties:
readOnly:
type: string
readOnly: true
example: 'read'
notReadOnly:
type: string
example: 'abc'
writeOnly:
type: string
writeOnly: true
example: 'write'
required:
- readOnly
- notReadOnly
- writeOnly
ReadOnlyArray:
type: array
items:
$ref: '#/components/schemas/ReadOnly'
Comments (5)
-
reporter -
reporter - changed title to SchemaValidator fails to validate schema with array as a root element with items containing readOnly/writeOnly properties
-
reporter - changed status to open
I have fixed this issue and there's a PR already waiting to be reviewed here: Link to PR
-
Thanks very much for the contribution! I’ll review it as soon as I can.
-
- changed status to resolved
Available in v2.7.2
- Log in to comment