diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/specification.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/specification.ts index 1558112279..af83795f82 100644 --- a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/specification.ts +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/specification.ts @@ -34,6 +34,7 @@ import ServerUrlVisitor from './visitors/async-api-2-0/server/UrlVisitor'; import ServerProtocolVisitor from './visitors/async-api-2-0/server/ProtocolVisitor'; import ServerProtocolVersionVisitor from './visitors/async-api-2-0/server/ProtocolVersionVisitor'; import ServerDescriptionVisitor from './visitors/async-api-2-0/server/DescriptionVisitor'; +import ServerBindingsVisitor_ from './visitors/async-api-2-0/server/BindingsVisitor'; import ServerVariablesVisitor from './visitors/async-api-2-0/server/VariablesVisitor'; import ServerSecurityVisitor from './visitors/async-api-2-0/server/SecurityVisitor'; import ServerVariableVisitor from './visitors/async-api-2-0/server-variable'; @@ -89,6 +90,7 @@ import ChannelBindingsVisitor from './visitors/async-api-2-0/channel-bindings'; import ChannelItemVisitor from './visitors/async-api-2-0/channel-item'; import ChannelItem$RefVisitor from './visitors/async-api-2-0/channel-item/$RefVisitor'; import ChannelItemDescriptionVisitor from './visitors/async-api-2-0/channel-item/DescriptionVisitor'; +import ChannelItemBindingsVisitor from './visitors/async-api-2-0/channel-item/BindingsVisitor'; import MessageBindingsVisitor from './visitors/async-api-2-0/message-bindings'; import MessageTraitVisitor from './visitors/async-api-2-0/message-trait'; import MessageTraitHeadersVisitor from './visitors/async-api-2-0/message-trait/HeadersVisitor'; @@ -325,9 +327,7 @@ const specification = { description: ServerDescriptionVisitor, variables: ServerVariablesVisitor, security: ServerSecurityVisitor, - bindings: { - $ref: '#/visitors/document/objects/ServerBindings', - }, + bindings: ServerBindingsVisitor_, }, }, ServerVariable: { @@ -359,9 +359,7 @@ const specification = { parameters: { $ref: '#/visitors/document/objects/Parameters', }, - bindings: { - $ref: '#/visitors/document/objects/ChannelBindings', - }, + bindings: ChannelItemBindingsVisitor, }, }, Operation: { diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/BindingsVisitor.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/BindingsVisitor.ts new file mode 100644 index 0000000000..b8b60697bf --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/channel-item/BindingsVisitor.ts @@ -0,0 +1,32 @@ +import stampit from 'stampit'; +import { T as stubTrue } from 'ramda'; +import { ObjectElement } from 'apidom'; + +import ReferenceElement from '../../../../elements/Reference'; +import AlternatingVisitor from '../../generics/AlternatingVisitor'; +import FallbackVisitor from '../../FallbackVisitor'; +import { isReferenceLikeElement } from '../../../predicates'; +import { isReferenceElement } from '../../../../predicates'; + +const BindingsVisitor = stampit(AlternatingVisitor, FallbackVisitor, { + props: { + alternator: [ + { predicate: isReferenceLikeElement, specPath: ['document', 'objects', 'Reference'] }, + { predicate: stubTrue, specPath: ['document', 'objects', 'ChannelBindings'] }, + ], + }, + methods: { + ObjectElement(objectElement: ObjectElement) { + // @ts-ignore + const result = AlternatingVisitor.compose.methods.ObjectElement.call(this, objectElement); + + this.element.filter(isReferenceElement).forEach((referenceElement: ReferenceElement) => { + referenceElement.setMetaProperty('referenced-element', 'channelBindings'); + }); + + return result; + }, + }, +}); + +export default BindingsVisitor; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/BindingsVisitor.ts b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/BindingsVisitor.ts new file mode 100644 index 0000000000..f94f52ab7c --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/src/refractor/visitors/async-api-2-0/server/BindingsVisitor.ts @@ -0,0 +1,32 @@ +import stampit from 'stampit'; +import { T as stubTrue } from 'ramda'; +import { ObjectElement } from 'apidom'; + +import ReferenceElement from '../../../../elements/Reference'; +import AlternatingVisitor from '../../generics/AlternatingVisitor'; +import FallbackVisitor from '../../FallbackVisitor'; +import { isReferenceLikeElement } from '../../../predicates'; +import { isReferenceElement } from '../../../../predicates'; + +const BindingsVisitor = stampit(AlternatingVisitor, FallbackVisitor, { + props: { + alternator: [ + { predicate: isReferenceLikeElement, specPath: ['document', 'objects', 'Reference'] }, + { predicate: stubTrue, specPath: ['document', 'objects', 'ServerBindings'] }, + ], + }, + methods: { + ObjectElement(objectElement: ObjectElement) { + // @ts-ignore + const result = AlternatingVisitor.compose.methods.ObjectElement.call(this, objectElement); + + this.element.filter(isReferenceElement).forEach((referenceElement: ReferenceElement) => { + referenceElement.setMetaProperty('referenced-element', 'serverBindings'); + }); + + return result; + }, + }, +}); + +export default BindingsVisitor; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..1e6380d77f --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/__snapshots__/index.ts.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements AsyncApi2_0Element should refract to semantic ApiDOM tree 1`] = ` +(AsyncApi2_0Element + (MemberElement + (StringElement) + (AsyncApiVersionElement)) + (MemberElement + (StringElement) + (IdentifierElement)) + (MemberElement + (StringElement) + (InfoElement)) + (MemberElement + (StringElement) + (ServersElement)) + (MemberElement + (StringElement) + (DefaultContentTypeElement)) + (MemberElement + (StringElement) + (ChannelsElement)) + (MemberElement + (StringElement) + (ComponentsElement)) + (MemberElement + (StringElement) + (TagsElement)) + (MemberElement + (StringElement) + (ExternalDocumentationElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/index.ts new file mode 100644 index 0000000000..e6cbef6e61 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApi2-0/index.ts @@ -0,0 +1,26 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { AsyncApi2_0Element } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('AsyncApi2_0Element', function () { + specify('should refract to semantic ApiDOM tree', function () { + const asyncApiElement = AsyncApi2_0Element.refract({ + asyncapi: '2.0.0', + id: 'urn:com:smartylighting:streetlights:server', + info: {}, + servers: {}, + defaultContentType: 'application/json', + channels: {}, + components: {}, + tags: [], + externalDocs: {}, + }); + + expect(sexprs(asyncApiElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..2ad7b45979 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/__snapshots__/index.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements AsyncApiVersionElement should refract to semantic ApiDOM tree 1`] = `(AsyncApiVersionElement)`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/index.ts new file mode 100644 index 0000000000..d1d2700e74 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/AsyncApiVersion/index.ts @@ -0,0 +1,16 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { AsyncApiVersionElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('AsyncApiVersionElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const asyncApiVersion = AsyncApiVersionElement.refract('2.0.0'); + + expect(sexprs(asyncApiVersion)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..1630d21c33 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/__snapshots__/index.ts.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ChannelItemElement given bindings field of type ChannelBindingsElement should refract to semantic ApiDOM tree 1`] = ` +(ChannelItemElement + (MemberElement + (StringElement) + (ChannelBindingsElement))) +`; + +exports[`refractor elements ChannelItemElement given bindings field of type ReferenceElement should refract to semantic ApiDOM tree 1`] = ` +(ChannelItemElement + (MemberElement + (StringElement) + (ReferenceElement + (MemberElement + (StringElement) + (StringElement))))) +`; + +exports[`refractor elements ChannelItemElement should refract to semantic ApiDOM tree 1`] = ` +(ChannelItemElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (OperationElement)) + (MemberElement + (StringElement) + (OperationElement)) + (MemberElement + (StringElement) + (ParametersElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/index.ts new file mode 100644 index 0000000000..9701b552df --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ChannelItem/index.ts @@ -0,0 +1,44 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ChannelItemElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ChannelItemElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const channelItemElement = ChannelItemElement.refract({ + $ref: '#/path/to/channel-item', + description: 'channel-item-description', + subscribe: {}, + publish: {}, + parameters: {}, + }); + + expect(sexprs(channelItemElement)).toMatchSnapshot(); + }); + + context('given bindings field of type ChannelBindingsElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const channelItemElement = ChannelItemElement.refract({ + bindings: {}, + }); + + expect(sexprs(channelItemElement)).toMatchSnapshot(); + }); + }); + + context('given bindings field of type ReferenceElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const channelItemElement = ChannelItemElement.refract({ + bindings: { + $ref: '#/path/to/bindings', + }, + }); + + expect(sexprs(channelItemElement)).toMatchSnapshot(); + }); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..6fa7811083 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/__snapshots__/index.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ChannelsElement should refract to semantic ApiDOM tree 1`] = ` +(ChannelsElement + (MemberElement + (StringElement) + (ChannelItemElement)) + (MemberElement + (StringElement) + (ChannelItemElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/index.ts new file mode 100644 index 0000000000..ca618a1fb6 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Channels/index.ts @@ -0,0 +1,19 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ChannelsElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ChannelsElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const channelsElement = ChannelsElement.refract({ + 'user/signedup': {}, + 'user/loggedout': {}, + }); + + expect(sexprs(channelsElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..ba97c975e4 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/__snapshots__/index.ts.snap @@ -0,0 +1,14 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ContactElement should refract to semantic ApiDOM tree 1`] = ` +(ContactElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/index.ts new file mode 100644 index 0000000000..751d360967 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Contact/index.ts @@ -0,0 +1,20 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ContactElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ContactElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const contactElement = ContactElement.refract({ + name: 'API Support', + url: 'http://www.asyncapi.org/support', + email: 'support@asyncapi.org', + }); + + expect(sexprs(contactElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..1cac4c9788 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/__snapshots__/index.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements DefaultContentTypeElement should refract to semantic ApiDOM tree 1`] = `(DefaultContentTypeElement)`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/index.ts new file mode 100644 index 0000000000..85325502e9 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/DefaultContentType/index.ts @@ -0,0 +1,16 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { DefaultContentTypeElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('DefaultContentTypeElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const defaultContentTypeElement = DefaultContentTypeElement.refract('application/json'); + + expect(sexprs(defaultContentTypeElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..11b1cc9a1c --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/__snapshots__/index.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements IdentifierElement should refract to semantic ApiDOM tree 1`] = `(IdentifierElement)`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/index.ts new file mode 100644 index 0000000000..8f2e66fc48 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Identifier/index.ts @@ -0,0 +1,18 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { IdentifierElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('IdentifierElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const identifierElement = IdentifierElement.refract( + 'urn:com:smartylighting:streetlights:server', + ); + + expect(sexprs(identifierElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..a492ae54ce --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/__snapshots__/index.ts.snap @@ -0,0 +1,38 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements InfoElement should refract to semantic ApiDOM tree 1`] = ` +(InfoElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ContactElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)))) + (MemberElement + (StringElement) + (LicenseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/index.ts new file mode 100644 index 0000000000..668af17f26 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Info/index.ts @@ -0,0 +1,30 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { InfoElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('InfoElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const infoElement = InfoElement.refract({ + title: 'AsyncAPI Sample App', + version: '1.0.1', + description: 'This is a sample server.', + termsOfService: 'http://asyncapi.org/terms/', + contact: { + name: 'API Support', + url: 'http://www.asyncapi.org/support', + email: 'support@asyncapi.org', + }, + license: { + name: 'Apache 2.0', + url: 'http://www.apache.org/licenses/LICENSE-2.0.html', + }, + }); + + expect(sexprs(infoElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..7118444fb3 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/__snapshots__/index.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements LicenseElement should refract to semantic ApiDOM tree 1`] = ` +(LicenseElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/index.ts new file mode 100644 index 0000000000..81999dacd1 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/License/index.ts @@ -0,0 +1,19 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { LicenseElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('LicenseElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const licenseElement = LicenseElement.refract({ + name: 'Apache 2.0', + url: 'http://www.apache.org/licenses/LICENSE-2.0.html', + }); + + expect(sexprs(licenseElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..9c3b4fc610 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/__snapshots__/index.ts.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ReferenceElement should refract to semantic ApiDOM tree 1`] = ` +(ReferenceElement + (MemberElement + (StringElement) + (StringElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/index.ts new file mode 100644 index 0000000000..b93aabcdc7 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Reference/index.ts @@ -0,0 +1,18 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ReferenceElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ReferenceElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const referenceElement = ReferenceElement.refract({ + $ref: '#/path/to/somewhere', + }); + + expect(sexprs(referenceElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..c81556ec00 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/__snapshots__/index.ts.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements SecurityRequirementElement should refract to semantic ApiDOM tree 1`] = ` +(SecurityRequirementElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/index.ts new file mode 100644 index 0000000000..311518d69e --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/SecurityRequirement/index.ts @@ -0,0 +1,18 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { SecurityRequirementElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('SecurityRequirementElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const securityRequirementElement = SecurityRequirementElement.refract({ + petstore_auth: ['write:pets', 'read:pets'], + }); + + expect(sexprs(securityRequirementElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..1dab5c1454 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/__snapshots__/index.ts.snap @@ -0,0 +1,44 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ServerElement given bindings field of type ReferenceElement should refract to semantic ApiDOM tree 1`] = ` +(ServerElement + (MemberElement + (StringElement) + (ReferenceElement + (MemberElement + (StringElement) + (StringElement))))) +`; + +exports[`refractor elements ServerElement given bindings field of type ServerBindingsElement should refract to semantic ApiDOM tree 1`] = ` +(ServerElement + (MemberElement + (StringElement) + (ServerBindingsElement))) +`; + +exports[`refractor elements ServerElement should refract to semantic ApiDOM tree 1`] = ` +(ServerElement + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ObjectElement + (MemberElement + (StringElement) + (ServerVariableElement)))) + (MemberElement + (StringElement) + (ArrayElement + (SecurityRequirementElement)))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/index.ts new file mode 100644 index 0000000000..1ec2390724 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Server/index.ts @@ -0,0 +1,47 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ServerElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ServerElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serverElement = ServerElement.refract({ + url: '{username}.gigantic-server.com', + description: 'The production API server', + protocol: 'kafka', + protocolVersion: '1.0.0', + variables: { + username: {}, + }, + security: [{}], + }); + + expect(sexprs(serverElement)).toMatchSnapshot(); + }); + + context('given bindings field of type ServerBindingsElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serverElement = ServerElement.refract({ + bindings: {}, + }); + + expect(sexprs(serverElement)).toMatchSnapshot(); + }); + }); + + context('given bindings field of type ReferenceElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serverElement = ServerElement.refract({ + bindings: { + $ref: '#/path/to/bindings', + }, + }); + + expect(sexprs(serverElement)).toMatchSnapshot(); + }); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..2083c62c8d --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/__snapshots__/index.ts.snap @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ServerBindingsElement should refract to semantic ApiDOM tree 1`] = ` +(ServerBindingsElement + (MemberElement + (StringElement) + (HttpServerBindingElement)) + (MemberElement + (StringElement) + (WebSocketServerBindingElement)) + (MemberElement + (StringElement) + (KafkaServerBindingElement)) + (MemberElement + (StringElement) + (AmqpServerBindingElement)) + (MemberElement + (StringElement) + (Amqp1ServerBindingElement)) + (MemberElement + (StringElement) + (MqttServerBindingElement)) + (MemberElement + (StringElement) + (Mqtt5ServerBindingElement)) + (MemberElement + (StringElement) + (NatsServerBindingElement)) + (MemberElement + (StringElement) + (JmsServerBindingElement)) + (MemberElement + (StringElement) + (SnsServerBindingElement)) + (MemberElement + (StringElement) + (SqsServerBindingElement)) + (MemberElement + (StringElement) + (StompServerBindingElement)) + (MemberElement + (StringElement) + (RedisServerBindingElement)) + (MemberElement + (StringElement) + (MercureServerBindingElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/index.ts new file mode 100644 index 0000000000..5200515573 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerBindings/index.ts @@ -0,0 +1,31 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ServerBindingsElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ServerBindingsElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serverBindingsElement = ServerBindingsElement.refract({ + http: {}, + ws: {}, + kafka: {}, + amqp: {}, + amqp1: {}, + mqtt: {}, + mqtt5: {}, + nats: {}, + jms: {}, + sns: {}, + sqs: {}, + stomp: {}, + redis: {}, + mercure: {}, + }); + + expect(sexprs(serverBindingsElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..bc83446d6b --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/__snapshots__/index.ts.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ServerVariableElement should refract to semantic ApiDOM tree 1`] = ` +(ServerVariableElement + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement))) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (StringElement)) + (MemberElement + (StringElement) + (ArrayElement + (StringElement) + (StringElement)))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/index.ts new file mode 100644 index 0000000000..172a73f563 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/ServerVariable/index.ts @@ -0,0 +1,21 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ServerVariableElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ServerVariableElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serverVariableElement = ServerVariableElement.refract({ + enum: ['val1', 'val2'], + default: 'val1', + description: 'server-variable-description', + examples: ['val1', 'val2'], + }); + + expect(sexprs(serverVariableElement)).toMatchSnapshot(); + }); + }); + }); +}); diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/__snapshots__/index.ts.snap b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/__snapshots__/index.ts.snap new file mode 100644 index 0000000000..c892fd7ff3 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/__snapshots__/index.ts.snap @@ -0,0 +1,14 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`refractor elements ServersElement should refract to semantic ApiDOM tree 1`] = ` +(ServersElement + (MemberElement + (StringElement) + (ServerElement)) + (MemberElement + (StringElement) + (ServerElement)) + (MemberElement + (StringElement) + (ServerElement))) +`; diff --git a/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/index.ts b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/index.ts new file mode 100644 index 0000000000..f1b53a6d43 --- /dev/null +++ b/apidom/packages/apidom-ns-asyncapi-2-0/test/refractor/elements/Servers/index.ts @@ -0,0 +1,20 @@ +import { expect } from 'chai'; +import { sexprs } from 'apidom'; + +import { ServersElement } from '../../../../src'; + +describe('refractor', function () { + context('elements', function () { + context('ServersElement', function () { + specify('should refract to semantic ApiDOM tree', function () { + const serversElement = ServersElement.refract({ + dev: {}, + staging: {}, + production: {}, + }); + + expect(sexprs(serversElement)).toMatchSnapshot(); + }); + }); + }); +});