From 86f0fd93b9a4ec1ef27dc65616b2e9262910fe10 Mon Sep 17 00:00:00 2001 From: Matatjahu Date: Tue, 4 Oct 2022 13:33:19 +0200 Subject: [PATCH] chore: add reusable tags and externalDocs and info object --- src/models/components.ts | 4 + ...rnal-docs.ts => external-documentation.ts} | 0 src/models/external-documentations.ts | 4 + src/models/index.ts | 2 +- src/models/mixins.ts | 2 +- src/models/v2/components.ts | 12 ++ ...rnal-docs.ts => external-documentation.ts} | 2 +- src/models/v2/external-documentations.ts | 10 ++ src/models/v2/index.ts | 2 +- src/models/v2/info.ts | 4 +- src/models/v2/message-trait.ts | 2 +- src/models/v2/mixins.ts | 4 +- src/models/v2/operation-trait.ts | 2 +- src/models/v2/schema.ts | 2 +- src/models/v2/tag.ts | 2 +- src/models/v3/asyncapi.ts | 2 + src/models/v3/components.ts | 133 ++++++++++++++++++ src/models/v3/contact.ts | 38 +++++ ...rnal-docs.ts => external-documentation.ts} | 4 +- src/models/v3/external-documentations.ts | 10 ++ src/models/v3/info.ts | 82 +++++++++++ src/models/v3/license.ts | 26 ++++ src/models/v3/mixins.ts | 4 +- src/models/v3/tag.ts | 4 +- src/models/v3/tags.ts | 6 +- src/spec-types/v3.ts | 108 ++++++++++++++ 26 files changed, 452 insertions(+), 19 deletions(-) rename src/models/{external-docs.ts => external-documentation.ts} (100%) create mode 100644 src/models/external-documentations.ts rename src/models/v2/{external-docs.ts => external-documentation.ts} (97%) create mode 100644 src/models/v2/external-documentations.ts create mode 100644 src/models/v3/components.ts create mode 100644 src/models/v3/contact.ts rename src/models/v3/{external-docs.ts => external-documentation.ts} (84%) create mode 100644 src/models/v3/external-documentations.ts create mode 100644 src/models/v3/info.ts create mode 100644 src/models/v3/license.ts diff --git a/src/models/components.ts b/src/models/components.ts index f96524f1e..54c201ffb 100644 --- a/src/models/components.ts +++ b/src/models/components.ts @@ -12,6 +12,8 @@ import type { MessageTraitsInterface } from './message-traits'; import type { SecuritySchemesInterface } from './security-schemes'; import type { CorrelationIdsInterface } from './correlation-ids'; import type { OperationsInterface } from './operations'; +import type { TagsInterface } from './tags'; +import type { ExternalDocumentationsInterface } from './external-documentations'; export interface ComponentsInterface extends BaseModel, ExtensionsMixinInterface { servers(): ServersInterface; @@ -25,6 +27,8 @@ export interface ComponentsInterface extends BaseModel, ExtensionsMixinInterface messageTraits(): MessageTraitsInterface; correlationIds(): CorrelationIdsInterface; securitySchemes(): SecuritySchemesInterface; + tags(): TagsInterface; + externalDocs(): ExternalDocumentationsInterface; serverBindings(): Record; channelBindings(): Record; operationBindings(): Record; diff --git a/src/models/external-docs.ts b/src/models/external-documentation.ts similarity index 100% rename from src/models/external-docs.ts rename to src/models/external-documentation.ts diff --git a/src/models/external-documentations.ts b/src/models/external-documentations.ts new file mode 100644 index 000000000..501aab4bf --- /dev/null +++ b/src/models/external-documentations.ts @@ -0,0 +1,4 @@ +import type { Collection } from './collection'; +import type { ExternalDocumentationInterface } from './external-documentation'; + +export type ExternalDocumentationsInterface = Collection diff --git a/src/models/index.ts b/src/models/index.ts index 1161d0a38..cb0aa250f 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -16,7 +16,7 @@ export * from './correlation-id'; export * from './correlation-ids'; export * from './extension'; export * from './extensions'; -export * from './external-docs'; +export * from './external-documentation'; export * from './info'; export * from './license'; export * from './message-example'; diff --git a/src/models/mixins.ts b/src/models/mixins.ts index 7cd305208..42d8cff71 100644 --- a/src/models/mixins.ts +++ b/src/models/mixins.ts @@ -1,6 +1,6 @@ import type { BindingsInterface } from './bindings'; import type { ExtensionsInterface } from './extensions'; -import type { ExternalDocumentationInterface } from './external-docs'; +import type { ExternalDocumentationInterface } from './external-documentation'; import type { TagsInterface } from './tags'; export interface BindingsMixinInterface { diff --git a/src/models/v2/components.ts b/src/models/v2/components.ts index b6f16f425..081761641 100644 --- a/src/models/v2/components.ts +++ b/src/models/v2/components.ts @@ -25,6 +25,8 @@ import { SecuritySchemes } from './security-schemes'; import { CorrelationIds } from './correlation-ids'; import { Operations } from './operations'; import { Message } from './message'; +import { Tags } from './tags'; +import { ExternalDocumentations } from './external-documentations'; import { tilde } from '../../utils'; @@ -43,6 +45,8 @@ import type { SecuritySchemesInterface } from '../security-schemes'; import type { MessageTraitsInterface } from '../message-traits'; import type { OperationsInterface } from '../operations'; import type { OperationInterface } from '../operation'; +import type { TagsInterface } from '../tags'; +import type { ExternalDocumentationsInterface } from '../external-documentations'; import type { v2 } from '../../spec-types'; @@ -97,6 +101,14 @@ export class Components extends BaseModel implements Compon return this.createCollection('securitySchemes', SecuritySchemes, SecurityScheme); } + tags(): TagsInterface { + return new Tags([]); + } + + externalDocs(): ExternalDocumentationsInterface { + return new ExternalDocumentations([]); + } + serverBindings(): Record { return this.createBindings('serverBindings'); } diff --git a/src/models/v2/external-docs.ts b/src/models/v2/external-documentation.ts similarity index 97% rename from src/models/v2/external-docs.ts rename to src/models/v2/external-documentation.ts index 5c6e513e8..8f4ee838a 100644 --- a/src/models/v2/external-docs.ts +++ b/src/models/v2/external-documentation.ts @@ -2,7 +2,7 @@ import { BaseModel } from '../base'; import { hasDescription, description, extensions } from './mixins'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { ExtensionsInterface } from '../extensions'; import type { v2 } from '../../spec-types'; diff --git a/src/models/v2/external-documentations.ts b/src/models/v2/external-documentations.ts new file mode 100644 index 000000000..46f3be049 --- /dev/null +++ b/src/models/v2/external-documentations.ts @@ -0,0 +1,10 @@ +import { Collection } from '../collection'; + +import type { ExternalDocumentationsInterface } from '../external-documentations'; +import type { ExternalDocumentationInterface } from '../external-documentation'; + +export class ExternalDocumentations extends Collection implements ExternalDocumentationsInterface { + override get(_: string): ExternalDocumentationInterface | undefined { + return; + } +} diff --git a/src/models/v2/index.ts b/src/models/v2/index.ts index 69b94f651..a29bcc771 100644 --- a/src/models/v2/index.ts +++ b/src/models/v2/index.ts @@ -10,7 +10,7 @@ export { Contact as ContactV2 } from './contact'; export { CorrelationId as CorrelationIdV2 } from './correlation-id'; export { Extension as ExtensionV2 } from './extension'; export { Extensions as ExtensionsV2 } from './extensions'; -export { ExternalDocumentation as ExternalDocumentationV2 } from './external-docs'; +export { ExternalDocumentation as ExternalDocumentationV2 } from './external-documentation'; export { Info as InfoV2 } from './info'; export { License as LicenseV2 } from './license'; export { MessageExample as MessageExampleV2 } from './message-example'; diff --git a/src/models/v2/info.ts b/src/models/v2/info.ts index 5ca6dda00..8baa0dacf 100644 --- a/src/models/v2/info.ts +++ b/src/models/v2/info.ts @@ -1,6 +1,6 @@ import { BaseModel } from '../base'; import { Contact } from './contact'; -import { ExternalDocumentation } from './external-docs'; +import { ExternalDocumentation } from './external-documentation'; import { License } from './license'; import { Tags } from './tags'; import { Tag } from './tag'; @@ -10,7 +10,7 @@ import { hasDescription, description, extensions } from './mixins'; import type { ContactInterface } from '../contact'; import type { InfoInterface } from '../info'; import type { ExtensionsInterface } from '../extensions'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { LicenseInterface } from '../license'; import type { TagsInterface } from '../tags'; diff --git a/src/models/v2/message-trait.ts b/src/models/v2/message-trait.ts index 914757e79..b9e17055c 100644 --- a/src/models/v2/message-trait.ts +++ b/src/models/v2/message-trait.ts @@ -11,7 +11,7 @@ import { bindings, hasDescription, description, extensions, hasExternalDocs, ext import type { BindingsInterface } from '../bindings'; import type { CorrelationIdInterface } from '../correlation-id'; import type { ExtensionsInterface } from '../extensions'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { MessageExamplesInterface } from '../message-examples'; import type { MessageTraitInterface } from '../message-trait'; import type { SchemaInterface } from '../schema'; diff --git a/src/models/v2/mixins.ts b/src/models/v2/mixins.ts index 37ebc7927..7e39a8627 100644 --- a/src/models/v2/mixins.ts +++ b/src/models/v2/mixins.ts @@ -2,7 +2,7 @@ import { Bindings } from './bindings'; import { Binding } from './binding'; import { Extensions } from './extensions'; import { Extension } from './extension'; -import { ExternalDocumentation } from './external-docs'; +import { ExternalDocumentation } from './external-documentation'; import { Tags } from './tags'; import { Tag } from './tag'; @@ -13,7 +13,7 @@ import type { BaseModel } from '../base'; import type { BindingsInterface } from '../bindings'; import type { ExtensionsInterface } from '../extensions'; import type { ExtensionInterface } from '../extension'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { TagsInterface } from '../tags'; import type { v2 } from '../../spec-types'; diff --git a/src/models/v2/operation-trait.ts b/src/models/v2/operation-trait.ts index 98a4ca631..c4a47d55d 100644 --- a/src/models/v2/operation-trait.ts +++ b/src/models/v2/operation-trait.ts @@ -5,7 +5,7 @@ import { bindings, hasDescription, description, extensions, hasExternalDocs, ext import type { BindingsInterface } from '../bindings'; import type { ExtensionsInterface } from '../extensions'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { OperationAction } from '../operation'; import type { OperationTraitInterface } from '../operation-trait'; import type { TagsInterface } from '../tags'; diff --git a/src/models/v2/schema.ts b/src/models/v2/schema.ts index ee551ae63..7149da70f 100644 --- a/src/models/v2/schema.ts +++ b/src/models/v2/schema.ts @@ -6,7 +6,7 @@ import { retrievePossibleRef, hasRef } from '../../utils'; import type { ModelMetadata } from '../base'; import type { ExtensionsInterface } from '../extensions'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { SchemaInterface } from '../schema'; import type { v2 } from '../../spec-types'; diff --git a/src/models/v2/tag.ts b/src/models/v2/tag.ts index 758043b05..b1492040f 100644 --- a/src/models/v2/tag.ts +++ b/src/models/v2/tag.ts @@ -3,7 +3,7 @@ import { BaseModel } from '../base'; import { hasDescription, description, extensions, hasExternalDocs, externalDocs } from './mixins'; import type { ExtensionsInterface } from '../extensions'; -import type{ ExternalDocumentationInterface } from '../external-docs'; +import type{ ExternalDocumentationInterface } from '../external-documentation'; import type { TagInterface } from '../tag'; import type { v2 } from '../../spec-types'; diff --git a/src/models/v3/asyncapi.ts b/src/models/v3/asyncapi.ts index 29e3b8687..e46292429 100644 --- a/src/models/v3/asyncapi.ts +++ b/src/models/v3/asyncapi.ts @@ -1,6 +1,8 @@ import { BaseModel } from '../base'; +import { Info } from './info'; import type { AsyncAPIDocumentInterface } from '../asyncapi'; +import type { InfoInterface } from '../info'; import type { v3 } from '../../spec-types'; diff --git a/src/models/v3/components.ts b/src/models/v3/components.ts new file mode 100644 index 000000000..6d638f594 --- /dev/null +++ b/src/models/v3/components.ts @@ -0,0 +1,133 @@ +import { BaseModel } from '../base'; +import { Collection } from '../collection'; + +import { Bindings } from './bindings'; +import { Binding } from './binding'; +import { extensions } from './mixins'; +import { Tags } from './tags'; +import { Tag } from './tag'; +import { ExternalDocumentations } from './external-documentations'; +import { ExternalDocumentation } from './external-documentation'; + +import { tilde } from '../../utils'; + +import type { BindingsInterface } from '../bindings'; +import type { ComponentsInterface } from '../components'; +import type { ExtensionsInterface } from '../extensions'; +import type { Constructor } from '../utils'; +import type { ServersInterface } from '../servers'; +import type { ChannelsInterface } from '../channels'; +import type { MessagesInterface } from '../messages'; +import type { SchemasInterface } from '../schemas'; +import type { ChannelParametersInterface } from '../channel-parameters'; +import type { ServerVariablesInterface } from '../server-variables'; +import type { OperationTraitsInterface } from '../operation-traits'; +import type { SecuritySchemesInterface } from '../security-schemes'; +import type { MessageTraitsInterface } from '../message-traits'; +import type { OperationsInterface } from '../operations'; +import type { TagsInterface } from '../tags'; +import type { ExternalDocumentationsInterface } from '../external-documentations'; +import type { CorrelationIdsInterface } from '../correlation-ids'; + +import type { v3 } from '../../spec-types'; + +export class Components extends BaseModel implements ComponentsInterface { + servers(): ServersInterface { + return [] as any; + } + + channels(): ChannelsInterface { + return [] as any; + } + + messages(): MessagesInterface { + return [] as any; + } + + schemas(): SchemasInterface { + return [] as any; + } + + channelParameters(): ChannelParametersInterface { + return [] as any; + } + + serverVariables(): ServerVariablesInterface { + return [] as any; + } + + operations(): OperationsInterface { + return [] as any; + } + + operationTraits(): OperationTraitsInterface { + return [] as any; + } + + messageTraits(): MessageTraitsInterface { + return [] as any; + } + + correlationIds(): CorrelationIdsInterface { + return [] as any; + } + + securitySchemes(): SecuritySchemesInterface { + return [] as any; + } + + tags(): TagsInterface { + return this.createCollection('tags', Tags, Tag, 'componentId'); + } + + externalDocs(): ExternalDocumentationsInterface { + return this.createCollection('externalDocs', ExternalDocumentations, ExternalDocumentation, 'componentId'); + } + + serverBindings(): Record { + return this.createBindings('serverBindings'); + } + + channelBindings(): Record { + return this.createBindings('channelBindings'); + } + + operationBindings(): Record { + return this.createBindings('operationBindings'); + } + + messageBindings(): Record { + return this.createBindings('messageBindings'); + } + + extensions(): ExtensionsInterface { + return extensions(this); + } + + isEmpty(): boolean { + return Object.keys(this._json).length === 0; + } + + protected createCollection, T extends BaseModel>(itemsName: keyof v3.ComponentsObject, collectionModel: Constructor, itemModel: Constructor, idKey: string = 'id'): M { + const collectionItems: T[] = []; + Object.entries(this._json[itemsName] || {}).forEach(([id, item]) => { + collectionItems.push(this.createModel(itemModel, item as any, { [idKey]: id, pointer: `/components/${itemsName}/${id}` } as any)); + }); + return new collectionModel(collectionItems); + } + + protected createBindings(itemsName: 'serverBindings' | 'channelBindings' | 'operationBindings' | 'messageBindings'): Record { + return Object.entries(this._json[itemsName] || {}).reduce((bindings, [name, item]) => { + const bindingsData = item || {}; + const asyncapi = this.meta('asyncapi'); + const pointer = `components/${itemsName}/${name}`; + bindings[name] = new Bindings( + Object.entries(bindingsData).map(([protocol, binding]) => + this.createModel(Binding, binding, { protocol, pointer: `${pointer}/${protocol}` }) + ), + { originalData: bindingsData as any, asyncapi, pointer } + ); + return bindings; + }, {} as Record); + } +} diff --git a/src/models/v3/contact.ts b/src/models/v3/contact.ts new file mode 100644 index 000000000..69166bd18 --- /dev/null +++ b/src/models/v3/contact.ts @@ -0,0 +1,38 @@ +import { BaseModel } from '../base'; + +import { extensions } from './mixins'; + +import type { ContactInterface } from '../contact'; +import type { ExtensionsInterface } from '../extensions'; + +import type { v3 } from '../../spec-types'; + +export class Contact extends BaseModel implements ContactInterface { + hasName(): boolean { + return !!this._json.name; + } + + name(): string | undefined { + return this._json.name; + } + + hasUrl(): boolean { + return !!this._json.url; + } + + url(): string | undefined { + return this._json.url; + } + + hasEmail(): boolean { + return !!this._json.email; + } + + email(): string | undefined { + return this._json.email; + } + + extensions(): ExtensionsInterface { + return extensions(this); + } +} \ No newline at end of file diff --git a/src/models/v3/external-docs.ts b/src/models/v3/external-documentation.ts similarity index 84% rename from src/models/v3/external-docs.ts rename to src/models/v3/external-documentation.ts index edafb417c..443142b0c 100644 --- a/src/models/v3/external-docs.ts +++ b/src/models/v3/external-documentation.ts @@ -2,12 +2,12 @@ import { BaseModel } from '../base'; import { hasDescription, description, extensions } from './mixins'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { ExtensionsInterface } from '../extensions'; import type { v3 } from '../../spec-types'; -export class ExternalDocumentation extends BaseModel implements ExternalDocumentationInterface { +export class ExternalDocumentation extends BaseModel implements ExternalDocumentationInterface { url(): string { return this._json.url; } diff --git a/src/models/v3/external-documentations.ts b/src/models/v3/external-documentations.ts new file mode 100644 index 000000000..46c197252 --- /dev/null +++ b/src/models/v3/external-documentations.ts @@ -0,0 +1,10 @@ +import { Collection } from '../collection'; + +import type { ExternalDocumentationsInterface } from '../external-documentations'; +import type { ExternalDocumentationInterface } from '../external-documentation'; + +export class ExternalDocumentations extends Collection implements ExternalDocumentationsInterface { + override get(id: string): ExternalDocumentationInterface | undefined { + return this.collections.find(externalDocumentation => externalDocumentation.meta('componentId' as any) === id); + } +} diff --git a/src/models/v3/info.ts b/src/models/v3/info.ts new file mode 100644 index 000000000..fec483ca1 --- /dev/null +++ b/src/models/v3/info.ts @@ -0,0 +1,82 @@ +import { BaseModel } from '../base'; +import { Contact } from './contact'; +import { License } from './license'; + +import { hasDescription, description, extensions, hasExternalDocs, externalDocs, tags } from './mixins'; + +import type { ContactInterface } from '../contact'; +import type { InfoInterface } from '../info'; +import type { ExtensionsInterface } from '../extensions'; +import type { ExternalDocumentationInterface } from '../external-documentation'; +import type { LicenseInterface } from '../license'; +import type { TagsInterface } from '../tags'; + +import type { v3 } from '../../spec-types'; + +export class Info extends BaseModel implements InfoInterface { + title(): string { + return this._json.title; + } + + version(): string { + return this._json.version; + } + + hasId(): boolean { + return !!this._meta.asyncapi.parsed.id; + } + + id(): string | undefined { + return this._meta.asyncapi.parsed.id; + } + + hasDescription(): boolean { + return hasDescription(this); + } + + description(): string | undefined { + return description(this); + } + + hasTermsOfService(): boolean { + return !!this._json.termsOfService; + } + + termsOfService(): string | undefined { + return this._json.termsOfService; + } + + hasContact(): boolean { + return Object.keys(this._json.contact || {}).length > 0; + } + + contact(): ContactInterface | undefined { + const contact = this._json.contact; + return contact && this.createModel(Contact, contact, { pointer: this.jsonPath('contact') }); + } + + hasLicense(): boolean { + return Object.keys(this._json.license || {}).length > 0; + } + + license(): LicenseInterface | undefined { + const license = this._json.license; + return license && this.createModel(License, license, { pointer: this.jsonPath('license') }); + } + + hasExternalDocs(): boolean { + return hasExternalDocs(this); + } + + externalDocs(): ExternalDocumentationInterface | undefined { + return externalDocs(this); + } + + tags(): TagsInterface { + return tags(this); + } + + extensions(): ExtensionsInterface { + return extensions(this); + } +} diff --git a/src/models/v3/license.ts b/src/models/v3/license.ts new file mode 100644 index 000000000..8280080fc --- /dev/null +++ b/src/models/v3/license.ts @@ -0,0 +1,26 @@ +import { BaseModel } from '../base'; + +import { extensions } from './mixins'; + +import type { ExtensionsInterface } from '../extensions'; +import type { LicenseInterface } from '../license'; + +import type { v3 } from '../../spec-types'; + +export class License extends BaseModel implements LicenseInterface { + name(): string { + return this._json.name; + } + + hasUrl(): boolean { + return !!this._json.url; + } + + url(): string | undefined { + return this._json.url; + } + + extensions(): ExtensionsInterface { + return extensions(this); + } +} diff --git a/src/models/v3/mixins.ts b/src/models/v3/mixins.ts index 405d1cd6b..babb3b088 100644 --- a/src/models/v3/mixins.ts +++ b/src/models/v3/mixins.ts @@ -2,7 +2,7 @@ import { Bindings } from './bindings'; import { Binding } from './binding'; import { Extensions } from './extensions'; import { Extension } from './extension'; -import { ExternalDocumentation } from './external-docs'; +import { ExternalDocumentation } from './external-documentation'; import { Tags } from './tags'; import { Tag } from './tag'; @@ -13,7 +13,7 @@ import type { BaseModel } from '../base'; import type { BindingsInterface } from '../bindings'; import type { ExtensionsInterface } from '../extensions'; import type { ExtensionInterface } from '../extension'; -import type { ExternalDocumentationInterface } from '../external-docs'; +import type { ExternalDocumentationInterface } from '../external-documentation'; import type { TagsInterface } from '../tags'; import type { v3 } from '../../spec-types'; diff --git a/src/models/v3/tag.ts b/src/models/v3/tag.ts index 84ea47133..d59137693 100644 --- a/src/models/v3/tag.ts +++ b/src/models/v3/tag.ts @@ -3,12 +3,12 @@ import { BaseModel } from '../base'; import { hasDescription, description, extensions, hasExternalDocs, externalDocs } from './mixins'; import type { ExtensionsInterface } from '../extensions'; -import type{ ExternalDocumentationInterface } from '../external-docs'; +import type{ ExternalDocumentationInterface } from '../external-documentation'; import type { TagInterface } from '../tag'; import type { v3 } from '../../spec-types'; -export class Tag extends BaseModel implements TagInterface { +export class Tag extends BaseModel implements TagInterface { name(): string { return this._json.name; } diff --git a/src/models/v3/tags.ts b/src/models/v3/tags.ts index 6048620ff..649a38cbf 100644 --- a/src/models/v3/tags.ts +++ b/src/models/v3/tags.ts @@ -5,6 +5,10 @@ import type { TagInterface } from '../tag'; export class Tags extends Collection implements TagsInterface { override get(name: string): TagInterface | undefined { - return this.collections.find(tag => tag.name() === name); + return this.collections.find(tag => { + const componentId = tag.meta('componentId' as any); + if (typeof componentId === 'string') return componentId === name; + return tag.name() === name; + }); } } diff --git a/src/spec-types/v3.ts b/src/spec-types/v3.ts index d9c114224..6d08de770 100644 --- a/src/spec-types/v3.ts +++ b/src/spec-types/v3.ts @@ -7,9 +7,108 @@ export type DefaultContentType = string; export interface AsyncAPIObject extends SpecificationExtensions { asyncapi: AsyncAPIVersion; id?: Identifier; + info: InfoObject; defaultContentType?: DefaultContentType; } +export interface InfoObject extends SpecificationExtensions { + title: string; + version: string; + description?: string; + termsOfService?: string; + contact?: ContactObject; + license?: LicenseObject; + tags?: TagsObject; + externalDocs?: ExternalDocumentationObject; +} + +export interface ContactObject extends SpecificationExtensions { + name?: string; + url?: string; + email?: string; +} + +export interface LicenseObject extends SpecificationExtensions { + name: string; + url?: string; +} + +export interface ServerBindingsObject extends SpecificationExtensions { + http?: Binding; + ws?: Binding; + kafka?: Binding; + anypointmq?: Binding; + amqp?: Binding; + amqp1?: Binding; + mqtt?: Binding; + mqtt5?: Binding; + nats?: Binding; + jms?: Binding; + sns?: Binding; + sqs?: Binding; + stomp?: Binding; + redis?: Binding; + mercure?: Binding; + ibmmq?: Binding; +} + +export interface ChannelBindingsObject extends SpecificationExtensions { + http?: Binding; + ws?: Binding; + kafka?: Binding; + anypointmq?: Binding; + amqp?: Binding; + amqp1?: Binding; + mqtt?: Binding; + mqtt5?: Binding; + nats?: Binding; + jms?: Binding; + sns?: Binding; + sqs?: Binding; + stomp?: Binding; + redis?: Binding; + mercure?: Binding; + ibmmq?: Binding; +} + +export interface OperationBindingsObject extends SpecificationExtensions { + http?: Binding; + ws?: Binding; + kafka?: Binding; + anypointmq?: Binding; + amqp?: Binding; + amqp1?: Binding; + mqtt?: Binding; + mqtt5?: Binding; + nats?: Binding; + jms?: Binding; + sns?: Binding; + sqs?: Binding; + stomp?: Binding; + redis?: Binding; + mercure?: Binding; + ibmmq?: Binding; +} + +export interface MessageBindingsObject extends SpecificationExtensions { + http?: Binding; + ws?: Binding; + kafka?: Binding; + anypointmq?: Binding; + amqp?: Binding; + amqp1?: Binding; + mqtt?: Binding; + mqtt5?: Binding; + nats?: Binding; + jms?: Binding; + sns?: Binding; + sqs?: Binding; + stomp?: Binding; + redis?: Binding; + mercure?: Binding; + ibmmq?: Binding; +} + export type TagsObject = Array; export interface TagObject extends SpecificationExtensions { @@ -23,6 +122,15 @@ export interface ExternalDocumentationObject extends SpecificationExtensions { description?: string; } +export interface ComponentsObject extends SpecificationExtensions { + tags?: Record; + externalDocs?: Record; + serverBindings?: Record; + channelBindings?: Record; + operationBindings?: Record; + messageBindings?: Record; +} + export type SchemaObject = AsyncAPISchemaObject | ReferenceObject; export type AsyncAPISchemaObject = AsyncAPISchemaDefinition | boolean;