Skip to content

feat(ls): OpenAPI 3.x.x mutually exclusive lint rule for Media Type #2168

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 2 commits into from
Oct 21, 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
1 change: 1 addition & 0 deletions packages/apidom-ls/src/config/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;