Skip to content

Commit

Permalink
refactor(ls): make rules scoping forward incompatible
Browse files Browse the repository at this point in the history
This will make sure that when OpenAPI 4.0 lands
existing rules will not be used, unless we
explicitly allow it.

Refs #3104
  • Loading branch information
char0n committed Dec 18, 2023
1 parent 75c46f4 commit 446ffd3
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 36 deletions.
4 changes: 2 additions & 2 deletions packages/apidom-ls/src/config/openapi/contact/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
CompletionFormat,
CompletionType,
} from '../../../apidom-language-types';
import { OpenAPI, OpenAPI2, OpenAPI3 } from '../target-specs';
import { OpenAPI2, OpenAPI3 } from '../target-specs';

const completion: ApidomCompletionItem[] = [
{
Expand All @@ -17,7 +17,7 @@ const completion: ApidomCompletionItem[] = [
kind: 'markdown',
value: 'The identifying name of the contact person/organization.',
},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
},
{
label: 'url',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { OpenAPI, OpenAPI2, OpenAPI30, OpenAPI31, OpenAPI3 } from '../target-specs';
import { OpenAPI2, OpenAPI30, OpenAPI31, OpenAPI3 } from '../target-specs';

const documentation = [
{
target: 'name',
docs: 'The identifying name of the contact person/organization.',
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
},
{
target: 'url',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const allowedFieldsLint: LinterMeta = {
code: ApilintCodes.NOT_ALLOWED_FIELDS,
Expand All @@ -12,7 +12,7 @@ const allowedFieldsLint: LinterMeta = {
linterFunction: 'allowedFields',
linterParams: [['name', 'url', 'email'], 'x-'],
marker: 'key',
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default allowedFieldsLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const emailFormatEmailLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_CONTACT_FIELD_EMAIL_FORMAT_EMAIL,
Expand All @@ -14,7 +14,7 @@ const emailFormatEmailLint: LinterMeta = {
marker: 'value',
target: 'email',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default emailFormatEmailLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const nameTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_CONTACT_FIELD_NAME_TYPE,
Expand All @@ -14,7 +14,7 @@ const nameTypeLint: LinterMeta = {
marker: 'value',
target: 'name',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default nameTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const urlFormatURILint: LinterMeta = {
code: ApilintCodes.OPENAPI2_CONTACT_FIELD_URL_FORMAT_URI,
Expand All @@ -13,7 +13,7 @@ const urlFormatURILint: LinterMeta = {
marker: 'value',
target: 'url',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default urlFormatURILint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const contactTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_INFO_FIELD_CONTACT_TYPE,
Expand All @@ -14,7 +14,7 @@ const contactTypeLint: LinterMeta = {
marker: 'value',
target: 'contact',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default contactTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const descriptionTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_INFO_FIELD_DESCRIPTION_TYPE,
Expand All @@ -14,7 +14,7 @@ const descriptionTypeLint: LinterMeta = {
marker: 'value',
target: 'description',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default descriptionTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const licenseTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_INFO_FIELD_LICENSE_TYPE,
Expand All @@ -14,7 +14,7 @@ const licenseTypeLint: LinterMeta = {
marker: 'value',
target: 'license',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default licenseTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const titleRequiredLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_INFO_FIELD_TITLE_REQUIRED,
Expand All @@ -22,7 +22,7 @@ const titleRequiredLint: LinterMeta = {
},
],
},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default titleRequiredLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const titleTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_INFO_FIELD_TITLE_TYPE,
Expand All @@ -14,7 +14,7 @@ const titleTypeLint: LinterMeta = {
marker: 'value',
target: 'title',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default titleTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const versionRequiredLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_INFO_FIELD_VERSION_REQUIRED,
Expand All @@ -22,7 +22,7 @@ const versionRequiredLint: LinterMeta = {
},
],
},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default versionRequiredLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const versionTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_INFO_FIELD_VERSION_TYPE,
Expand All @@ -14,7 +14,7 @@ const versionTypeLint: LinterMeta = {
marker: 'value',
target: 'version',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default versionTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const nameRequiredLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_LICENSE_FIELD_NAME_REQUIRED,
Expand All @@ -22,7 +22,7 @@ const nameRequiredLint: LinterMeta = {
},
],
},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default nameRequiredLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const nameTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_LICENSE_FIELD_NAME_TYPE,
Expand All @@ -14,7 +14,7 @@ const nameTypeLint: LinterMeta = {
marker: 'value',
target: 'name',
data: {},
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default nameTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const valueValidLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_PATH_TEMPLATE_VALUE_VALID,
Expand All @@ -11,7 +11,7 @@ const valueValidLint: LinterMeta = {
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintOpenAPIPathTemplateValid',
marker: 'value',
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
conditions: [
{
function: 'apilintOpenAPIPathTemplateWellFormed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI } from '../../target-specs';
import { OpenAPI2, OpenAPI3 } from '../../target-specs';

const valueWellFormedLint: LinterMeta = {
code: ApilintCodes.OPENAPI2_PATH_TEMPLATE_VALUE_WELL_FORMED,
Expand All @@ -12,7 +12,7 @@ const valueWellFormedLint: LinterMeta = {
linterFunction: 'apilintOpenAPIPathTemplateWellFormed',
linterParams: [false],
marker: 'value',
targetSpecs: OpenAPI,
targetSpecs: [...OpenAPI2, ...OpenAPI3],
};

export default valueWellFormedLint;
2 changes: 0 additions & 2 deletions packages/apidom-ls/src/config/openapi/target-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ export const OpenAPI303 = [{ namespace: 'openapi', version: '3.0.3' }];
export const OpenAPI30 = [...OpenAPI300, ...OpenAPI301, ...OpenAPI302, ...OpenAPI303];
export const OpenAPI31 = [{ namespace: 'openapi', version: '3.1.0' }];
export const OpenAPI3 = [...OpenAPI30, ...OpenAPI31];

export const OpenAPI = [...OpenAPI2, ...OpenAPI3];

0 comments on commit 446ffd3

Please sign in to comment.