Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import {
ApidomCompletionItem,
CompletionFormat,
CompletionType,
} from '../../../../../../apidom-language-types.ts';

const completion: ApidomCompletionItem[] = [
{
label: 'destination',
insertText: 'destination',
kind: 14,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'**Optional**, defaults to the channel name. The destination (queue or exchange) name for this channel. SHOULD only be specified if the channel name differs from the actual destination name, such as when the channel name is not a valid destination name in Anypoint MQ.',
},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
{
label: 'destinationType',
insertText: 'destinationType',
kind: 14,
format: CompletionFormat.QUOTED,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'**Optional**, defaults to `queue`. The type of destination, which MUST be either `exchange` or `queue` or `fifo-queue`. SHOULD be specified to document the messaging model (publish/subscribe, point-to-point, strict message ordering) supported by this channel.',
},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
{
target: 'destinationType',
label: 'destinationType',
insertText: 'exchange',
kind: 12,
format: CompletionFormat.QUOTED,
type: CompletionType.VALUE,
insertTextFormat: 2,
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
{
target: 'destinationType',
label: 'destinationType',
insertText: 'queue',
kind: 12,
format: CompletionFormat.QUOTED,
type: CompletionType.VALUE,
insertTextFormat: 2,
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
{
target: 'destinationType',
label: 'destinationType',
insertText: 'fifo-queue',
kind: 12,
format: CompletionFormat.QUOTED,
type: CompletionType.VALUE,
insertTextFormat: 2,
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
];

export default completion;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import completion0_0_1Items from './0-0-1.ts';
import completion0_1_0Items from './0-1-0.ts';
import completionLatestItems from './latest.ts';
import {
ApidomCompletionItem,
Expand All @@ -8,6 +9,7 @@ import {

const completion: ApidomCompletionItem[] = [
...completion0_0_1Items,
...completion0_1_0Items,
...completionLatestItems,
{
label: 'bindingVersion',
Expand All @@ -18,7 +20,7 @@ const completion: ApidomCompletionItem[] = [
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value: '**Optional**, defaults to `0.0.1`. The version of this binding.',
value: '**Optional**, defaults to `0.1.0`. The version of this binding.',
},
},
{
Expand All @@ -30,6 +32,15 @@ const completion: ApidomCompletionItem[] = [
type: CompletionType.VALUE,
insertTextFormat: 2,
},
{
target: 'bindingVersion',
label: '0.1.0',
insertText: '0.1.0',
kind: 12,
format: CompletionFormat.QUOTED_FORCED,
type: CompletionType.VALUE,
insertTextFormat: 2,
},
];

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

import ApilintCodes from '../../../../../../codes.ts';
import { LinterMeta } from '../../../../../../../apidom-language-types.ts';

const allowedFieldsLint: LinterMeta = {
code: ApilintCodes.NOT_ALLOWED_FIELDS,
source: 'apilint',
message: 'Object includes not allowed fields',
severity: DiagnosticSeverity.Error,
linterFunction: 'allowedFields',
linterParams: [['destination', 'destinationType', 'bindingVersion']],
marker: 'key',
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
};

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

import ApilintCodes from '../../../../../../codes.ts';
import { LinterMeta } from '../../../../../../../apidom-language-types.ts';

const destinationTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_ANYPOINTMQ_CHANNEL_BINDING_FIELD_DESTINATION_TYPE,
source: 'apilint',
message: "'destination' value must be a string",
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintType',
linterParams: ['string'],
marker: 'value',
target: 'destination',
data: {},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
};

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

import ApilintCodes from '../../../../../../codes.ts';
import { LinterMeta } from '../../../../../../../apidom-language-types.ts';

const destinationTypeTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_ANYPOINTMQ_CHANNEL_BINDING_FIELD_DESTINATION_TYPE_TYPE,
source: 'apilint',
message: "'destinationType' value must be a string",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be stricter with this rule since the description says? The type of destination, which MUST be either exchange or queue or fifo-queue

severity: DiagnosticSeverity.Error,
linterFunction: 'apilintType',
linterParams: ['string'],
marker: 'value',
target: 'destinationType',
data: {},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
};

export default destinationTypeTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import allowedFieldsLint from './allowed-fields.ts';
import destinationTypeLint from './destination--type.ts';
import destinationTypeTypeLint from './destination-type--type.ts';

const lints = [destinationTypeLint, destinationTypeTypeLint, allowedFieldsLint];

export default lints;
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import channelBinding0_0_1Lints from './0-0-1/index.ts';
import channelBinding0_1_0Lints from './0-1-0/index.ts';
import channelBindingLatestLints from './latest/index.ts';
import bindingVersionTypeLint from './binding-version--type.ts';

const lints = [...channelBinding0_0_1Lints, ...channelBindingLatestLints, bindingVersionTypeLint];
const lints = [
...channelBinding0_0_1Lints,
...channelBinding0_1_0Lints,
...channelBindingLatestLints,
bindingVersionTypeLint,
];

export default lints;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
ApidomCompletionItem,
CompletionFormat,
CompletionType,
} from '../../../../../../apidom-language-types.ts';

const completion: ApidomCompletionItem[] = [
{
label: 'headers',
insertText: 'headers',
kind: 14,
format: CompletionFormat.OBJECT,
type: CompletionType.PROPERTY,
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value:
'[Schema object](https://www.asyncapi.com/docs/reference/specification/v2.6.0#schemaObject)\n\\\n\\\n**Optional**. A Schema object containing the definitions for Anypoint MQ-specific headers (so-called protocol headers). This schema MUST be of type `object` and have a `properties` key. Examples of Anypoint MQ protocol headers are `messageId` and `messageGroupId`.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong version would be showed for other asyncapi specs :/
could you create an issue for supporting dynamic version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just add targetSpec and separate the rule for 3.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, we could, but we would have to do this also for async 3.1 soon even though the rule will be the same. 🤔

Copy link
Contributor Author

@glowcloud glowcloud Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in general we use the latest spec for the major version, unless some fields have changed 🤔
For targeting minor versions - we probably need to go through each element to update them in that case 😔

},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
},
];

export default completion;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import completion0_0_1Items from './0-0-1.ts';
import completion0_1_0Items from './0-1-0.ts';
import completionLatestItems from './latest.ts';
import {
ApidomCompletionItem,
Expand All @@ -8,6 +9,7 @@ import {

const completion: ApidomCompletionItem[] = [
...completion0_0_1Items,
...completion0_1_0Items,
...completionLatestItems,
{
label: 'bindingVersion',
Expand All @@ -18,7 +20,7 @@ const completion: ApidomCompletionItem[] = [
insertTextFormat: 2,
documentation: {
kind: 'markdown',
value: '**Optional**, defaults to `0.0.1`. The version of this binding.',
value: '**Optional**, defaults to `0.1.0`. The version of this binding.',
},
},
{
Expand All @@ -30,6 +32,15 @@ const completion: ApidomCompletionItem[] = [
type: CompletionType.VALUE,
insertTextFormat: 2,
},
{
target: 'bindingVersion',
label: '0.1.0',
insertText: '0.1.0',
kind: 12,
format: CompletionFormat.QUOTED_FORCED,
type: CompletionType.VALUE,
insertTextFormat: 2,
},
];

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

import ApilintCodes from '../../../../../../codes.ts';
import { LinterMeta } from '../../../../../../../apidom-language-types.ts';

const allowedFieldsLint: LinterMeta = {
code: ApilintCodes.NOT_ALLOWED_FIELDS,
source: 'apilint',
message: 'Object includes not allowed fields',
severity: DiagnosticSeverity.Error,
linterFunction: 'allowedFields',
linterParams: [['headers', 'bindingVersion']],
marker: 'key',
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
};

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

import ApilintCodes from '../../../../../../codes.ts';
import { LinterMeta } from '../../../../../../../apidom-language-types.ts';

const headersTypeLint: LinterMeta = {
code: ApilintCodes.ASYNCAPI2_ANYPOINTMQ_MESSAGE_BINDING_FIELD_HEADERS_TYPE,
source: 'apilint',
message: 'headers must be an object or a boolean JSON schema',
severity: DiagnosticSeverity.Error,
linterFunction: 'apilintElementOrClass',
linterParams: [['schema', 'boolean']],
marker: 'value',
target: 'headers',
data: {},
conditions: [
{
targets: [{ path: 'bindingVersion' }],
function: 'apilintValueOrArray',
params: [['0.1.0']],
},
],
};

export default headersTypeLint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import allowedFieldsLint from './allowed-fields.ts';
import headersTypeLint from './headers--type.ts';

const lints = [allowedFieldsLint, headersTypeLint];

export default lints;
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import messageBinding0_0_1Lints from './0-0-1/index.ts';
import messageBinding0_1_0Lints from './0-1-0/index.ts';
import messageBindingLatestLints from './latest/index.ts';
import bindingVersionTypeLint from './binding-version--type.ts';

const lints = [...messageBinding0_0_1Lints, ...messageBindingLatestLints, bindingVersionTypeLint];
const lints = [
...messageBinding0_0_1Lints,
...messageBinding0_1_0Lints,
...messageBindingLatestLints,
bindingVersionTypeLint,
];

export default lints;
Loading