Skip to content

feat(ls): OpenAPI 3.1.0 lint rules for components object #2118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -726,6 +726,8 @@ enum ApilintCodes {
OPENAPI3_1_INFO = 7010000,
OPENAPI3_1_INFO_FIELD_SUMMARY_TYPE = 7010100,

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;