diff --git a/packages/apidom-ns-asyncapi-2/src/elements/nces/ChannelItemsServers.ts b/packages/apidom-ns-asyncapi-2/src/elements/nces/ChannelItemsServers.ts new file mode 100644 index 0000000000..a0708bb07f --- /dev/null +++ b/packages/apidom-ns-asyncapi-2/src/elements/nces/ChannelItemsServers.ts @@ -0,0 +1,13 @@ +import { Attributes, Meta } from 'minim'; +import { ArrayElement } from '@swagger-api/apidom-core'; + +class ChannelItemServers extends ArrayElement { + static primaryClass = 'channel-item-server-names-list'; + + constructor(content?: Array, meta?: Meta, attributes?: Attributes) { + super(content, meta, attributes); + this.classes.push(ChannelItemServers.primaryClass); + } +} + +export default ChannelItemServers; diff --git a/packages/apidom-ns-asyncapi-2/src/elements/nces/OAuthFlowScopes.ts b/packages/apidom-ns-asyncapi-2/src/elements/nces/OAuthFlowScopes.ts new file mode 100644 index 0000000000..63ce82eab7 --- /dev/null +++ b/packages/apidom-ns-asyncapi-2/src/elements/nces/OAuthFlowScopes.ts @@ -0,0 +1,13 @@ +import { Attributes, Meta } from 'minim'; +import { ObjectElement } from '@swagger-api/apidom-core'; + +class OAuthFlowScopes extends ObjectElement { + static primaryClass = 'oauth-flow-scopes'; + + constructor(content?: Record, meta?: Meta, attributes?: Attributes) { + super(content, meta, attributes); + this.classes.push(OAuthFlowScopes.primaryClass); + } +} + +export default OAuthFlowScopes; diff --git a/packages/apidom-ns-asyncapi-2/src/elements/nces/OperationTraits.ts b/packages/apidom-ns-asyncapi-2/src/elements/nces/OperationTraits.ts new file mode 100644 index 0000000000..b9816e3e22 --- /dev/null +++ b/packages/apidom-ns-asyncapi-2/src/elements/nces/OperationTraits.ts @@ -0,0 +1,13 @@ +import { Attributes, Meta } from 'minim'; +import { ArrayElement } from '@swagger-api/apidom-core'; + +class OperationTraits extends ArrayElement { + static primaryClass = 'operation-traits'; + + constructor(content?: Array, meta?: Meta, attributes?: Attributes) { + super(content, meta, attributes); + this.classes.push(OperationTraits.primaryClass); + } +} + +export default OperationTraits; diff --git a/packages/apidom-ns-asyncapi-2/src/elements/nces/ServerVariables.ts b/packages/apidom-ns-asyncapi-2/src/elements/nces/ServerVariables.ts new file mode 100644 index 0000000000..13b40266cf --- /dev/null +++ b/packages/apidom-ns-asyncapi-2/src/elements/nces/ServerVariables.ts @@ -0,0 +1,13 @@ +import { Attributes, Meta } from 'minim'; +import { ObjectElement } from '@swagger-api/apidom-core'; + +class ServerVariables extends ObjectElement { + static primaryClass = 'server-variables'; + + constructor(content?: Record, meta?: Meta, attributes?: Attributes) { + super(content, meta, attributes); + this.classes.push(ServerVariables.primaryClass); + } +} + +export default ServerVariables; diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts b/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts index fca0bfaf19..c823a5a2e2 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/plugins/replace-empty-element.ts @@ -1,7 +1,7 @@ -import { mergeAll, test } from 'ramda'; import { - ObjectElement, MemberElement, + ObjectElement, + ArrayElement, isStringElement, includesClasses, } from '@swagger-api/apidom-core'; @@ -21,6 +21,7 @@ import ExternalDocumentationElement from '../../elements/ExternalDocumentation'; import ContactElement from '../../elements/Contact'; import LicenseElement from '../../elements/License'; import ServerElement from '../../elements/Server'; +import ServerVariableElement from '../../elements/ServerVariable'; import ChannelItemElement from '../../elements/ChannelItem'; import SchemaElement from '../../elements/Schema'; import MessageElement from '../../elements/Message'; @@ -33,6 +34,91 @@ import ServerBindingsElement from '../../elements/ServerBindings'; import ChannelBindingsElement from '../../elements/ChannelBindings'; import OperationBindingsElement from '../../elements/OperationBindings'; import MessageBindingsElement from '../../elements/MessageBindings'; +import OAuthFlowsElement from '../../elements/OAuthFlows'; +import OAuthFlowElement from '../../elements/OAuthFlow'; +import OperationElement from '../../elements/Operation'; +/** + * Binding elements. + */ +// AMQP 0-9-1 +import AmqpChannelBindingElement from '../../elements/bindings/amqp/AmqpChannelBinding'; +import AmqpMessageBindingElement from '../../elements/bindings/amqp/AmqpMessageBinding'; +import AmqpOperationBindingElement from '../../elements/bindings/amqp/AmqpOperationBinding'; +import AmqpServerBindingElement from '../../elements/bindings/amqp/AmqpServerBinding'; +// AMQP 1.0 +import Amqp1ChannelBindingElement from '../../elements/bindings/amqp1/Amqp1ChannelBinding'; +import Amqp1MessageBindingElement from '../../elements/bindings/amqp1/Amqp1MessageBinding'; +import Amqp1OperationBindingElement from '../../elements/bindings/amqp1/Amqp1OperationBinding'; +import Amqp1ServerBindingElement from '../../elements/bindings/amqp1/Amqp1ServerBinding'; +// HTTP +import HttpChannelBindingElement from '../../elements/bindings/http/HttpChannelBinding'; +import HttpMessageBindingElement from '../../elements/bindings/http/HttpMessageBinding'; +import HttpOperationBindingElement from '../../elements/bindings/http/HttpOperationBinding'; +import HttpServerBindingElement from '../../elements/bindings/http/HttpServerBinding'; +// IBM MQ +import IbmmqChannelBindingElement from '../../elements/bindings/ibmmq/IbmmqChannelBinding'; +import IbmmqMessageBindingElement from '../../elements/bindings/ibmmq/IbmmqMessageBinding'; +import IbmmqServerBindingElement from '../../elements/bindings/ibmmq/IbmmqServerBinding'; +// JMS +import JmsChannelBindingElement from '../../elements/bindings/jms/JmsChannelBinding'; +import JmsMessageBindingElement from '../../elements/bindings/jms/JmsMessageBinding'; +import JmsOperationBindingElement from '../../elements/bindings/jms/JmsOperationBinding'; +import JmsServerBindingElement from '../../elements/bindings/jms/JmsServerBinding'; +// Kafka +import KafkaChannelBindingElement from '../../elements/bindings/kafka/KafkaChannelBinding'; +import KafkaMessageBindingElement from '../../elements/bindings/kafka/KafkaMessageBinding'; +import KafkaOperationBindingElement from '../../elements/bindings/kafka/KafkaOperationBinding'; +import KafkaServerBindingElement from '../../elements/bindings/kafka/KafkaServerBinding'; +// Anypoint MQ +import AnypointmqChannelBindingElement from '../../elements/bindings/anypointmq/AnypointmqChannelBinding'; +import AnypointmqMessageBindingElement from '../../elements/bindings/anypointmq/AnypointmqMessageBinding'; +import AnypointmqOperationBindingElement from '../../elements/bindings/anypointmq/AnypointmqOperationBinding'; +import AnypointmqServerBindingElement from '../../elements/bindings/anypointmq/AnypointmqServerBinding'; +// Mercure +import MercureChannelBindingElement from '../../elements/bindings/mercure/MercureChannelBinding'; +import MercureMessageBindingElement from '../../elements/bindings/mercure/MercureMessageBinding'; +import MercureOperationBindingElement from '../../elements/bindings/mercure/MercureOperationBinding'; +import MercureServerBindingElement from '../../elements/bindings/mercure/MercureServerBinding'; +// MQTT +import MqttChannelBindingElement from '../../elements/bindings/mqtt/MqttChannelBinding'; +import MqttMessageBindingElement from '../../elements/bindings/mqtt/MqttMessageBinding'; +import MqttOperationBindingElement from '../../elements/bindings/mqtt/MqttOperationBinding'; +import MqttServerBindingElement from '../../elements/bindings/mqtt/MqttServerBinding'; +// MQTT 5 +import Mqtt5ChannelBindingElement from '../../elements/bindings/mqtt5/Mqtt5ChannelBinding'; +import Mqtt5MessageBindingElement from '../../elements/bindings/mqtt5/Mqtt5MessageBinding'; +import Mqtt5OperationBindingElement from '../../elements/bindings/mqtt5/Mqtt5OperationBinding'; +import Mqtt5ServerBindingElement from '../../elements/bindings/mqtt5/Mqtt5ServerBinding'; +// NATS +import NatsChannelBindingElement from '../../elements/bindings/nats/NatsChannelBinding'; +import NatsMessageBindingElement from '../../elements/bindings/nats/NatsMessageBinding'; +import NatsOperationBindingElement from '../../elements/bindings/nats/NatsOperationBinding'; +import NatsServerBindingElement from '../../elements/bindings/nats/NatsServerBinding'; +// Redis +import RedisChannelBindingElement from '../../elements/bindings/redis/RedisChannelBinding'; +import RedisMessageBindingElement from '../../elements/bindings/redis/RedisMessageBinding'; +import RedisOperationBindingElement from '../../elements/bindings/redis/RedisOperationBinding'; +import RedisServerBindingElement from '../../elements/bindings/redis/RedisServerBinding'; +// SNS +import SnsChannelBindingElement from '../../elements/bindings/sns/SnsChannelBinding'; +import SnsMessageBindingElement from '../../elements/bindings/sns/SnsMessageBinding'; +import SnsOperationBindingElement from '../../elements/bindings/sns/SnsOperationBinding'; +import SnsServerBindingElement from '../../elements/bindings/sns/SnsServerBinding'; +// SQS +import SqsChannelBindingElement from '../../elements/bindings/sqs/SqsChannelBinding'; +import SqsMessageBindingElement from '../../elements/bindings/sqs/SqsMessageBinding'; +import SqsOperationBindingElement from '../../elements/bindings/sqs/SqsOperationBinding'; +import SqsServerBindingElement from '../../elements/bindings/sqs/SqsServerBinding'; +// STOMP +import StompChannelBindingElement from '../../elements/bindings/stomp/StompChannelBinding'; +import StompMessageBindingElement from '../../elements/bindings/stomp/StompMessageBinding'; +import StompOperationBindingElement from '../../elements/bindings/stomp/StompOperationBinding'; +import StompServerBindingElement from '../../elements/bindings/stomp/StompServerBinding'; +// WebSocket +import WebSocketChannelBindingElement from '../../elements/bindings/ws/WebSocketChannelBinding'; +import WebSocketMessageBindingElement from '../../elements/bindings/ws/WebSocketMessageBinding'; +import WebSocketOperationBindingElement from '../../elements/bindings/ws/WebSocketOperationBinding'; +import WebSocketServerBindingElement from '../../elements/bindings/ws/WebSocketServerBinding'; // non-concrete Elements (NCEs) import ComponentsSchemasElement from '../../elements/nces/ComponentsSchemas'; import ComponentsMessagesElement from '../../elements/nces/ComponentsMessages'; @@ -45,6 +131,11 @@ import ComponentsServerBindingsElement from '../../elements/nces/ComponentsServe import ComponentsChannelBindingsElement from '../../elements/nces/ComponentsChannelBindings'; import ComponentsOperationBindingsElement from '../../elements/nces/ComponentsOperationBindings'; import ComponentsMessageBindingsElement from '../../elements/nces/ComponentsMessageBindings'; +import ServerVariablesElement from '../../elements/nces/ServerVariables'; +import ChannelItemServersElement from '../../elements/nces/ChannelItemsServers'; +import OAuthFlowScopesElement from '../../elements/nces/OAuthFlowScopes'; +import OperationTraitsElement from '../../elements/nces/OperationTraits'; +import { getNodeType } from '../../traversal/visitor'; /** * This plugin is specific to YAML 1.2 format, which allows defining key-value pairs @@ -103,9 +194,35 @@ const schema = { ServersElement: { '*': () => new ServerElement(), }, + ServerElement: { + variables: () => new ServerVariablesElement(), + security: () => new ArrayElement(), + bindings: () => new ServerBindingsElement(), + }, + ServerVariableElement: { + enum: () => new ArrayElement(), + examples: () => new ArrayElement(), + }, + SecurityRequirementElement: { + '*': () => new ArrayElement(), + }, ChannelsElement: { '*': () => new ChannelItemElement(), }, + ChannelItemElement: { + servers: () => new ChannelItemServersElement(), + subscribe: () => new OperationElement(), + publish: () => new OperationElement(), + parameters: () => new ParameterElement(), + bindings: () => new ChannelBindingsElement(), + }, + OperationElement: { + tags: () => new TagsElement(), + externalDocs: () => new ExternalDocumentationElement(), + bindings: () => new OperationBindingsElement(), + traits: () => new OperationTraitsElement(), + message: () => new MessageElement(), + }, ComponentsElement: { schemas: () => new ComponentsSchemasElement(), messages: () => new ComponentsMessagesElement(), @@ -119,6 +236,145 @@ const schema = { operationBindings: () => new ComponentsOperationBindingsElement(), messageBindings: () => new ComponentsMessageBindingsElement(), }, + TagElement: { + externalDocs: () => new ExternalDocumentationElement(), + }, + MessageElement: { + headers: () => new SchemaElement(), + correlationId: () => new CorrelationIDElement(), + tags: () => new TagsElement(), + externalDocs: () => new ExternalDocumentationElement(), + bindings: () => new MessageBindingsElement(), + examples: () => new ArrayElement(), + traits: () => new ArrayElement(), + }, + SecuritySchemeElement: { + flows: () => new OAuthFlowsElement(), + }, + OAuthFlowsElement: { + implicit: () => new OAuthFlowElement(), + password: () => new OAuthFlowElement(), + clientCredentials: () => new OAuthFlowElement(), + authorizationCode: () => new OAuthFlowElement(), + }, + OAuthFlow: { + scopes: () => new OAuthFlowScopesElement(), + }, + ParametersElement: { + '*': () => new ParameterElement(), + }, + ParameterElement: { + schema: () => new SchemaElement(), + }, + OperationTraitElement: { + tags: () => new TagsElement(), + externalDocs: () => new ExternalDocumentationElement(), + bindings: () => new OperationBindingsElement(), + }, + MessageTraitElement: { + headers: () => new SchemaElement(), + correlationId: () => new CorrelationIDElement(), + tags: () => new TagsElement(), + externalDocs: () => new ExternalDocumentationElement(), + bindings: () => new MessageBindingsElement(), + examples: () => new ArrayElement(), + }, + MessageExampleElement: { + headers: () => new ObjectElement(), + }, + OperationBindingsElement: { + http: () => new HttpOperationBindingElement(), + ws: () => new WebSocketOperationBindingElement(), + kafka: () => new KafkaOperationBindingElement(), + anypointmq: () => new AnypointmqOperationBindingElement(), + amqp: () => new AmqpOperationBindingElement(), + amqp1: () => new Amqp1OperationBindingElement(), + mqtt: () => new MqttOperationBindingElement(), + mqtt5: () => new Mqtt5OperationBindingElement(), + nats: () => new NatsOperationBindingElement(), + jms: () => new JmsOperationBindingElement(), + sns: () => new SnsOperationBindingElement(), + sqs: () => new SqsOperationBindingElement(), + stomp: () => new StompOperationBindingElement(), + redis: () => new RedisOperationBindingElement(), + mercure: () => new MercureOperationBindingElement(), + }, + MessageBindingsElement: { + http: () => new HttpMessageBindingElement(), + ws: () => new WebSocketMessageBindingElement(), + kafka: () => new KafkaMessageBindingElement(), + anypointmq: () => new AnypointmqMessageBindingElement(), + amqp: () => new AmqpMessageBindingElement(), + amqp1: () => new Amqp1MessageBindingElement(), + mqtt: () => new MqttMessageBindingElement(), + mqtt5: () => new Mqtt5MessageBindingElement(), + nats: () => new NatsMessageBindingElement(), + jms: () => new JmsMessageBindingElement(), + sns: () => new SnsMessageBindingElement(), + sqs: () => new SqsMessageBindingElement(), + stomp: () => new StompMessageBindingElement(), + redis: () => new RedisMessageBindingElement(), + mercure: () => new MercureMessageBindingElement(), + ibmmq: () => new IbmmqMessageBindingElement(), + }, + ServerBindingsElement: { + http: () => new HttpServerBindingElement(), + ws: () => new WebSocketServerBindingElement(), + kafka: () => new KafkaServerBindingElement(), + anypointmq: () => new AnypointmqServerBindingElement(), + amqp: () => new AmqpServerBindingElement(), + amqp1: () => new Amqp1ServerBindingElement(), + mqtt: () => new MqttServerBindingElement(), + mqtt5: () => new Mqtt5ServerBindingElement(), + nats: () => new NatsServerBindingElement(), + jms: () => new JmsServerBindingElement(), + sns: () => new SnsServerBindingElement(), + sqs: () => new SqsServerBindingElement(), + stomp: () => new StompServerBindingElement(), + redis: () => new RedisServerBindingElement(), + mercure: () => new MercureServerBindingElement(), + ibmmq: () => new IbmmqServerBindingElement(), + }, + ChannelBindingsElement: { + http: () => new HttpChannelBindingElement(), + ws: () => new WebSocketChannelBindingElement(), + kafka: () => new KafkaChannelBindingElement(), + anypointmq: () => new AnypointmqChannelBindingElement(), + amqp: () => new AmqpChannelBindingElement(), + amqp1: () => new Amqp1ChannelBindingElement(), + mqtt: () => new MqttChannelBindingElement(), + mqtt5: () => new Mqtt5ChannelBindingElement(), + nats: () => new NatsChannelBindingElement(), + jms: () => new JmsChannelBindingElement(), + sns: () => new SnsChannelBindingElement(), + sqs: () => new SqsChannelBindingElement(), + stomp: () => new StompChannelBindingElement(), + redis: () => new RedisChannelBindingElement(), + mercure: () => new MercureChannelBindingElement(), + ibmmq: () => new IbmmqChannelBindingElement(), + }, + SchemaElement: { + allOf: () => new ArrayElement([], { classes: ['json-schema-allOf'] }), + anyOf: () => new ArrayElement([], { classes: ['json-schema-anyOf'] }), + oneOf: () => new ArrayElement([], { classes: ['json-schema-oneOf'] }), + not: () => new SchemaElement(), + if: () => new SchemaElement(), + then: () => new SchemaElement(), + else: () => new SchemaElement(), + enum: () => new ArrayElement(), + items: () => new SchemaElement(), + additionalItems: () => new SchemaElement(), + containsProp: () => new SchemaElement(), + required: () => new ArrayElement([], { classes: ['json-schema-required'] }), + properties: () => new ObjectElement({}, { classes: ['json-schema-properties'] }), + patternProperties: () => new ObjectElement({}, { classes: ['json-schema-patternProperties'] }), + additionalProperties: () => new SchemaElement(), + dependencies: () => new ObjectElement({}, { classes: ['json-schema-dependencies'] }), + propertyNames: () => new SchemaElement(), + examples: () => new ArrayElement([], { classes: ['json-schema-examples'] }), + definitions: () => new ObjectElement({}, { classes: ['json-schema-definitions'] }), + externalDocs: () => new ExternalDocumentationElement(), + }, // non-concrete types handling (NCEs) [ComponentsSchemasElement.primaryClass]: { '*': () => new SchemaElement(), @@ -153,108 +409,45 @@ const schema = { [ComponentsMessageBindingsElement.primaryClass]: { '*': () => new MessageBindingsElement(), }, + [ServerVariablesElement.primaryClass]: { + '*': () => new ServerVariableElement(), + }, }; -const replaceEmptyValues = (type: string, element: T) => { - const members: MemberElement[] = []; - let hasEmptyElement = false; - - element.forEach((value, key, member) => { - if (!isEmptyElement(value)) { - // @ts-ignore - members.push(member); - return; - } +const findElementFactory = (ancestor: any, element: MemberElement) => { + const elementType = getNodeType(ancestor); // @ts-ignore + const keyName = element.key.toValue(); // @ts-ignore + const keyMapping = schema[elementType] || schema[ancestor.classes.first?.toValue?.()]; - // @ts-ignore - const elementFactory = Object.prototype.hasOwnProperty.call(schema[type], '*') - ? // @ts-ignore - schema[type]['*'] - : // @ts-ignore - schema[type][key.toValue()]; - - if (typeof elementFactory !== 'function') { - // @ts-ignore - members.push(member); - return; - } - - const newMember = new MemberElement( - // @ts-ignore - member.key, - elementFactory(), - member.meta.clone(), - member.attributes.clone(), - ); - - hasEmptyElement = true; - members.push(newMember); - }); - - if (hasEmptyElement) { - // shallow clone of the element - // @ts-ignore - return new element.constructor(members, element.meta.clone(), element.attributes.clone()); - } - - return undefined; + return typeof keyMapping === 'undefined' + ? undefined + : Object.prototype.hasOwnProperty.call(keyMapping, '*') + ? keyMapping['*'] + : keyMapping[keyName]; }; const plugin = () => () => { - const ceVisitor = Object.keys(schema) - .filter(test(/^[A-Z]/)) // concrete Elements starts with uppercase letters - .map((elementType) => ({ - [elementType](element: ObjectElement) { - return replaceEmptyValues(elementType, element); - }, - })); - const nctVisitor = { - ObjectElement(element: ObjectElement) { - // skip the chain of following checks - if (element.classes.length === 0) { - return undefined; - } + return { + visitor: { + MemberElement(element: MemberElement, ...rest: any) { + // no empty Element, continue with next one + if (!isEmptyElement(element.value)) return undefined; - if (element.classes.includes(ComponentsSchemasElement.primaryClass)) { - return replaceEmptyValues(ComponentsSchemasElement.primaryClass, element); - } - if (element.classes.includes(ComponentsMessagesElement.primaryClass)) { - return replaceEmptyValues(ComponentsMessagesElement.primaryClass, element); - } - if (element.classes.includes(ComponentsSecuritySchemesElement.primaryClass)) { - return replaceEmptyValues(ComponentsSecuritySchemesElement.primaryClass, element); - } - if (element.classes.includes(ComponentsParametersElement.primaryClass)) { - return replaceEmptyValues(ComponentsParametersElement.primaryClass, element); - } - if (element.classes.includes(ComponentsCorrelationIDsElement.primaryClass)) { - return replaceEmptyValues(ComponentsCorrelationIDsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsOperationTraitsElement.primaryClass)) { - return replaceEmptyValues(ComponentsOperationTraitsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsMessageTraitsElement.primaryClass)) { - return replaceEmptyValues(ComponentsMessageTraitsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsServerBindingsElement.primaryClass)) { - return replaceEmptyValues(ComponentsServerBindingsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsChannelBindingsElement.primaryClass)) { - return replaceEmptyValues(ComponentsChannelBindingsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsOperationBindingsElement.primaryClass)) { - return replaceEmptyValues(ComponentsOperationBindingsElement.primaryClass, element); - } - if (element.classes.includes(ComponentsMessageBindingsElement.primaryClass)) { - return replaceEmptyValues(ComponentsMessageBindingsElement.primaryClass, element); - } + const [, , , ancestors] = rest; + const ancestor = ancestors[ancestors.length - 1]; + const elementFactory = findElementFactory(ancestor, element); - return undefined; - }, - }; + // no element factory found + if (typeof elementFactory === 'undefined') return undefined; - return { - visitor: { ...mergeAll(ceVisitor), ...nctVisitor }, + return new MemberElement( + element.key, + elementFactory(), + element.meta.clone(), + element.attributes.clone(), + ); + }, + }, }; }; diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/channel-item/ServersVisitor.ts b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/channel-item/ServersVisitor.ts index 1d697a12a8..dbeecb85af 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/channel-item/ServersVisitor.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/channel-item/ServersVisitor.ts @@ -1,13 +1,13 @@ import stampit from 'stampit'; import { ArrayElement, Element, isStringElement, BREAK } from '@swagger-api/apidom-core'; +import ChannelItemServersElement from '../../../../elements/nces/ChannelItemsServers'; import SpecificationVisitor from '../../SpecificationVisitor'; import FallbackVisitor from '../../FallbackVisitor'; const ServersVisitor = stampit(SpecificationVisitor, FallbackVisitor, { init() { - this.element = new ArrayElement(); - this.element.classes.push('channel-item-server-names-list'); + this.element = new ChannelItemServersElement(); }, methods: { ArrayElement(arrayElement: ArrayElement) { diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/oauth-flow/ScopesVisitor.ts b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/oauth-flow/ScopesVisitor.ts index 4fe48f67e6..d816a5b9cb 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/oauth-flow/ScopesVisitor.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/oauth-flow/ScopesVisitor.ts @@ -1,7 +1,7 @@ import stampit from 'stampit'; import { always } from 'ramda'; -import { ObjectElement } from '@swagger-api/apidom-core'; +import OAuthFlowScopesElement from '../../../../elements/nces/OAuthFlowScopes'; import MapVisitor from '../../generics/MapVisitor'; import FallbackVisitor from '../../FallbackVisitor'; @@ -10,8 +10,7 @@ const ScopesVisitor = stampit(MapVisitor, FallbackVisitor, { specPath: always(['value']), }, init() { - this.element = new ObjectElement(); - this.element.classes.push('oauth-flow-scopes'); + this.element = new OAuthFlowScopesElement(); }, }); diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/operation/TraitsVisitor.ts b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/operation/TraitsVisitor.ts index e3ad7f9ad0..366d947f6a 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/operation/TraitsVisitor.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/operation/TraitsVisitor.ts @@ -1,14 +1,14 @@ import stampit from 'stampit'; import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core'; +import OperationTraitsElement from '../../../../elements/nces/OperationTraits'; import SpecificationVisitor from '../../SpecificationVisitor'; import FallbackVisitor from '../../FallbackVisitor'; import { isReferenceLikeElement } from '../../../predicates'; const TraitsVisitor = stampit(SpecificationVisitor, FallbackVisitor, { init() { - this.element = new ArrayElement(); - this.element.classes.push('operation-traits'); + this.element = new OperationTraitsElement(); }, methods: { ArrayElement(arrayElement: ArrayElement) { diff --git a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/server/VariablesVisitor.ts b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/server/VariablesVisitor.ts index 0c9a044f7e..72200a46ce 100644 --- a/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/server/VariablesVisitor.ts +++ b/packages/apidom-ns-asyncapi-2/src/refractor/visitors/async-api-2/server/VariablesVisitor.ts @@ -1,7 +1,7 @@ import stampit from 'stampit'; import { always } from 'ramda'; -import { ObjectElement } from '@swagger-api/apidom-core'; +import ServerVariablesElement from '../../../../elements/nces/ServerVariables'; import MapVisitor from '../../generics/MapVisitor'; import FallbackVisitor from '../../FallbackVisitor'; @@ -10,8 +10,7 @@ const VariablesVisitor = stampit(MapVisitor, FallbackVisitor, { specPath: always(['document', 'objects', 'ServerVariable']), }, init() { - this.element = new ObjectElement(); - this.element.classes.push('server-variables'); + this.element = new ServerVariablesElement(); }, });