Skip to content

Commit 0a5b973

Browse files
committed
feat(ls): provide OpenAPI 3.0.x Paths lint rules
Refs #2033
1 parent 4541787 commit 0a5b973

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

packages/apidom-ls/src/config/codes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ enum ApilintCodes {
639639
OPENAPI3_O_SERVER_VARIABLE_FIELD_DEFAULT_REQUIRED,
640640
OPENAPI3_O_SERVER_VARIABLE_FIELD_DESCRIPTION_TYPE = 5080300,
641641

642+
OPENAPI_3_0_PATHS = 5090000,
643+
OPENAPI_3_0_PATHS_KEYS_PATTERN,
644+
OPENAPI_3_0_PATHS_VALUES_PATTERN,
645+
642646
OPENAPI3_1 = 7000000,
643647

644648
OPENAPI3_1_OPENAPI_VALUE_PATTERN_3_1_0 = 7000100,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import keysPatternLint from './keys--pattern';
2+
import valuesTypeLint from './values--type';
3+
4+
const lints = [keysPatternLint, valuesTypeLint];
5+
6+
export default lints;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import ApilintCodes from '../../../codes';
2+
import { LinterMeta } from '../../../../apidom-language-types';
3+
4+
const keysPatternLint: LinterMeta = {
5+
code: ApilintCodes.OPENAPI_3_0_PATHS_KEYS_PATTERN,
6+
source: 'apilint',
7+
message: 'Paths Object keys must match the regular expression: `^/.*$`',
8+
severity: 1,
9+
linterFunction: 'apilintMembersKeysRegex',
10+
linterParams: ['^\\/.*$'],
11+
marker: 'key',
12+
data: {},
13+
};
14+
15+
export default keysPatternLint;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import ApilintCodes from '../../../codes';
2+
import { LinterMeta } from '../../../../apidom-language-types';
3+
4+
const valuesTypeLint: LinterMeta = {
5+
code: ApilintCodes.OPENAPI_3_0_PATHS_VALUES_PATTERN,
6+
source: 'apilint',
7+
message: 'Paths Object values must be of Path Item Object shape',
8+
severity: 1,
9+
linterFunction: 'apilintChildrenOfElementsOrClasses',
10+
linterParams: [['pathItem']],
11+
marker: 'key',
12+
data: {},
13+
};
14+
15+
export default valuesTypeLint;

packages/apidom-ls/src/config/openapi/paths/meta.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import lint from './lint';
12
import documentation from './documentation';
23
import { FormatMeta } from '../../../apidom-language-types';
34

45
const meta: FormatMeta = {
6+
lint,
57
documentation,
68
};
79

0 commit comments

Comments
 (0)