Skip to content

Commit 1e0f226

Browse files
authored
fix(ls): fix validation of writeOnly and readOnly properties (#5053)
1 parent 1ba6aad commit 1e0f226

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

packages/apidom-ls/src/services/validation/linter-functions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,10 @@ export const standardLinterfunctions: FunctionItem[] = [
356356

357357
const fields = keys.map((key) => element.get(key)).filter(Boolean);
358358

359-
if (fields.length === 0) {
359+
if (fields.length !== keys.length) {
360360
return true;
361361
}
362+
362363
return !fields.every((field) => {
363364
const elValue = toValue(field);
364365

packages/apidom-ls/test/fixtures/validation/oas/schema-read-only-write-only.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ paths:
1616
application/json:
1717
schema:
1818
$ref: '#/components/schemas/PropertyToTest'
19+
application/xml:
20+
schema:
21+
$ref: '#/components/schemas/PropertyToTestNoError'
1922
components:
2023
schemas:
2124
PropertyToTest:
@@ -35,3 +38,19 @@ components:
3538
fieldDate:
3639
type: string
3740
format: date-time
41+
PropertyToTestNoError:
42+
type: object
43+
required:
44+
- id
45+
- fieldname
46+
- fieldDate
47+
properties:
48+
id:
49+
type: string
50+
format: uuid
51+
readOnly: true
52+
fieldname:
53+
type: string
54+
fieldDate:
55+
type: string
56+
format: date-time

packages/apidom-ls/test/validate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,11 +5187,11 @@ describe('apidom-ls-validate', function () {
51875187
range: {
51885188
end: {
51895189
character: 10,
5190-
line: 27,
5190+
line: 30,
51915191
},
51925192
start: {
51935193
character: 8,
5194-
line: 27,
5194+
line: 30,
51955195
},
51965196
},
51975197
severity: 1,

0 commit comments

Comments
 (0)