Skip to content

Commit cc74e0c

Browse files
committed
feat(ls): provide OpenAPI 3.0.x Reference lint rules
Refs #2033
1 parent fb69f9d commit cc74e0c

File tree

15 files changed

+93
-153
lines changed

15 files changed

+93
-153
lines changed

packages/apidom-ls/src/config/openapi/example/lint/$ref--no-siblings.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/apidom-ls/src/config/openapi/example/lint/$ref--valid.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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: [['summary', 'description', 'value', 'externalValue', '$ref'], 'x-'],
12+
marker: 'key',
13+
targetSpecs: [
14+
{ namespace: 'openapi', version: '3.0.0' },
15+
{ namespace: 'openapi', version: '3.0.1' },
16+
{ namespace: 'openapi', version: '3.0.2' },
17+
{ namespace: 'openapi', version: '3.0.3' },
18+
],
19+
};
20+
21+
export default allowedFields3_0Lint;

packages/apidom-ls/src/config/openapi/example/lint/allowed-fields.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import allowedFieldsLint from './allowed-fields';
2-
import $refValidLint from './$ref--valid';
3-
import $refNoSiblingsLint from './$ref--no-siblings';
1+
import allowedFields3_0Lint from './allowed-fields-3-0';
42
import summaryTypeLint from './summary--type';
53
import descriptionTypeLint from './description--type';
64
import valueMutuallyExclusiveLint from './value--mutually-exclusive';
@@ -11,9 +9,7 @@ const lints = [
119
descriptionTypeLint,
1210
valueMutuallyExclusiveLint,
1311
externalValueFormatURILint,
14-
$refValidLint,
15-
$refNoSiblingsLint,
16-
allowedFieldsLint,
12+
allowedFields3_0Lint,
1713
];
1814

1915
export default lints;

packages/apidom-ls/src/config/openapi/request-body/lint/$ref--no-siblings.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/apidom-ls/src/config/openapi/request-body/lint/$ref--valid.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import ApilintCodes from '../../../codes';
22
import { LinterMeta } from '../../../../apidom-language-types';
33

4-
const allowedFieldsLint: LinterMeta = {
4+
// eslint-disable-next-line @typescript-eslint/naming-convention
5+
const allowedFields3_0Lint: LinterMeta = {
56
code: ApilintCodes.NOT_ALLOWED_FIELDS,
67
source: 'apilint',
78
message: 'Object includes not allowed fields',
89
severity: 1,
910
linterFunction: 'allowedFields',
1011
linterParams: [['description', 'content', 'required', '$ref'], 'x-'],
1112
marker: 'key',
13+
targetSpecs: [
14+
{ namespace: 'openapi', version: '3.0.0' },
15+
{ namespace: 'openapi', version: '3.0.1' },
16+
{ namespace: 'openapi', version: '3.0.2' },
17+
{ namespace: 'openapi', version: '3.0.3' },
18+
],
1219
};
1320

14-
export default allowedFieldsLint;
21+
export default allowedFields3_0Lint;
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import allowedFieldsLint from './allowed-fields';
2-
import $refNoSiblingsLint from './$ref--no-siblings';
3-
import $refValidLint from './$ref--valid';
1+
import allowedFields3_0Lint from './allowed-fields-3-0';
42
import descriptionTypeLint from './description--type';
53
import contentValuesTypeLint from './content--values-type';
64
import contentRequiredLint from './content--required';
75
import requiredTypeLint from './required--type';
86

97
const lints = [
10-
allowedFieldsLint,
11-
$refNoSiblingsLint,
12-
$refValidLint,
138
descriptionTypeLint,
149
contentRequiredLint,
1510
contentValuesTypeLint,
1611
requiredTypeLint,
12+
allowedFields3_0Lint,
1713
];
1814

1915
export default lints;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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', 'headers', 'content', 'links', '$ref'], 'x-'],
12+
marker: 'key',
13+
targetSpecs: [
14+
{ namespace: 'openapi', version: '3.0.0' },
15+
{ namespace: 'openapi', version: '3.0.1' },
16+
{ namespace: 'openapi', version: '3.0.2' },
17+
{ namespace: 'openapi', version: '3.0.3' },
18+
],
19+
};
20+
21+
export default allowedFields3_0Lint;

packages/apidom-ls/src/config/openapi/response/lint/allowed-fields.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import allowedFieldsLint from './allowed-fields';
1+
import allowedFields3_0Lint from './allowed-fields-3-0';
22
import descriptionTypeLint from './description--type';
33
import descriptionRequiredLint from './description--required';
44
import headersValuesTypeLint from './headers--values-type';
@@ -11,7 +11,7 @@ const lints = [
1111
headersValuesTypeLint,
1212
contentValuesTypeLint,
1313
linksValuesTypeLint,
14-
allowedFieldsLint,
14+
allowedFields3_0Lint,
1515
];
1616

1717
export default lints;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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: [
12+
[
13+
'type',
14+
'description',
15+
'name',
16+
'in',
17+
'scheme',
18+
'bearerFormat',
19+
'flows',
20+
'openIdConnectUrl',
21+
'$ref',
22+
],
23+
'x-',
24+
],
25+
marker: 'key',
26+
targetSpecs: [
27+
{ namespace: 'openapi', version: '3.0.0' },
28+
{ namespace: 'openapi', version: '3.0.1' },
29+
{ namespace: 'openapi', version: '3.0.2' },
30+
{ namespace: 'openapi', version: '3.0.3' },
31+
],
32+
};
33+
34+
export default allowedFields3_0Lint;

packages/apidom-ls/src/config/openapi/security-scheme/lint/allowed-fields.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/apidom-ls/src/config/openapi/security-scheme/lint/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import allowedFieldsLint from './allowed-fields';
1+
import allowedFields3_0Lint from './allowed-fields-3-0';
22
import typeEquals3_0Lint from './type--equals-3-0';
33
import descriptionTypeLint from './description--type';
44
import nameTypeLint from './name--type';
@@ -27,7 +27,7 @@ const lints = [
2727
flowsRequiredLint,
2828
openIdConnectUrlFormatURILint,
2929
openIdConnectUrlRequiredLint,
30-
allowedFieldsLint,
30+
allowedFields3_0Lint,
3131
];
3232

3333
export default lints;

0 commit comments

Comments
 (0)