Skip to content

Commit ae4c69b

Browse files
authored
fix(ls): provide OpenAPI 3.1 Request Body allowed fields lint rule (#2216)
Refs #2061
1 parent 3fe4a0b commit ae4c69b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import ApilintCodes from '../../../codes';
2+
import { LinterMeta } from '../../../../apidom-language-types';
3+
4+
// eslint-disable-next-line @typescript-eslint/naming-convention
5+
const allowedFields3_0Lint: LinterMeta = {
6+
code: ApilintCodes.NOT_ALLOWED_FIELDS,
7+
source: 'apilint',
8+
message: 'Object includes not allowed fields',
9+
severity: 1,
10+
linterFunction: 'allowedFields',
11+
linterParams: [['description', 'content', 'required'], 'x-'],
12+
marker: 'key',
13+
conditions: [
14+
{
15+
function: 'missingField',
16+
params: ['$ref'],
17+
},
18+
],
19+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
20+
};
21+
22+
export default allowedFields3_0Lint;

packages/apidom-ls/src/config/openapi/request-body/lint/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import allowedFields3_0Lint from './allowed-fields-3-0';
2+
import allowedFields3_1Lint from './allowed-fields-3-1';
23
import descriptionTypeLint from './description--type';
34
import contentValuesTypeLint from './content--values-type';
45
import contentRequiredLint from './content--required';
@@ -10,6 +11,7 @@ const lints = [
1011
contentValuesTypeLint,
1112
requiredTypeLint,
1213
allowedFields3_0Lint,
14+
allowedFields3_1Lint,
1315
];
1416

1517
export default lints;

0 commit comments

Comments
 (0)