Skip to content

Commit 713eecd

Browse files
committed
feat(ls): provide OpenAPI 3.1.0 License lint rules
feat(ls): oas31 update license allowed fields
1 parent a333168 commit 713eecd

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ enum ApilintCodes {
813813
OPENAPI3_1_COMPONENTS = 7020000,
814814
OPENAPI3_1_COMPONENTS_FIELD_PATH_ITEMS_VALUES_TYPE = 7020100,
815815

816+
OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE = 7040300,
817+
OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_MUTUALLY_EXCLUSIVE = 7040600,
818+
816819
ADS = 8000000,
817820
ADS_INFO = 8010000,
818821
ADS_INFO_REQUIRED = 8010010,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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_1Lint: 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: [['name', 'url', 'identifier'], 'x-'],
12+
marker: 'key',
13+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
14+
};
15+
16+
export default allowedFields3_1Lint;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import ApilintCodes from '../../../codes';
2+
import { LinterMeta } from '../../../../apidom-language-types';
3+
4+
const identifierMutuallyExclusiveLint: LinterMeta = {
5+
code: ApilintCodes.OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_MUTUALLY_EXCLUSIVE,
6+
source: 'apilint',
7+
message: 'The identifier field and url field are mutually exclusive.',
8+
severity: 1,
9+
linterFunction: 'allowedFields',
10+
linterParams: [['identifier']],
11+
marker: 'key',
12+
target: 'identifier',
13+
data: {},
14+
conditions: [
15+
{
16+
function: 'existFields',
17+
params: [['url']],
18+
},
19+
],
20+
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
21+
};
22+
23+
export default identifierMutuallyExclusiveLint;

packages/apidom-ls/src/config/openapi/license/lint/identifier--type.ts

Whitespace-only changes.
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import allowedFields3_0Lint from './allowed-fields-3-0';
2+
import allowedFields3_1Lint from './allowed-fields-3-1';
23
import nameTypeLint from './name--type';
34
import nameRequiredLint from './name--required';
5+
import identifierMutuallyExclusiveLint from './identifier--mutually-exclusive';
46
import urlFormatURILint from './url--format-uri';
57

6-
const lints = [nameTypeLint, nameRequiredLint, urlFormatURILint, allowedFields3_0Lint];
8+
const lints = [
9+
nameTypeLint,
10+
nameRequiredLint,
11+
identifierMutuallyExclusiveLint,
12+
urlFormatURILint,
13+
allowedFields3_0Lint,
14+
allowedFields3_1Lint,
15+
];
716

817
export default lints;

packages/apidom-ls/src/config/openapi/license/lint/name--type.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import ApilintCodes from '../../../codes';
22
import { LinterMeta } from '../../../../apidom-language-types';
33

44
const nameTypeLint: LinterMeta = {
5-
code: ApilintCodes.OPENAPI3_0_LICENSE_FIELD_NAME_TYPE,
5+
code: ApilintCodes.OPENAPI3_1_LICENSE_FIELD_IDENTIFIER_TYPE,
66
source: 'apilint',
7-
message: "'name' must be a string",
7+
message: "'identifier' must be a string",
88
severity: 1,
99
linterFunction: 'apilintType',
1010
linterParams: ['string'],

0 commit comments

Comments
 (0)