diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index 330b6fdbb1..c9a784719c 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -743,6 +743,7 @@ enum ApilintCodes { OPENAPI3_0_PARAMETER_FIELD_EXPLODE_TYPE = 5150700, OPENAPI3_0_PARAMETER_FIELD_ALLOW_RESERVED_TYPE = 5150800, OPENAPI3_0_PARAMETER_FIELD_SCHEMA_TYPE = 5150900, + OPENAPI3_0_PARAMETER_FIELD_SCHEMA_MUTUALLY_EXCLUSIVE, OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_VALUES_TYPE = 5151000, OPENAPI3_0_PARAMETER_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE, OPENAPI3_0_PARAMETER_FIELD_CONTENT_VALUES_TYPE = 5151100, 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 80db824dc6..da3e819b02 100644 --- a/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts +++ b/packages/apidom-ls/src/config/openapi/parameter/lint/index.ts @@ -14,6 +14,7 @@ import styleTypeLint from './style--type'; import explodeTypeLint from './explode--type'; import allowReservedTypeLint from './allow-reserved--type'; import schemaTypeLint from './schema--type'; +import schemaMutuallyExclusiveLint from './schema--mutually-exclusive'; import examplesValuesTypeLint from './examples--values-type'; import examplesMutuallyExclusiveLint from './examples--mutually-exclusive'; import contentValuesTypeLint from './content--values-type'; @@ -33,6 +34,7 @@ const lints = [ explodeTypeLint, allowReservedTypeLint, schemaTypeLint, + schemaMutuallyExclusiveLint, examplesValuesTypeLint, examplesMutuallyExclusiveLint, contentValuesTypeLint, diff --git a/packages/apidom-ls/src/config/openapi/parameter/lint/schema--mutually-exclusive.ts b/packages/apidom-ls/src/config/openapi/parameter/lint/schema--mutually-exclusive.ts new file mode 100644 index 0000000000..d15c64c6a7 --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/parameter/lint/schema--mutually-exclusive.ts @@ -0,0 +1,23 @@ +import { DiagnosticSeverity } from 'vscode-languageserver-types'; + +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const schemaMutuallyExclusiveLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_PARAMETER_FIELD_SCHEMA_MUTUALLY_EXCLUSIVE, + source: 'apilint', + message: 'The `schema` field and `content` field are mutually exclusive.', + severity: DiagnosticSeverity.Error, + linterFunction: 'missingFields', + linterParams: [['schema']], + marker: 'key', + markerTarget: 'schema', + conditions: [ + { + function: 'existFields', + params: [['content']], + }, + ], +}; + +export default schemaMutuallyExclusiveLint;