Skip to content

Commit

Permalink
feat(apidom-ls): fix schema rules for boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Jan 17, 2024
1 parent 0e921ae commit 960f590
Show file tree
Hide file tree
Showing 56 changed files with 478 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const keyTypeLint: LinterMeta = {
message: 'key must be an object (Schema or AVRO Schema)',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'key',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const keyTypeLint: LinterMeta = {
message: 'key must be an object (Schema or AVRO Schema)',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'key',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const keyTypeLint: LinterMeta = {
message: 'key must be an object (Schema or AVRO Schema)',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'key',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const keyTypeLint: LinterMeta = {
message: 'key must be an object (Schema or AVRO Schema)',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'key',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const clientIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_CLIENT_ID_TYPE,
source: 'apilint',
message: 'clientId must be an object',
message: 'clientId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'clientId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const groupIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_GROUP_ID_TYPE,
source: 'apilint',
message: 'groupId must be an object',
message: 'groupId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'groupdId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const clientIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_CLIENT_ID_TYPE,
source: 'apilint',
message: 'clientId must be an object',
message: 'clientId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'clientId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const groupIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_GROUP_ID_TYPE,
source: 'apilint',
message: 'groupId must be an object',
message: 'groupId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'groupdId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const clientIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_CLIENT_ID_TYPE,
source: 'apilint',
message: 'clientId must be an object',
message: 'clientId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'clientId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const groupIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_GROUP_ID_TYPE,
source: 'apilint',
message: 'groupId must be an object',
message: 'groupId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'groupdId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const clientIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_CLIENT_ID_TYPE,
source: 'apilint',
message: 'clientId must be an object',
message: 'clientId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'clientId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { LinterMeta } from '../../../../../../../apidom-language-types';
const groupIdTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_KAFKA_OPERATION_BINDING_FIELD_GROUP_ID_TYPE,
source: 'apilint',
message: 'groupId must be an object',
message: 'groupId must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'groupdId',
data: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const schemasValuesTypeLint: LinterMeta = {
message: '"schemas" members must be Schema object',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintChildrenOfElementsOrClasses',
linterParams: [['schema']],
linterParams: [['schema', 'boolean']],
marker: 'key',
markerTarget: 'schemas',
target: 'schemas',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LinterMeta } from '../../../../apidom-language-types';
const headersTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_MESSAGE_TRAIT_FIELD_HEADERS_TYPE,
source: 'apilint',
message: "'headers' must be a schema",
message: "'headers' must be a schema object",
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LinterMeta } from '../../../../apidom-language-types';
const headersTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_MESSAGE_FIELD_HEADERS_TYPE,
source: 'apilint',
message: "'headers' must be a schema",
message: "'headers' must be a schema object",
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const schemaTypeLint: LinterMeta = {
message: "'schema' must be a schema",
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema'],
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'schema',
data: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const additionalItemsTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_ADDITIONALITEMS,
source: 'apilint',
message: 'additionalItems must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'additionalItems',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

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

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

const additionalItemsTypeLint: LinterMeta = {
code: ApilintCodes.SCHEMA_ADDITIONALITEMS,
Expand All @@ -13,6 +14,7 @@ const additionalItemsTypeLint: LinterMeta = {
marker: 'value',
target: 'additionalItems',
data: {},
targetSpecs: [...OpenAPI2, ...OpenAPI30],
};

export default additionalItemsTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const allOfTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_ALLOF,
source: 'apilint',
message: 'allOf must be a non-empty array of schemas',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintArrayOfElementsOrClasses',
linterParams: [['schema', 'boolean'], true],
marker: 'key',
target: 'allOf',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

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

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

const allOfTypeLint: LinterMeta = {
code: ApilintCodes.SCHEMA_ALLOF,
Expand All @@ -13,6 +14,7 @@ const allOfTypeLint: LinterMeta = {
marker: 'key',
target: 'allOf',
data: {},
targetSpecs: [...OpenAPI2, ...OpenAPI30],
};

export default allOfTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const anyOfTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_ANYOF,
source: 'apilint',
message: 'anyOf must be a non-empty array of schemas',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintArrayOfElementsOrClasses',
linterParams: [['schema', 'boolean'], true],
marker: 'key',
target: 'anyOf',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

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

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

const anyOfTypeLint: LinterMeta = {
code: ApilintCodes.SCHEMA_ANYOF,
Expand All @@ -13,6 +14,7 @@ const anyOfTypeLint: LinterMeta = {
marker: 'key',
target: 'anyOf',
data: {},
targetSpecs: [...OpenAPI2, ...OpenAPI30],
};

export default anyOfTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const containsTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_CONTAINS,
source: 'apilint',
message: 'contains must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'contains',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

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

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

const containsTypeLint: LinterMeta = {
code: ApilintCodes.SCHEMA_CONTAINS,
Expand All @@ -13,6 +14,7 @@ const containsTypeLint: LinterMeta = {
marker: 'value',
target: 'contains',
data: {},
targetSpecs: [...OpenAPI2, ...OpenAPI30],
};

export default containsTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const elseTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_ELSE,
source: 'apilint',
message: '"else" must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'else',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

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

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

const elseTypeLint: LinterMeta = {
code: ApilintCodes.SCHEMA_ELSE,
Expand All @@ -13,6 +14,7 @@ const elseTypeLint: LinterMeta = {
marker: 'value',
target: 'else',
data: {},
targetSpecs: [...OpenAPI2, ...OpenAPI30],
};

export default elseTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { AsyncAPI2 } from '../../../asyncapi/target-specs';
import { OpenAPI31 } from '../../../openapi/target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const ifTypeOpenAPI3_1_AsyncAPI2Lint: LinterMeta = {
code: ApilintCodes.SCHEMA_IF,
source: 'apilint',
message: 'if must be a schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: ['schema', 'boolean'],
marker: 'value',
target: 'if',
data: {},
targetSpecs: [...OpenAPI31, ...AsyncAPI2],
};

export default ifTypeOpenAPI3_1_AsyncAPI2Lint;
Loading

0 comments on commit 960f590

Please sign in to comment.