diff --git a/packages/apidom-ls/src/config/codes.ts b/packages/apidom-ls/src/config/codes.ts index 398673de78..ef2c2d58ec 100644 --- a/packages/apidom-ls/src/config/codes.ts +++ b/packages/apidom-ls/src/config/codes.ts @@ -721,6 +721,7 @@ enum ApilintCodes { OPENAPI3_0_MEDIA_TYPE_FIELD_SCHEMA_VALUES_TYPE = 5170100, OPENAPI3_0_MEDIA_TYPE_FIELD_EXAMPLES_VALUES_TYPE = 5170200, OPENAPI3_0_MEDIA_TYPE_FIELD_ENCODING_VALUES_TYPE = 5170300, + OPENAPI3_0_MEDIA_TYPE_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE, OPENAPI3_0_ENCODING = 5180000, OPENAPI3_0_ENCODING_FIELD_CONTENT_TYPE_TYPE = 5180100, diff --git a/packages/apidom-ls/src/config/openapi/media-type/lint/examples--mutually-exclusive.ts b/packages/apidom-ls/src/config/openapi/media-type/lint/examples--mutually-exclusive.ts new file mode 100644 index 0000000000..7cf99e8c1a --- /dev/null +++ b/packages/apidom-ls/src/config/openapi/media-type/lint/examples--mutually-exclusive.ts @@ -0,0 +1,21 @@ +import ApilintCodes from '../../../codes'; +import { LinterMeta } from '../../../../apidom-language-types'; + +const examplesMutuallyExclusiveLint: LinterMeta = { + code: ApilintCodes.OPENAPI3_0_MEDIA_TYPE_FIELD_EXAMPLES_MUTUALLY_EXCLUSIVE, + source: 'apilint', + message: 'The `example` field and `examples` field are mutually exclusive.', + severity: 1, + 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/media-type/lint/index.ts b/packages/apidom-ls/src/config/openapi/media-type/lint/index.ts index a2df63b9d9..9226c5fe31 100644 --- a/packages/apidom-ls/src/config/openapi/media-type/lint/index.ts +++ b/packages/apidom-ls/src/config/openapi/media-type/lint/index.ts @@ -2,7 +2,14 @@ import allowedFieldsLint from './allowed-fields'; import schemaTypeLint from './schema--type'; import examplesValuesTypeLint from './examples--values-type'; import encodingValuesTypeLint from './encoding--values-type'; +import examplesMutuallyExclusiveLint from './examples--mutually-exclusive'; -const lints = [schemaTypeLint, examplesValuesTypeLint, encodingValuesTypeLint, allowedFieldsLint]; +const lints = [ + schemaTypeLint, + examplesValuesTypeLint, + encodingValuesTypeLint, + allowedFieldsLint, + examplesMutuallyExclusiveLint, +]; export default lints;