diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index 6bc3803013..dafe7405db 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -744,6 +744,7 @@ enum ApilintCodes { OPENAPI3_0_PARAMETER_FIELD_ALLOW_RESERVED_TYPE = 5150800, OPENAPI3_0_PARAMETER_FIELD_SCHEMA_TYPE = 5150900, OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_VALUES_TYPE = 5151000, + OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE, OPENAPI3_0_PARAMETER_FIELD_CONTENT_VALUES_TYPE = 5151100, OPENAPI3_0_REQUEST_BODY = 5160000, diff --git a/packages/apidom-ls/src/config/openapi/parameter/lint/examples--mutually-exclusive.ts b/packages/apidom-ls/src/config/openapi/parameter/lint/examples--mutually-exclusive.ts new file mode 100644 index 0000000000..065a4c3ccf --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/parameter/lint/examples--mutually-exclusive.ts @@ -0,0 +1,23 @@ +import { DiagnosticSeverity } from 'vscode-languageserver-types'; + +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const examplesMutuallyExclusiveLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE, + source: 'apilint', + message: 'The `example` field and `examples` field are mutually exclusive.', + severity: DiagnosticSeverity.Error, + linterFunction: 'missingFields', + linterParams: [['examples']], + marker: 'key', + markerTarget: 'examples', + conditions: [ + { + function: 'existFields', + params: [['example']], + }, + ], +}; + +export default examplesMutuallyExclusiveLint; diff --git a/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts b/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts index 1793e55e36..80db824dc6 100644 --- a/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts +++ b/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts @@ -15,6 +15,7 @@ import explodeTypeLint from './explode--type'; import allowReservedTypeLint from './allow-reserved--type'; import schemaTypeLint from './schema--type'; import examplesValuesTypeLint from './examples--values-type'; +import examplesMutuallyExclusiveLint from './examples--mutually-exclusive'; import contentValuesTypeLint from './content--values-type'; const lints = [ @@ -33,6 +34,7 @@ const lints = [ allowReservedTypeLint, schemaTypeLint, examplesValuesTypeLint, + examplesMutuallyExclusiveLint, contentValuesTypeLint, allowedFields3_0Lint, allowedFields3_1Lint,