@redocly/asyncapi-docs
Version:
Async API docs for Redocly Realm
236 lines (235 loc) • 6.38 kB
TypeScript
import type { ResolvedNavItem } from '@redocly/config';
import type { JSONSchema7 } from 'json-schema';
import type { ApiItemData } from './apiItem';
export interface AsyncApiDefinition {
asyncapi: string;
id?: string;
info: AsyncApiInfo;
servers?: Record<string, AsyncApiServer>;
defaultContentType?: string;
channels?: AsyncApiChannels;
operations?: AsyncApiOperations;
components?: AsyncApiComponents;
}
export interface AsyncApiInfo {
title: string;
version: string;
description?: string;
termsOfService?: string;
contact?: AsyncApiContact;
license?: AsyncApiLicense;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
'x-metadata'?: Record<string, unknown>;
}
export interface AsyncApiContact {
name?: string;
url?: string;
email?: string;
}
export interface AsyncApiLicense {
name: string;
url?: string;
}
export interface AsyncApiTag {
name: string;
description?: string;
externalDocs?: AsyncApiExternalDocs;
}
export interface AsyncApiExternalDocs {
description?: string;
url: string;
}
export interface AsyncApiServer {
host: string;
protocol: string;
protocolVersion?: string;
pathname?: string;
description?: string;
title?: string;
summary?: string;
variables?: AsyncApiServerVariables;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
bindings?: AsyncApiServerBinding;
}
export interface AsyncApiServerVariables {
[name: string]: AsyncApiServerVariable;
}
export interface AsyncApiChannels {
[name: string]: AsyncApiChannel;
}
export interface AsyncApiServerVariable {
enum?: string[];
default: string;
description?: string;
}
export interface AsyncApiServerBinding {
kafka?: AsyncApiServerKafkaBinding;
}
export interface AsyncApiServerKafkaBinding {
schemaRegistryUrl?: string;
schemaRegistryVendor?: string;
bindingVersion?: string;
}
export interface AsyncApiChannel {
address?: string;
messages?: AsyncApiMessages;
title?: string;
summary?: string;
description?: string;
servers?: AsyncApiServer[];
parameters?: AsyncApiParameters;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
bindings?: AsyncApiChannelBinding;
'x-badges'?: AsyncApiXBadges[];
}
export interface AsyncApiXBadges {
name: string;
position?: 'before' | 'after';
color?: string;
}
export interface AsyncApiChannelBinding {
kafka?: AsyncApiChannelKafkaBinding;
}
export interface AsyncApiChannelKafkaBinding {
topic?: string;
partitions?: number;
replicas?: number;
bindingVersion?: string;
topicConfiguration?: {
'cleanup.policy'?: string[];
'retention.ms'?: number;
'retention.bytes'?: number;
'delete.retention.ms'?: number;
'max.message.bytes'?: number;
'confluent.key.schema.validation'?: boolean;
'confluent.key.subject.name.strategy'?: string;
'confluent.value.schema.validation'?: boolean;
'confluent.value.subject.name.strategy'?: string;
};
}
export interface AsyncApiMessages {
[name: string]: AsyncApiMessage;
}
export interface AsyncApiParameters {
[name: string]: AsyncApiParameter;
}
export interface AsyncApiParameter {
enum?: string[];
default?: string;
description?: string;
examples?: string[];
location?: string;
}
export interface AsyncApiMessage {
headers?: JSONSchema7 | MultiFormatSchemaObject;
payload?: JSONSchema7 | MultiFormatSchemaObject;
correlationId?: AsyncApiCorrelationId;
contentType?: string;
name?: string;
title?: string;
summary?: string;
description?: string;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
bindings?: AsyncApiMessageBinding;
examples?: AsyncApiMessageExample[];
}
export interface AsyncApiCorrelationId {
description?: string;
location: string;
}
export interface AsyncApiMessageBinding {
kafka?: AsyncApiMessageKafkaBinding;
}
export interface AsyncApiMessageKafkaBinding {
key?: JSONSchema7;
schemaIdLocation?: string;
schemaIdPayloadEncoding?: string;
schemaLookupStrategy?: string;
bindingVersion?: string;
}
export interface AsyncApiMessageExample {
payload?: Record<string, any>;
name?: string;
summary?: string;
}
export interface MultiFormatSchemaObject {
schema: JSONSchema7 | AvroSchema;
schemaFormat: string;
}
export interface AsyncApiOperations {
[name: string]: AsyncApiOperation;
}
export interface AsyncApiOperation {
action: 'send' | 'receive';
channel: AsyncApiChannel;
title?: string;
summary?: string;
description?: string;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
bindings?: AsyncApiOperationBinding;
traits?: AsyncApiOperationTraits[];
messages?: AsyncApiMessage[];
reply?: AsyncApiOperationReply;
'x-badges'?: AsyncApiXBadges[];
}
export interface AsyncApiOperationReply {
address?: {
description?: string;
location: string;
};
channel?: AsyncApiChannel;
messages?: AsyncApiMessage[];
}
export interface AsyncApiOperationTraits {
title?: string;
summary?: string;
description?: string;
tags?: AsyncApiTag[];
externalDocs?: AsyncApiExternalDocs;
bindings?: AsyncApiOperationBinding;
}
export interface AsyncApiOperationBinding {
kafka?: AsyncApiOperationKafkaBinding;
}
export interface AsyncApiOperationKafkaBinding {
groupId?: {
type: string;
enum: string[];
};
clientId?: {
type: string;
enum: string[];
};
bindingVersion?: string;
}
export interface AsyncApiComponents {
messages: Record<string, AsyncApiMessage>;
tags: Record<string, AsyncApiTag>;
}
export interface AvroSchema {
type: string | string[] | AvroSchema[];
name?: string;
doc?: string;
symbols?: string[];
fields?: Array<{
name: string;
type: AvroSchema | string | (string | AvroSchema)[];
doc?: string;
default?: any;
}>;
items?: AvroSchema | string;
values?: AvroSchema | string;
}
export type ResolvedAsyncApiNavItem = ResolvedNavItem & {
apiItemData?: ApiItemData;
items?: ResolvedAsyncApiNavItem[];
action?: string;
};
export type DownloadUrls = {
url: string;
};