Skip to content

Commit

Permalink
feat(ls): OpenAPI 3.1.0 lint rules for components object (#2118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lai committed Oct 11, 2022
1 parent 956262f commit 64b8f3d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ enum ApilintCodes {
OPENAPI3_1_INFO = 7020000,
OPENAPI3_1_INFO_FIELD_SUMMARY_TYPE = 7020100,

OPENAPI3_1_COMPONENTS_FIELD_PATH_ITEMS_VALUES_TYPE = 7061000,

ADS = 8000000,
ADS_INFO = 8010000,
ADS_INFO_REQUIRED = 8010010,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

// eslint-disable-next-line @typescript-eslint/naming-convention
const allowedFieldsLint3_1: LinterMeta = {
code: ApilintCodes.NOT_ALLOWED_FIELDS,
source: 'apilint',
message: 'Object includes not allowed fields',
severity: 1,
linterFunction: 'allowedFields',
linterParams: [
[
'schemas',
'responses',
'parameters',
'examples',
'requestBodies',
'headers',
'securitySchemes',
'links',
'callbacks',
'pathItems',
],
'x-',
],
marker: 'key',
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
};

export default allowedFieldsLint3_1;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import allowedFields3_0Lint from './allowed-fields-3-0';
import allowedFieldsLint3_1 from './allowed-fields-3-1';
import schemasValuesTypeLint from './schemas--values-type';
import responsesValuesTypeLint from './responses--values-type';
import parametersValuesTypeLint from './parameters--values-type';
Expand All @@ -9,6 +10,7 @@ import securitySchemesValuesType from './security-schemes--values-type';
import linksValuesTypeLint from './links--values-type';
import callbacksValuesTypeLint from './callbacks--values-type';
import keysPatternLint from './keys--pattern';
import pathItemsValuesTypeLint from './path-items--values-type';

const lints = [
schemasValuesTypeLint,
Expand All @@ -21,7 +23,9 @@ const lints = [
linksValuesTypeLint,
callbacksValuesTypeLint,
keysPatternLint,
pathItemsValuesTypeLint,
allowedFields3_0Lint,
allowedFieldsLint3_1,
];

export default lints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';

const pathItemsValuesTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_1_COMPONENTS_FIELD_PATH_ITEMS_VALUES_TYPE,
source: 'apilint',
message: '"pathItems" members must be Path Item Object',
severity: 1,
linterFunction: 'apilintChildrenOfElementsOrClasses',
linterParams: [['pathItem']],
marker: 'key',
markerTarget: 'pathItems',
target: 'pathItems',
data: {},
};

export default pathItemsValuesTypeLint;

0 comments on commit 64b8f3d

Please sign in to comment.