diff --git a/src/apitypes/async/async.changes.ts b/src/apitypes/async/async.changes.ts index 9319a4dd..23196980 100644 --- a/src/apitypes/async/async.changes.ts +++ b/src/apitypes/async/async.changes.ts @@ -25,6 +25,7 @@ import { import { AFTER_VALUE_NORMALIZED_PROPERTY, BEFORE_VALUE_NORMALIZED_PROPERTY, + FIRST_REFERENCE_KEY_PROPERTY, NORMALIZE_OPTIONS, ORIGINS_SYMBOL, } from '../../consts' @@ -45,8 +46,16 @@ import { getOperationTags, OperationsMap, } from '../../components' +import { createAsyncApiCompatibilityScopeFunction } from '../../components/compare/async.bwc.validation' import { v3 as AsyncAPIV3 } from '@asyncapi/parser/esm/spec-types' -import { getAsyncMessageId } from './async.utils' +import { + collectChannelMessageDefinitionDiffs, + collectExclusiveOtherMessageDiffs, + extractAsyncApiVersionDiff, + extractIdDiff, + extractInfoDiffs, + getAsyncMessageId, +} from './async.utils' export const compareDocuments: DocumentsCompare = async ( operationsMap: OperationsMap, @@ -86,9 +95,11 @@ export const compareDocuments: DocumentsCompare = async ( ...NORMALIZE_OPTIONS, metaKey: DIFF_META_KEY, originsFlag: ORIGINS_SYMBOL, - normalizedResult: true, + normalizedResult: false, afterValueNormalizedProperty: AFTER_VALUE_NORMALIZED_PROPERTY, beforeValueNormalizedProperty: BEFORE_VALUE_NORMALIZED_PROPERTY, + firstReferenceKeyProperty: FIRST_REFERENCE_KEY_PROPERTY, + apiCompatibilityScopeFunction: createAsyncApiCompatibilityScopeFunction(), }, ) as { merged: AsyncAPIV3.AsyncAPIObject; diffs: Diff[] } @@ -101,10 +112,18 @@ export const compareDocuments: DocumentsCompare = async ( const tags = new Set() const operationChanges: OperationChanges[] = [] + // Precompute root-level diffs once (shared across all operations) + const asyncApiVersionDiffs = extractAsyncApiVersionDiff(merged) + const infoDiffs = extractInfoDiffs(merged) + const idDiffs = extractIdDiff(merged) + // Note: defaultContentType changes are handled by normalization inside apiDiff. + // Messages without explicit contentType inherit from defaultContentType during normalization, + // so changes to defaultContentType automatically appear in allOperationDiffs for affected messages. + // Iterate through operations in merged document - const { operations } = merged - if (operations && isObject(operations)) { - for (const [asyncOperationId, operationData] of Object.entries(operations)) { + const { operations: asyncOperations } = merged + if (asyncOperations && isObject(asyncOperations)) { + for (const [asyncOperationId, operationData] of Object.entries(asyncOperations)) { if (!operationData || !isObject(operationData)) { continue } @@ -114,16 +133,15 @@ export const compareDocuments: DocumentsCompare = async ( if (!Array.isArray(messages) || messages.length === 0) { continue } - // Extract action and channel from operation + const { action, channel: operationChannel } = operationObject if (!action || !operationChannel) { continue } - for (const message of messages) { - // Use simple operation ID (no normalization needed for AsyncAPI) + + for (const [messageIndex, message] of messages.entries()) { const messageId = getAsyncMessageId(message) const operationId = calculateAsyncOperationId(asyncOperationId, messageId) - const { current, previous, @@ -137,18 +155,26 @@ export const compareDocuments: DocumentsCompare = async ( let operationDiffs: Diff[] = [] if (operationPotentiallyChanged) { + const allOperationDiffs = (operationObject as WithAggregatedDiffs)[DIFFS_AGGREGATED_META_KEY] ?? [] + + const otherMessageDiffs = collectExclusiveOtherMessageDiffs(messages, messageIndex) + const channelMessageDiffs = collectChannelMessageDefinitionDiffs(operationChannel as AsyncAPIV3.ChannelObject) + operationDiffs = [ - ...(operationObject as WithAggregatedDiffs)[DIFFS_AGGREGATED_META_KEY] ?? [], - // TODO: check - // ...extractAsyncApiVersionDiff(merged), - // ...extractRootServersDiffs(merged), - // ...extractChannelsDiffs(merged, operationChannel), + ...([...allOperationDiffs].filter(diff => !otherMessageDiffs.has(diff) && !channelMessageDiffs.has(diff))), + ...asyncApiVersionDiffs, + ...infoDiffs, + ...idDiffs, ] } if (operationAddedOrRemoved) { - const operationAddedOrRemovedDiff = (operations as WithDiffMetaRecord)[DIFF_META_KEY]?.[asyncOperationId] - if (operationAddedOrRemovedDiff) { - operationDiffs.push(operationAddedOrRemovedDiff) + // Level 1: message added/removed within an existing operation (analogous to REST method within path) + const messageAddedOrRemovedDiff = (messages as WithDiffMetaRecord)[DIFF_META_KEY]?.[messageIndex] + // Level 2: entire operation added/removed (analogous to REST entire path) + const operationAddedOrRemovedDiff = (asyncOperations as WithDiffMetaRecord)[DIFF_META_KEY]?.[asyncOperationId] + const diff = messageAddedOrRemovedDiff ?? operationAddedOrRemovedDiff + if (diff) { + operationDiffs.push(diff) } } @@ -172,7 +198,7 @@ export const compareDocuments: DocumentsCompare = async ( return { operationChanges, tags, - ...(comparisonDocument) ? { comparisonDocument } : {}, + ...(comparisonDocument ? { comparisonDocument } : {}), } } diff --git a/src/apitypes/async/async.utils.ts b/src/apitypes/async/async.utils.ts index 1a70564a..f0aa4047 100644 --- a/src/apitypes/async/async.utils.ts +++ b/src/apitypes/async/async.utils.ts @@ -22,7 +22,8 @@ import { getSymbolValueIfDefined, isObject, isReferenceObject, - setValueByPath, takeIfDefined, + setValueByPath, + takeIfDefined, } from '../../utils' import type * as TYPE from './async.types' import { @@ -42,6 +43,8 @@ import { FIRST_REFERENCE_KEY_PROPERTY, INLINE_REFS_FLAG, } from '../../consts' +import { WithAggregatedDiffs, WithDiffMetaRecord } from '../../types' +import { Diff, DiffAction, DIFF_META_KEY, DIFFS_AGGREGATED_META_KEY } from '@netcracker/qubership-apihub-api-diff' // Re-export shared utilities export { dump, getCustomTags, resolveApiAudience } from '../../utils/apihubSpecificationExtensions' @@ -146,8 +149,8 @@ export const createBaseAsyncApiSpec = ( ): TYPE.AsyncOperationData => ({ asyncapi: document.asyncapi || '3.0.0', info: document.info, - ...takeIfDefined({id: document.id}), - ...takeIfDefined({defaultContentType: document.defaultContentType}), + ...takeIfDefined({ id: document.id }), + ...takeIfDefined({ defaultContentType: document.defaultContentType }), operations, }) @@ -236,11 +239,11 @@ export const resolveAsyncApiOperationIdsFromRefs = ( } for (const message of messages) { - if(!isMessageObject(message)){ + if (!isMessageObject(message)) { continue } const inlineRefs = getSymbolValueIfDefined(message, INLINE_REFS_FLAG) as string[] | undefined - if (!inlineRefs || inlineRefs.length === 0){ + if (!inlineRefs || inlineRefs.length === 0) { continue } const lastInlineRef = inlineRefs.at(-1) @@ -267,3 +270,88 @@ export const resolveAsyncApiOperationIdsFromRefs = ( return resolved } + +/** + * Aggregated diffs on the operation level include diffs from ALL messages. + * Since each apihub operation maps to a specific operation + message pair, + * diffs from sibling messages must be excluded to prevent them from leaking + * into unrelated apihub operations. + * + * Collects two kinds of diffs that belong exclusively to other messages: + * 1. Aggregated content diffs from each sibling message object + * 2. Array-level diffs for adding/removing sibling messages from the messages list + * + * Diffs shared between the current message and sibling messages (e.g. from a shared + * component schema) are NOT included, so they won't be incorrectly filtered out. + */ +export function collectExclusiveOtherMessageDiffs(messages: AsyncAPIV3.MessageObject[], currentMessageIndex: number): Set { + const currentMessageDiffsArr = (messages[currentMessageIndex] as WithAggregatedDiffs)[DIFFS_AGGREGATED_META_KEY] + const currentMessageDiffs = new Set(currentMessageDiffsArr ?? []) + + const otherDiffs = new Set() + for (const [messageIndex, message] of messages.entries()) { + if (messageIndex === currentMessageIndex) continue + const messageDiffs = (message as WithAggregatedDiffs)[DIFFS_AGGREGATED_META_KEY] + if (messageDiffs) { + for (const messageDiff of messageDiffs) { + if (!currentMessageDiffs.has(messageDiff)) { + otherDiffs.add(messageDiff) + } + } + } + } + const messagesArrayMeta = (messages as WithDiffMetaRecord)[DIFF_META_KEY] + if (messagesArrayMeta) { + for (const key in messagesArrayMeta) { + if (Number(key) !== currentMessageIndex) { + otherDiffs.add(messagesArrayMeta[key]) + } + } + } + return otherDiffs +} + +/** + * Collects diffs for adding/removing message definitions in channel.messages. + * These are channel-level definition changes that should not propagate to operations, + * because what matters is whether the operation's own messages array references a message, + * not whether the channel defines it. + */ +export function collectChannelMessageDefinitionDiffs(operationChannel: AsyncAPIV3.ChannelObject): Set { + const channelMessages = (operationChannel as Record).messages + if (!isObject(channelMessages)) { + return new Set() + } + const diffs = new Set() + const messagesMeta = (channelMessages as WithDiffMetaRecord)[DIFF_META_KEY] + if (messagesMeta) { + for (const key in messagesMeta) { + diffs.add(messagesMeta[key]) + } + } + return diffs +} + +export function extractAsyncApiVersionDiff(doc: AsyncAPIV3.AsyncAPIObject): Diff[] { + const diff = (doc as WithDiffMetaRecord)[DIFF_META_KEY]?.asyncapi + return diff ? [diff] : [] +} + +export function extractInfoDiffs(doc: AsyncAPIV3.AsyncAPIObject): Diff[] { + const addOrRemoveInfoDiff = (doc as WithDiffMetaRecord)[DIFF_META_KEY]?.info + const infoInternalDiffs = (doc.info as WithAggregatedDiffs)?.[DIFFS_AGGREGATED_META_KEY] ?? [] + return [ + ...(addOrRemoveInfoDiff ? [addOrRemoveInfoDiff] : []), + ...infoInternalDiffs, + ] +} + +export function extractIdDiff(doc: AsyncAPIV3.AsyncAPIObject): Diff[] { + const diff = (doc as WithDiffMetaRecord)[DIFF_META_KEY]?.id + return diff ? [diff] : [] +} + +export function extractDefaultContentTypeDiff(doc: AsyncAPIV3.AsyncAPIObject): Diff[] { + const diff = (doc as WithDiffMetaRecord)[DIFF_META_KEY]?.defaultContentType + return diff ? [diff] : [] +} diff --git a/src/apitypes/rest/rest.changes.ts b/src/apitypes/rest/rest.changes.ts index 106e1f55..a0ac311a 100644 --- a/src/apitypes/rest/rest.changes.ts +++ b/src/apitypes/rest/rest.changes.ts @@ -81,7 +81,7 @@ import { getOperationTags, OperationsMap, } from '../../components' -import { createApihubApiCompatibilityScopeFunction } from '../../components/compare/bwc.validation' +import { createRestApiCompatibilityScopeFunction } from '../../components/compare/rest.bwc.validation' import { calculateApiKindFromLabels, getApiKindProperty } from '../../components/document' export const compareDocuments: DocumentsCompare = async ( @@ -140,7 +140,7 @@ export const compareDocuments: DocumentsCompare = async ( normalizedResult: false, afterValueNormalizedProperty: AFTER_VALUE_NORMALIZED_PROPERTY, beforeValueNormalizedProperty: BEFORE_VALUE_NORMALIZED_PROPERTY, - apiCompatibilityScopeFunction: createApihubApiCompatibilityScopeFunction(prevDocumentApiKind, currDocumentApiKind), + apiCompatibilityScopeFunction: createRestApiCompatibilityScopeFunction(prevDocumentApiKind, currDocumentApiKind), openApiPathItemPerOperationDiffs: true, }, ) as { merged: OpenAPIV3.Document; diffs: Diff[] } diff --git a/src/components/compare/async.bwc.validation.ts b/src/components/compare/async.bwc.validation.ts new file mode 100644 index 00000000..b7c90c05 --- /dev/null +++ b/src/components/compare/async.bwc.validation.ts @@ -0,0 +1,106 @@ +/** + * Copyright 2024-2025 NetCracker Technology Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC } from '../../consts' +import { isObject } from '../../utils' +import { JsonPath } from '@netcracker/qubership-apihub-json-crawl' +import { + API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE, + API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE, + ApiCompatibilityKind, +} from '@netcracker/qubership-apihub-api-diff' +import { getApiKindProperty } from '../document' +import { v3 as AsyncAPIV3 } from '@asyncapi/parser/esm/spec-types' +import { ApiCompatibilityScopeFunctionFactory } from './bwc.validation.types' + +const ROOT_PATH_LENGTH = 0 +const ASYNC_OPERATION_PATH_LENGTH = 2 // operations/ +const ASYNC_CHANNEL_PATH_LENGTH = 2 // channels/ + +/** + * Creates an ApiCompatibilityScopeFunction for AsyncAPI documents. + * + * Resolution order: + * Channel (x-api-kind) → Operation (x-api-kind override) → Messages + * Document-level x-api-kind is not supported for AsyncAPI yet; + * prevDocumentApiKind/currDocumentApiKind params are reserved for future use. + * + * The scope function receives normalized before/after objects where $refs are resolved, + * so operation.channel is the resolved channel object with all its properties. + * + * - root: defaults to bwc (document-level api-kind reserved for future use) + * - operations/: operation x-api-kind overrides channel x-api-kind + * - channels/: channel's own x-api-kind + */ +export const createAsyncApiCompatibilityScopeFunction: ApiCompatibilityScopeFunctionFactory = ( + prevDocumentApiKind = APIHUB_API_COMPATIBILITY_KIND_BWC, + currDocumentApiKind = APIHUB_API_COMPATIBILITY_KIND_BWC, +) => { + const defaultApiCompatibilityKind = (prevDocumentApiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC || currDocumentApiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + ? API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE + : API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE + + return ( + path?: JsonPath, + beforeJso?: unknown, + afterJso?: unknown, + ): ApiCompatibilityKind | undefined => { + const pathLength = path?.length ?? 0 + + if (pathLength === ROOT_PATH_LENGTH) { + return defaultApiCompatibilityKind + } + + const firstSegment = path?.[0] + const beforeExists = isObject(beforeJso) + const afterExists = isObject(afterJso) + + if (!beforeExists && !afterExists) { + return undefined + } + + // operations/: resolve api-kind from operation x-api-kind with channel fallback + if (firstSegment === 'operations' && pathLength === ASYNC_OPERATION_PATH_LENGTH) { + // In normalized documents, operation.channel is the resolved channel object + const beforeChannelKind = getApiKindProperty((beforeJso as AsyncAPIV3.OperationObject | undefined)?.channel) + const afterChannelKind = getApiKindProperty((afterJso as AsyncAPIV3.OperationObject | undefined)?.channel) + + // Operation's own x-api-kind takes priority, falls back to channel's x-api-kind + const beforeOperationKind = getApiKindProperty(beforeJso, beforeChannelKind) + const afterOperationKind = getApiKindProperty(afterJso, afterChannelKind) + + if (beforeOperationKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC || afterOperationKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC) { + return API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE + } + + return API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE + } + + // channels/: use channel's own x-api-kind + if (firstSegment === 'channels' && pathLength === ASYNC_CHANNEL_PATH_LENGTH) { + const beforeChannelKind = getApiKindProperty(beforeJso) + const afterChannelKind = getApiKindProperty(afterJso) + + if (beforeChannelKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC || afterChannelKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC) { + return API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE + } + + return API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE + } + + return undefined + } +} diff --git a/src/components/compare/bwc.validation.types.ts b/src/components/compare/bwc.validation.types.ts new file mode 100644 index 00000000..f27597dd --- /dev/null +++ b/src/components/compare/bwc.validation.types.ts @@ -0,0 +1,7 @@ +import { ApihubApiCompatibilityKind } from '../../consts' +import { ApiCompatibilityScopeFunction } from '@netcracker/qubership-apihub-api-diff' + +export type ApiCompatibilityScopeFunctionFactory = ( + prevDocumentApiKind?: ApihubApiCompatibilityKind, + currDocumentApiKind?: ApihubApiCompatibilityKind, +) => ApiCompatibilityScopeFunction diff --git a/src/components/compare/bwc.validation.ts b/src/components/compare/rest.bwc.validation.ts similarity index 95% rename from src/components/compare/bwc.validation.ts rename to src/components/compare/rest.bwc.validation.ts index f100a24c..a90bf6f8 100644 --- a/src/components/compare/bwc.validation.ts +++ b/src/components/compare/rest.bwc.validation.ts @@ -26,10 +26,10 @@ import { API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE, API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE, ApiCompatibilityKind, - ApiCompatibilityScopeFunction, } from '@netcracker/qubership-apihub-api-diff' import { getApiKindProperty } from '../document' import { OpenAPIV3 } from 'openapi-types' +import { ApiCompatibilityScopeFunctionFactory } from './bwc.validation.types' export const calculateOperationApiCompatibilityKind = ( beforeOperationObject: OpenAPIV3.OperationObject | undefined, @@ -94,10 +94,10 @@ const ROOT_PATH_LENGTH = 0 const PATH_ITEM_PATH_LENGTH = 2 const OPERATION_OBJECT_PATH_LENGTH = 3 -export const createApihubApiCompatibilityScopeFunction = ( - prevDocumentApiKind: ApihubApiCompatibilityKind = APIHUB_API_COMPATIBILITY_KIND_BWC, - currDocumentApiKind: ApihubApiCompatibilityKind = APIHUB_API_COMPATIBILITY_KIND_BWC, -): ApiCompatibilityScopeFunction => { +export const createRestApiCompatibilityScopeFunction: ApiCompatibilityScopeFunctionFactory = ( + prevDocumentApiKind = APIHUB_API_COMPATIBILITY_KIND_BWC, + currDocumentApiKind = APIHUB_API_COMPATIBILITY_KIND_BWC, +) => { const defaultApiCompatibilityKind = (prevDocumentApiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC || currDocumentApiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC) ? API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE : API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE diff --git a/src/strategies/build.strategy.ts b/src/strategies/build.strategy.ts index 9ad8b0f0..e4ca2a41 100644 --- a/src/strategies/build.strategy.ts +++ b/src/strategies/build.strategy.ts @@ -16,11 +16,32 @@ import { BuildConfig, BuilderStrategy, BuildResult, BuildTypeContexts, VersionCache } from '../types' import { compareVersions } from '../components/compare' -import { getOperationsList, setDocument } from '../utils' +import { DuplicateOperationHandler, getOperationsList, setDocument } from '../utils' import { buildFiles } from '../components/files' import { calculateHistoryForDeprecatedItems } from '../components/deprecated' import { asyncDebugPerformance, DebugPerformanceContext } from '../utils/logs' -import { REST_API_TYPE } from '../consts' +import { ASYNCAPI_API_TYPE, MESSAGE_SEVERITY, REST_API_TYPE } from '../consts' + +/** + * Handles duplicate operationIds found across different documents during build. + * - AsyncAPI: throws an error, since duplicate operationIds across documents are not allowed. + * - REST: adds an error notification (non-fatal), since existing published specs may already have duplicates. + */ +const createDuplicateOperationHandler = (buildResult: BuildResult): DuplicateOperationHandler => (existing, duplicate) => { + if (duplicate.apiType === ASYNCAPI_API_TYPE) { + throw new Error( + `Duplicated operationId '${duplicate.operationId}' found in different documents: ` + + `'${existing.documentId}' and '${duplicate.documentId}'`, + ) + } + buildResult.notifications.push({ + severity: MESSAGE_SEVERITY.Error, + message: `Duplicated operationId '${duplicate.operationId}' found in different documents: ` + + `'${existing.documentId}' and '${duplicate.documentId}'`, + operationId: duplicate.operationId, + fileId: duplicate.documentId, + }) +} export class BuildStrategy implements BuilderStrategy { async execute(config: BuildConfig, buildResult: BuildResult, contexts: BuildTypeContexts, debugContext: DebugPerformanceContext): Promise { @@ -48,8 +69,9 @@ export class BuildStrategy implements BuilderStrategy { if (files?.length) { const buildFilesResult = await buildFiles(files, builderContextObject, debugContext) + const handleDuplicateOperation = createDuplicateOperationHandler(buildResult) for (const { document, operations = [] } of buildFilesResult) { - setDocument(buildResult, document, operations) + setDocument(buildResult, document, operations, handleDuplicateOperation) } if (!builderContextObject.builderRunOptions.withoutDeprecatedDepth && previousVersionCache) { diff --git a/src/utils/document.ts b/src/utils/document.ts index d75bf02f..5513523d 100644 --- a/src/utils/document.ts +++ b/src/utils/document.ts @@ -100,18 +100,22 @@ export function toPackageDocument(document: VersionDocument): PackageDocument { } } -export function setDocument(buildResult: BuildResult, document: VersionDocument, operations: ApiOperation[] = []): void { +export type DuplicateOperationHandler = ( + existing: ApiOperation, + duplicate: ApiOperation, +) => void + +export function setDocument( + buildResult: BuildResult, + document: VersionDocument, + operations: ApiOperation[] = [], + handleDuplicateOperation?: DuplicateOperationHandler, +): void { buildResult.documents.set(document.fileId, document) for (const operation of operations) { const existingOperation = buildResult.operations.get(operation.operationId) - if (existingOperation) { - buildResult.notifications.push({ - severity: MESSAGE_SEVERITY.Error, - message: `Duplicated operationId '${operation.operationId}' found in different documents: ` + - `'${existingOperation.documentId}' and '${operation.documentId}'`, - operationId: operation.operationId, - fileId: operation.documentId, - }) + if (existingOperation && handleDuplicateOperation) { + handleDuplicateOperation(existingOperation, operation) } buildResult.operations.set(operation.operationId, operation) } diff --git a/test/apiKinds.test.ts b/test/apiKinds.test.ts index 073b2118..47ca97bf 100644 --- a/test/apiKinds.test.ts +++ b/test/apiKinds.test.ts @@ -29,8 +29,8 @@ import { import { jest } from '@jest/globals' import { changesSummaryMatcher, Editor, LocalRegistry, serializedComparisonDocumentMatcher } from './helpers' import { takeIfDefined } from '../src/utils' -import * as bwcValidation from '../src/components/compare/bwc.validation' -import { calculateOperationApiCompatibilityKind } from '../src/components/compare/bwc.validation' +import * as bwcValidation from '../src/components/compare/rest.bwc.validation' +import { calculateOperationApiCompatibilityKind } from '../src/components/compare/rest.bwc.validation' let afterPackage: LocalRegistry const AFTER_PACKAGE_ID = 'api-kinds' diff --git a/test/asyncapi-apikind.test.ts b/test/asyncapi-apikind.test.ts deleted file mode 100644 index 58f9ab91..00000000 --- a/test/asyncapi-apikind.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { - APIHUB_API_COMPATIBILITY_KIND_BWC, - APIHUB_API_COMPATIBILITY_KIND_NO_BWC, - ApihubApiCompatibilityKind, - ApiOperation, -} from '../src' -import { calculateAsyncApiKind } from '../src/apitypes/async/async.utils' -import { buildPackageWithDefaultConfig } from './helpers' - -describe('AsyncAPI apiKind calculation', () => { - describe('Unit tests', () => { - it('should calculate apiKind from operation and channel values', () => { - const data = [ - // Operation ApiKind, Channel ApiKnd, Result - [undefined, undefined, APIHUB_API_COMPATIBILITY_KIND_BWC], - [APIHUB_API_COMPATIBILITY_KIND_BWC, undefined, APIHUB_API_COMPATIBILITY_KIND_BWC], - [undefined, APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC], - [APIHUB_API_COMPATIBILITY_KIND_NO_BWC, undefined, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], - [undefined, APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], - [APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC], - [APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], - ] - data.forEach(([operationApiKind, channelApiKind, expected]) => { - const result = calculateAsyncApiKind(operationApiKind as ApihubApiCompatibilityKind, channelApiKind as ApihubApiCompatibilityKind) - expect(result).toBe(expected) - }) - }) - }) - - describe('AsyncAPI operation/channel compatibility apiKind application', () => { - let operation: ApiOperation - let operationWithChannelBwc: ApiOperation - let operationWithChannelNoBwc: ApiOperation - let operationBwc: ApiOperation - let operationNoBwc: ApiOperation - let operationBwcWithChannelBwc: ApiOperation - let operationBwcWithChannelNoBwc: ApiOperation - let operationNoBwcWithChannelBwc: ApiOperation - let operationNoBwcWithChannelNoBwc: ApiOperation - - beforeAll(async () => { - const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base') - ;[ - operation, - operationWithChannelBwc, - operationWithChannelNoBwc, - operationBwc, - operationNoBwc, - operationBwcWithChannelBwc, - operationBwcWithChannelNoBwc, - operationNoBwcWithChannelBwc, - operationNoBwcWithChannelNoBwc, - ] = Array.from(result.operations.values()) - }) - - it('should apply BWC apiKind when both operation and channel have no apiKind', () => { - expect(operation.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should apply BWC apiKind when channel apiKind is BWC and operation has no apiKind', () => { - expect(operationWithChannelBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should apply NO_BWC apiKind when channel apiKind is NO_BWC and operation has no apiKind', () => { - expect(operationWithChannelNoBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) - }) - - it('should apply BWC apiKind when operation apiKind is BWC and channel has no apiKind', () => { - expect(operationBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should apply NO_BWC apiKind when operation apiKind is NO_BWC and channel has no apiKind', () => { - expect(operationNoBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) - }) - - it('should apply BWC apiKind when both operation and channel apiKind are BWC', () => { - expect(operationBwcWithChannelBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should apply BWC apiKind when operation apiKind is BWC and channel apiKind is NO_BWC', () => { - expect(operationBwcWithChannelNoBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should apply NO_BWC apiKind when operation apiKind is NO_BWC and channel apiKind is BWC', () => { - expect(operationNoBwcWithChannelBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) - }) - - it('should apply NO_BWC apiKind when both operation and channel apiKind are NO_BWC', () => { - expect(operationNoBwcWithChannelNoBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) - }) - }) - - it('should apply channel apiKind to all operations using that channel', async () => { - const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/share-channel-api-kind') - const operations = Array.from(result.operations.values()) - - expect(operations.every(operation => operation.apiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC)).toBeTrue() - }) - - describe('Labels should not redefine AsyncAPI apiKind', () => { - it('should not override default apiKind by Label', async () => { - const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base', ['apihub/x-api-kind: no-BWC']) - const [operation] = Array.from(result.operations.values()) - expect(operation.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - - it('should not override operation/channel apiKind by Label', async () => { - const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base', ['apihub/x-api-kind: no-BWC']) - const [operationWithCannelBwc] = Array.from(result.operations.values()) - expect(operationWithCannelBwc.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) - }) - }) -}) diff --git a/test/asyncapi-build-apikind.test.ts b/test/asyncapi-build-apikind.test.ts new file mode 100644 index 00000000..d82555c8 --- /dev/null +++ b/test/asyncapi-build-apikind.test.ts @@ -0,0 +1,282 @@ +import { + API_KIND_SPECIFICATION_EXTENSION, + APIHUB_API_COMPATIBILITY_KIND_BWC, + APIHUB_API_COMPATIBILITY_KIND_NO_BWC, + ApihubApiCompatibilityKind, + ApiOperation, +} from '../src' +import { calculateAsyncApiKind } from '../src/apitypes/async/async.utils' +import { buildPackageWithDefaultConfig } from './helpers' +import { createAsyncApiCompatibilityScopeFunction } from '../src/components/compare/async.bwc.validation' +import { + API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE, + API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE, +} from '@netcracker/qubership-apihub-api-diff' +import { v3 as AsyncAPIV3 } from '@asyncapi/parser/esm/spec-types' + +describe('AsyncAPI apiKind calculation', () => { + describe('Unit tests', () => { + it('should resolve effective apiKind from operation and channel x-api-kind', () => { + const data = [ + // Operation ApiKind, Channel ApiKnd, Result + [undefined, undefined, APIHUB_API_COMPATIBILITY_KIND_BWC], + [APIHUB_API_COMPATIBILITY_KIND_BWC, undefined, APIHUB_API_COMPATIBILITY_KIND_BWC], + [undefined, APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC], + [APIHUB_API_COMPATIBILITY_KIND_NO_BWC, undefined, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], + [undefined, APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], + [APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC], + [APIHUB_API_COMPATIBILITY_KIND_NO_BWC, APIHUB_API_COMPATIBILITY_KIND_BWC, APIHUB_API_COMPATIBILITY_KIND_NO_BWC], + ] + data.forEach(([operationApiKind, channelApiKind, expected]) => { + const result = calculateAsyncApiKind(operationApiKind as ApihubApiCompatibilityKind, channelApiKind as ApihubApiCompatibilityKind) + expect(result).toBe(expected) + }) + }) + + describe('Changelog backward compatibility scope function', () => { + // short names + const BWC = API_COMPATIBILITY_KIND_BACKWARD_COMPATIBLE + const NOT_BWC = API_COMPATIBILITY_KIND_NOT_BACKWARD_COMPATIBLE + + // Factories return a fresh object each time so that before/after are distinct instances. + // Currently the scope function only reads properties and doesn't compare by reference, + // but unique instances prevent false positives if the implementation ever starts + // distinguishing "same object" from "equal objects" (e.g. identity checks or mutation). + const channel = (): AsyncAPIV3.ChannelObject => ({ address: 'channel1' }) + const bwcChannel = (): AsyncAPIV3.ChannelObject => ({ ...channel(), [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_BWC }) + const noBwcChannel = (): AsyncAPIV3.ChannelObject => ({ ...channel(), [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_NO_BWC }) + + const operation = (): AsyncAPIV3.OperationObject => ({ action: 'receive', channel: {} }) + const bwcOperation = (): AsyncAPIV3.OperationObject => ({ ...operation(), [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_BWC }) + const noBwcOperation = (): AsyncAPIV3.OperationObject => ({ ...operation(), [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_NO_BWC }) + + describe('Root level', () => { + it.each([ + // prev | curr | expected + ['bwc', 'bwc', BWC], + ['bwc', 'no-bwc', NOT_BWC], + ['no-bwc', 'bwc', NOT_BWC], + ['no-bwc', 'no-bwc', NOT_BWC], + ])('prev: %s, curr: %s → should return %s', (prev, curr, expected) => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction( + prev as ApihubApiCompatibilityKind, + curr as ApihubApiCompatibilityKind, + ) + expect(scopeFunction([], {}, {})).toBe(expected) + }) + }) + + describe('Channels scope', () => { + it.each([ + // default | before | after | expected + // undefined JSO = channel added/removed + ['bwc', channel(), channel(), BWC], + ['bwc', channel(), bwcChannel(), BWC], + ['bwc', channel(), noBwcChannel(), NOT_BWC], + ['bwc', bwcChannel(), channel(), BWC], + ['bwc', bwcChannel(), bwcChannel(), BWC], + ['bwc', bwcChannel(), noBwcChannel(), NOT_BWC], + ['bwc', noBwcChannel(), channel(), NOT_BWC], + ['bwc', noBwcChannel(), bwcChannel(), NOT_BWC], + ['bwc', noBwcChannel(), noBwcChannel(), NOT_BWC], + ['bwc', undefined, channel(), BWC], + ['bwc', undefined, noBwcChannel(), NOT_BWC], + ['bwc', channel(), undefined, BWC], + ['bwc', noBwcChannel(), undefined, NOT_BWC], + ['bwc', undefined, undefined, undefined], + ['no-bwc', channel(), channel(), BWC], + ['no-bwc', channel(), bwcChannel(), BWC], + ['no-bwc', channel(), noBwcChannel(), NOT_BWC], + ['no-bwc', bwcChannel(), channel(), BWC], + ['no-bwc', bwcChannel(), bwcChannel(), BWC], + ['no-bwc', bwcChannel(), noBwcChannel(), NOT_BWC], + ['no-bwc', noBwcChannel(), channel(), NOT_BWC], + ['no-bwc', noBwcChannel(), bwcChannel(), NOT_BWC], + ['no-bwc', noBwcChannel(), noBwcChannel(), NOT_BWC], + ['no-bwc', undefined, channel(), BWC], + ['no-bwc', undefined, noBwcChannel(), NOT_BWC], + ['no-bwc', channel(), undefined, BWC], + ['no-bwc', noBwcChannel(), undefined, NOT_BWC], + ['no-bwc', undefined, undefined, undefined], + ] as const)('documentApiKind: %s, before: %s, after: %s', ( + documentApiKind, + beforeJso, + afterJso, + expected, + ) => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction(documentApiKind) + expect(scopeFunction(['channels', 'ch1'], beforeJso, afterJso)).toBe(expected) + }) + }) + + describe('Operations scope', () => { + it.each([ + // default | before | after | expected + ['bwc', operation(), operation(), BWC], + ['bwc', operation(), bwcOperation(), BWC], + ['bwc', operation(), noBwcOperation(), NOT_BWC], + ['bwc', bwcOperation(), operation(), BWC], + ['bwc', bwcOperation(), bwcOperation(), BWC], + ['bwc', bwcOperation(), noBwcOperation(), NOT_BWC], + ['bwc', noBwcOperation(), operation(), NOT_BWC], + ['bwc', noBwcOperation(), bwcOperation(), NOT_BWC], + ['bwc', noBwcOperation(), noBwcOperation(), NOT_BWC], + ['bwc', undefined, operation(), BWC], + ['bwc', undefined, noBwcOperation(), NOT_BWC], + ['bwc', operation(), undefined, BWC], + ['bwc', noBwcOperation(), undefined, NOT_BWC], + ['bwc', undefined, undefined, undefined], + ['no-bwc', operation(), operation(), BWC], + ['no-bwc', operation(), bwcOperation(), BWC], + ['no-bwc', operation(), noBwcOperation(), NOT_BWC], + ['no-bwc', bwcOperation(), operation(), BWC], + ['no-bwc', bwcOperation(), bwcOperation(), BWC], + ['no-bwc', bwcOperation(), noBwcOperation(), NOT_BWC], + ['no-bwc', noBwcOperation(), operation(), NOT_BWC], + ['no-bwc', noBwcOperation(), bwcOperation(), NOT_BWC], + ['no-bwc', noBwcOperation(), noBwcOperation(), NOT_BWC], + ['no-bwc', undefined, operation(), BWC], + ['no-bwc', undefined, noBwcOperation(), NOT_BWC], + ['no-bwc', operation(), undefined, BWC], + ['no-bwc', noBwcOperation(), undefined, NOT_BWC], + ['no-bwc', undefined, undefined, undefined], + ] as const)('documentApiKind: %s, before: %s, after: %s', ( + documentApiKind, + beforeJso, + afterJso, + expected, + ) => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction(documentApiKind) + expect(scopeFunction(['operations', 'op1'], beforeJso, afterJso)).toBe(expected) + }) + + it('should use channel x-api-kind as fallback when operation has no x-api-kind', () => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction() + const before = { + action: 'receive', + channel: { [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_NO_BWC }, + } + const after = { action: 'receive', channel: {} } + expect(scopeFunction(['operations', 'op1'], before, after)).toBe(NOT_BWC) + }) + + it('should let operation x-api-kind override channel x-api-kind', () => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction() + const before = { + action: 'receive', + [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_BWC, + channel: { [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_NO_BWC }, + } + const after = { + action: 'receive', + [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_BWC, + channel: { [API_KIND_SPECIFICATION_EXTENSION]: APIHUB_API_COMPATIBILITY_KIND_NO_BWC }, + } + expect(scopeFunction(['operations', 'op1'], before, after)).toBe(BWC) + }) + }) + + describe('Other paths', () => { + const scopeFunction = createAsyncApiCompatibilityScopeFunction() + + it('should return undefined for non-operations/non-channels paths', () => { + expect(scopeFunction(['components', 'messages'], {}, {})).toBeUndefined() + }) + + it('should return undefined for deeper operation paths', () => { + expect(scopeFunction(['operations', 'op1', 'channel'], {}, {})).toBeUndefined() + }) + + it('should return undefined for deeper channel paths', () => { + expect(scopeFunction(['channels', 'ch1', 'messages'], {}, {})).toBeUndefined() + }) + }) + }) + }) + + describe('AsyncAPI operation/channel compatibility apiKind application', () => { + let operationNoKindChannelNoKind: ApiOperation + let operationNoKindChannelBWC: ApiOperation + let operationNoKindChannelNoBWC: ApiOperation + let operationBWCChannelNoKind: ApiOperation + let operationNoBWCChannelNoKind: ApiOperation + let operationBWCChannelBWC: ApiOperation + let operationBWCChannelNoBWC: ApiOperation + let operationNoBWCChannelBWC: ApiOperation + let operationNoBWCChannelNoBWC: ApiOperation + + beforeAll(async () => { + const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base') + ;[ + operationNoKindChannelNoKind, + operationNoKindChannelBWC, + operationNoKindChannelNoBWC, + operationBWCChannelNoKind, + operationNoBWCChannelNoKind, + operationBWCChannelBWC, + operationBWCChannelNoBWC, + operationNoBWCChannelBWC, + operationNoBWCChannelNoBWC, + ] = Array.from(result.operations.values()) + }) + + it('operationNoKindChannelNoKind → BWC', () => { + expect(operationNoKindChannelNoKind.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('operationNoKindChannelBWC → BWC', () => { + expect(operationNoKindChannelBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('operationNoKindChannelNoBWC → NoBWC', () => { + expect(operationNoKindChannelNoBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + }) + + it('operationBWCChannelNoKind → BWC', () => { + expect(operationBWCChannelNoKind.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('operationNoBWCChannelNoKind → NoBWC', () => { + expect(operationNoBWCChannelNoKind.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + }) + + it('operationBWCChannelBWC → BWC', () => { + expect(operationBWCChannelBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('operationBWCChannelNoBWC → BWC', () => { + expect(operationBWCChannelNoBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('operationNoBWCChannelBWC → NoBWC', () => { + expect(operationNoBWCChannelBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + }) + + it('operationNoBWCChannelNoBWC → NoBWC', () => { + expect(operationNoBWCChannelNoBWC.apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + }) + }) + + it('should apply channel apiKind to all operations using that channel', async () => { + const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/share-channel-api-kind') + const operations = Array.from(result.operations.values()) + + expect(operations.every(operation => operation.apiKind === APIHUB_API_COMPATIBILITY_KIND_NO_BWC)).toBeTrue() + }) + + describe('Labels should not redefine AsyncAPI apiKind', () => { + it('should not override default BWC apiKind with no-BWC label', async () => { + const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base', ['apihub/x-api-kind: no-BWC']) + const operations = Array.from(result.operations.values()) + // First operation has no x-api-kind on operation or channel — should stay BWC despite label + expect(operations[0].apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_BWC) + }) + + it('should not override channel NO_BWC apiKind with BWC label', async () => { + const result = await buildPackageWithDefaultConfig('asyncapi/api-kind/base', ['apihub/x-api-kind: BWC']) + const operations = Array.from(result.operations.values()) + // Third operation uses channel-no-bwc — should stay NO_BWC despite BWC label + expect(operations[2].apiKind).toEqual(APIHUB_API_COMPATIBILITY_KIND_NO_BWC) + }) + }) +}) diff --git a/test/asyncapi-changelog-apikind.test.ts b/test/asyncapi-changelog-apikind.test.ts new file mode 100644 index 00000000..ffd9c3c0 --- /dev/null +++ b/test/asyncapi-changelog-apikind.test.ts @@ -0,0 +1,108 @@ +import { + buildChangelogPackageDefaultConfig, + changesSummaryMatcher, + numberOfImpactedOperationsMatcher, +} from './helpers' +import { ASYNCAPI_API_TYPE, BREAKING_CHANGE_TYPE, RISKY_CHANGE_TYPE, UNCLASSIFIED_CHANGE_TYPE } from '../src' + +describe('AsyncAPI changelog api-kind tests', () => { + type ApiKindCase = [string, string, Record] + + const runApiKindCases = (scope: string, cases: ApiKindCase[]): void => { + test.each(cases)('%s (%s)', async (_description, caseName, expected) => { + const result = await buildChangelogPackageDefaultConfig(`asyncapi-changelog-apikind/${scope}/${caseName}`) + expect(result).toEqual(changesSummaryMatcher(expected, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher(expected, ASYNCAPI_API_TYPE)) + }) + } + + const apiKindTransitionCases: ApiKindCase[] = [ + ['should apply BWC by default when no x-api-kind is set', 'none-to-none', { [BREAKING_CHANGE_TYPE]: 1 }], + ['should apply BWC when x-api-kind: BWC added in current document', 'none-to-bwc', { [BREAKING_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply no-BWC when x-api-kind: no-BWC added in current document', 'none-to-nobwc', { [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply BWC when x-api-kind: BWC removed in current document', 'bwc-to-none', { [BREAKING_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply BWC when x-api-kind: BWC in both documents', 'bwc-to-bwc', { [BREAKING_CHANGE_TYPE]: 1 }], + ['should apply no-BWC when x-api-kind changed from BWC to no-BWC', 'bwc-to-nobwc', { [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply no-BWC when x-api-kind: no-BWC in previous document and removed in current', 'nobwc-to-none', { [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply no-BWC when x-api-kind changed from no-BWC to BWC', 'nobwc-to-bwc', { [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }], + ['should apply no-BWC when x-api-kind: no-BWC in both documents', 'nobwc-to-nobwc', { [RISKY_CHANGE_TYPE]: 1 }], + ] + + describe('Operation-level x-api-kind', () => { + runApiKindCases('operation', apiKindTransitionCases) + }) + + describe('Channel-level x-api-kind', () => { + runApiKindCases('channel', apiKindTransitionCases) + }) + + describe('Operation + Channel x-api-kind', () => { + test('should apply BWC from channel when operation has no x-api-kind', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/operation/channel-bwc-operation-none') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should apply no-BWC from channel when operation has no x-api-kind', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/operation/channel-nobwc-operation-none') + expect(result).toEqual(changesSummaryMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should prioritize operation no-BWC over channel BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc') + expect(result).toEqual(changesSummaryMatcher({ [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [RISKY_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should prioritize operation BWC over channel no-BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1, [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + }) + + describe('Remove operation tests', () => { + test('should apply removed operation as BWC when operation has x-api-kind: BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-operation-bwc') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should apply removed operation as no-BWC when operation has x-api-kind: no-BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-operation-nobwc') + expect(result).toEqual(changesSummaryMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should apply removed operation as BWC by default when no x-api-kind is set', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-operation-none') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should prioritize removed operation BWC over channel no-BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should prioritize removed operation no-BWC over channel BWC', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc') + expect(result).toEqual(changesSummaryMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should fallback to channel no-BWC when removed operation has no x-api-kind', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none') + expect(result).toEqual(changesSummaryMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [RISKY_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + test('should fallback to channel BWC when removed operation has no x-api-kind', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + }) +}) diff --git a/test/asyncapi-changes.test.ts b/test/asyncapi-changes.test.ts index c1e06b97..7543b5d5 100644 --- a/test/asyncapi-changes.test.ts +++ b/test/asyncapi-changes.test.ts @@ -1,152 +1,566 @@ - import { buildChangelogPackageDefaultConfig, changesSummaryMatcher, noChangesMatcher, numberOfImpactedOperationsMatcher, + operationChangesMatcher, operationTypeMatcher, } from './helpers' import { ANNOTATION_CHANGE_TYPE, ASYNCAPI_API_TYPE, BREAKING_CHANGE_TYPE, + BuildResult, + EMPTY_CHANGE_SUMMARY, NON_BREAKING_CHANGE_TYPE, UNCLASSIFIED_CHANGE_TYPE, } from '../src' -// TODO Enable tests when changes are added -describe.skip('AsyncAPI 3.0 Changelog', () => { +describe('AsyncAPI 3.0 Changelog tests', () => { + + const expectNoChanges = (result: BuildResult): void => { + expect(result).toEqual(noChangesMatcher(ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher(EMPTY_CHANGE_SUMMARY, ASYNCAPI_API_TYPE)) + } - test('no changes', async () => { + test('should report no changes for identical documents', async () => { const result = await buildChangelogPackageDefaultConfig( 'asyncapi-changes/no-changes', [{ fileId: 'before.yaml', publish: true }], - [{ fileId: 'before.yaml' }], + [{ fileId: 'before.yaml', publish: true }], ) - expect(result).toEqual(noChangesMatcher(ASYNCAPI_API_TYPE)) - }) - - describe('Channels', () => { - test('add channel', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/add') - - expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - }) - - test('remove channel', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/remove') - - expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - }) - - test('change channel address', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/change') - - expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - }) + expectNoChanges(result) }) describe('Operations tests', () => { - test('add operation', async () => { + test('should report added operation', async () => { const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/add') expect(result).toEqual(changesSummaryMatcher({ [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ operationId: 'operation2-message1' }), + ])) }) - test('add multiple operations', async () => { + test('should report multiple added operations', async () => { const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/add-multiple') expect(result).toEqual(changesSummaryMatcher({ [NON_BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [NON_BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ operationId: 'operation2-message1' }), + expect.objectContaining({ operationId: 'operation3-message1' }), + ])) + }) + + test('should report added operation with multiple messages', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/add-with-multiple-messages') + expect(result).toEqual(changesSummaryMatcher({ [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ operationId: 'operation2-message1' }), + expect.objectContaining({ operationId: 'operation2-message2' }), + ])) + }) + + test('should report added operation without message change diffs', async () => { + // operation2 (send) added + message1 payload userId type changed (string → integer). + // The added operation should only produce "add" diff, + // not inherit the breaking payload change from message1. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/add-with-changed-message') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1, [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + expect.objectContaining({ operationId: 'operation2-message1' }), + ])) }) - test('remove operation', async () => { + test('should report removed operation', async () => { const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/remove') expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ previousOperationId: 'operation2-message1' }), + ])) }) - test('add and remove operations', async () => { + test('should report simultaneously added and removed operations', async () => { const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/add-remove') expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1, [NON_BREAKING_CHANGE_TYPE]: 1, }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ - [BREAKING_CHANGE_TYPE]: 1, - [NON_BREAKING_CHANGE_TYPE]: 1, - }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ previousOperationId: 'old-operation-message1' }), + expect.objectContaining({ operationId: 'new-operation-message1' }), + ])) }) - test('change operation', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/change') + test('should report changed operation action type', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/change-action') - expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) }) - test('renamed operation as add/remove', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/rename') + test('should report changed operation description with multiple messages', async () => { + // operation1 has message1 and message2. Only operation description changed (test1 → test2). + // The annotation diff is counted once in changesSummary but impacts 2 apihub operations + // (one per message: operation1-message1, operation1-message2). + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/operation/change-description-with-multiple-messages') + expect(result).toEqual(changesSummaryMatcher({ - [BREAKING_CHANGE_TYPE]: 1, - [NON_BREAKING_CHANGE_TYPE]: 1, - }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ - [BREAKING_CHANGE_TYPE]: 1, - [NON_BREAKING_CHANGE_TYPE]: 1, + [ANNOTATION_CHANGE_TYPE]: 1, }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + expect.objectContaining({ + operationId: 'operation1-message2', + previousOperationId: 'operation1-message2', + }), + ])) }) }) - describe('Servers', () => { - test('add server', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/add') + describe('Channels tests', () => { + test('should be tolerant to channel reference change', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/change-reference') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation2-message1', + previousOperationId: 'operation2-message1', + }), + ])) + }) + + test('should not report changes when removing unused channel', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/remove-unused') + + expectNoChanges(result) + }) + + test('should report changed channel address', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/change-address') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should impact all operations on shared channel when changing address', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/change-address-shared-channel') + + // operation1 and operation2 both reference channel1, address changed + // both apihub operations should be impacted + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + expect.objectContaining({ + operationId: 'operation2-message2', + previousOperationId: 'operation2-message2', + }), + ])) + }) + + test('should not report changes when adding message definition in channel without referencing it in operation', async () => { + // message2 added to channel1.messages but operation1.messages still only references message1 + // channel.messages add/remove diffs are filtered out — only operation.messages references matter + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/add-message-not-in-operation') + + expectNoChanges(result) + }) + + test('should not impact operation on other channel when changing address', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/channel/change-address-no-impact-on-other-channel') + + // channel1 address changed, channel2 unchanged + // only operation1 (on channel1) should be impacted, not operation2 (on channel2) + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + }) + + describe('Servers tests', () => { + test('should report added server in channel', async () => { + // Server reference added to channel1.servers — channel-level diff only + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/add-to-channel') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should report removed server from channel', async () => { + // Server reference removed from channel1.servers — channel-level diff only + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/remove-from-channel') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should report changed server used in channel', async () => { + // Server host changed (api.example.com → api.production.example.com). + // Server is referenced by channel1.servers → diff propagates via channel aggregation. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/change-in-channel') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should only impact operation whose channel references the changed server', async () => { + // Two channels, two servers: channel1→server1, channel2→server2. + // Only server1 host changed (api1 → new-api1). + // operation1 (on channel1) should get the diff, operation2 (on channel2) should not. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/change-isolated-servers') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + // TODO: unskip when root servers propagate to channel.servers during normalization + test.skip('should report added server on operation when channel has no explicit servers', async () => { + // servers.production added at root, channel1 has no explicit servers. + // If channel.servers is absent, all root servers apply to the channel. + // The add diff should reach the operation via channel.servers aggregation. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/add-root') expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) expect(result).toEqual(numberOfImpactedOperationsMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) }) - test('remove server', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/remove') + // TODO: unskip when root servers propagate to channel.servers during normalization + test.skip('should report removed server on operation when channel has no explicit servers', async () => { + // servers.production removed from root, channel1 has no explicit servers. + // If channel.servers is absent, all root servers apply to the channel. + // The remove diff should reach the operation via channel.servers aggregation. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/remove-root') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + + // TODO: unskip when root servers propagate to channel.servers during normalization + test.skip('should report changed server on operation when channel has no explicit servers', async () => { + // servers.production.host changed, channel1 has no explicit servers. + // If channel.servers is absent, all root servers apply to the channel. + // The host change diff should reach the operation via channel.servers aggregation. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/change-root') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + }) + }) + + describe('Messages tests', () => { + test('should report added APIHUB operation when message reference is added to async operation', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/add-to-operation') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ operationId: 'operation1-message2' }), + ])) + }) + + test('should report removed APIHUB operation when message reference is removed from async operation', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/remove-from-operation') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ previousOperationId: 'operation1-message2' }), + ])) + }) + + test('should report changed message content type', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/change-content-type') expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) }) - test('change server', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/change') + test('should not impact other operation when adding message to one', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/add-to-one-of-multiple-operations') - expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + // message2 added to operation1, operation2 unchanged + // should only impact 1 new apihub operation (operation1-message2) + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message2', + }), + ])) }) - test('add root servers', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/add-root') + test('should not add changes to remaining messages when removing message from operation', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/remove-from-operation-with-remaining-messages') + + // Removing message2 from operation with message1, message2, message3 + // should only impact 1 removed apihub operation (operation1-message2), + // not the remaining operation1-message1 and operation1-message3 + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + previousOperationId: 'operation1-message2', + }), + ])) + }) + + test('should only impact changed message when changing content type with multiple messages', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/change-content-type-with-multiple-messages') + + // Changing contentType of message1 in operation with message1 and message2 + // should only impact operation1-message1, not operation1-message2 + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should impact both operations when changing shared payload with multiple messages', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/change-shared-payload-with-multiple-messages') + + // message1 and message2 both reference SharedPayload schema + // changing SharedPayload type should impact both apihub operations + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + expect.objectContaining({ + operationId: 'operation1-message2', + previousOperationId: 'operation1-message2', + }), + ])) + }) + + test('should not leak add-message diff to existing sibling message operations', async () => { + // operation1 has message1, message2. message3 is added to operation1. + // The add diff should only appear on the new operation1-message3, + // not on existing operation1-message1 or operation1-message2. + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/add-message-no-sibling-impact') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message3', + }), + ])) + }) + + test('should correctly separate operation-level and message-level changes', async () => { + // operation1 with message1 and message2. + // Changes: operation description changed (annotation, shared by both messages) + // + message1 contentType changed (breaking, specific to message1 only) + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/mixed-operation-and-message-changes') + + expect(result).toEqual(changesSummaryMatcher({ + [ANNOTATION_CHANGE_TYPE]: 1, + [BREAKING_CHANGE_TYPE]: 1, + }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + expect.objectContaining({ + operationId: 'operation1-message2', + previousOperationId: 'operation1-message2', + }), + ])) + }) + + test('should not report changes when adding unused component message', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/add-unused-component-message') + + // Adding a message to components/messages that is not referenced by any channel or operation + // should not impact any apihub operations + expectNoChanges(result) + }) + + test('should not report changes when removing unused component message', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/message/remove-unused-component-message') + + // Removing a message from components/messages that is not referenced by any operation + // should not impact any apihub operations + expectNoChanges(result) + }) + }) + + describe('Schema tests', () => { + test('should report added property in message schema', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/schema/add-property') + + expect(result).toEqual(changesSummaryMatcher({ [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should report removed property from message schema', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/schema/remove-property') + + expect(result).toEqual(changesSummaryMatcher({ [NON_BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should report changed property type in message schema', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/schema/change-property-type') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + }) + + describe('Info tests', () => { + test('should report changed info version', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-version') + + // info.version changed (1.0.0 -> 2.0.0) — should be reported as a change in every apihub operation expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) }) - test('remove root servers', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/remove-root') + test('should report changed info title', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-title') + // info.title changed — should be reported as a change in every apihub operation expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) }) - test('change root servers', async () => { - const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/server/change-root') + test('should report changed document id', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-id') expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) - expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should report changed defaultContentType', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-default-content-type') + + // defaultContentType changed (json → xml). + // message1 has no explicit contentType → normalization resolves defaultContentType + // into effective contentType, so the change propagates as a breaking diff. + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) + }) + + test('should only affect message without explicit contentType when defaultContentType changes in same operation', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-default-content-type-mixed-messages') + + // One operation with two messages: + // message1 has explicit contentType → not affected by defaultContentType change. + // message2 has no explicit contentType → affected via normalization. + // Only operation1-message2 should be impacted. + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message2', + previousOperationId: 'operation1-message2', + }), + ])) + }) + + test('should report defaultContentType change when message explicit contentType is removed', async () => { + const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/info/change-default-content-type-with-removed-override') + + // Before: message1 has explicit contentType (json), defaultContentType is json. + // After: message1 explicit contentType removed, defaultContentType changed to xml. + // message1 now inherits from defaultContentType → affected by the effective contentType change. + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(operationChangesMatcher([ + expect.objectContaining({ + operationId: 'operation1-message1', + previousOperationId: 'operation1-message1', + }), + ])) }) }) - describe('tags', () => { - test('Tags are not duplicated', async () => { + describe('Tags tests', () => { + test('should not duplicate tags', async () => { const result = await buildChangelogPackageDefaultConfig('asyncapi-changes/tags') expect(result).toEqual(operationTypeMatcher({ @@ -157,9 +571,22 @@ describe.skip('AsyncAPI 3.0 Changelog', () => { 'sameTagInDifferentSiblings1', 'sameTagInDifferentSiblings2', 'sameTagInDifferentSiblings3', + 'sameTagInOperationSiblings1', 'tag', ]), })) }) }) + + describe('Duplicate operationId across documents', () => { + test('should throw error during changelog when same operationId appears in multiple documents', async () => { + // Same operation (operation1-message1) described in two documents. + // AsyncAPI does not allow duplicate operationIds across documents — must throw. + await expect(buildChangelogPackageDefaultConfig( + 'asyncapi-deduplication/cross-document-dedup', + [{ fileId: 'before1.yaml', publish: true }, { fileId: 'before2.yaml', publish: true }], + [{ fileId: 'after1.yaml' }, { fileId: 'after2.yaml' }], + )).rejects.toThrow(/Duplicated operationId 'operation1-message1'/) + }) + }) }) diff --git a/test/asyncapi-deduplication.test.ts b/test/asyncapi-deduplication.test.ts new file mode 100644 index 00000000..23c2c3c6 --- /dev/null +++ b/test/asyncapi-deduplication.test.ts @@ -0,0 +1,125 @@ +import { + buildChangelogPackageDefaultConfig, + changesSummaryMatcher, + numberOfImpactedOperationsMatcher, +} from './helpers' +import { ANNOTATION_CHANGE_TYPE, ASYNCAPI_API_TYPE, BREAKING_CHANGE_TYPE, UNCLASSIFIED_CHANGE_TYPE } from '../src' + +/** + * Tests for AsyncAPI diff deduplication. + * + * Deduplication in AsyncAPI works at two stages: + * + * Within one document pair (by reference identity): + * - `aggregateDiffsWithRollup` propagates diffs bottom-up via Set + * - Same Diff instance can appear in multiple operations (e.g. shared component schema) + * - `comparePairedDocs` deduplicates via `new Set(allDiffs)` — reference identity + * + * Across multiple document pairs (by content hash): + * - Rare case: one operation in multiple documents → multiple apiDiff() calls + * - Uses `removeObjectDuplicates(diffs, calculateDiffId)` for content-based dedup + */ +describe('AsyncAPI deduplication tests', () => { + + describe('Shared entities in the same specification', () => { + test('shared schema, different scopes (receive vs send)', async () => { + // Two operations (operation1=receive, operation2=send) on different channels, + // both messages referencing SharedPayload. Changing SharedPayload type (number → string). + // apiDiff resolves $refs per scope → separate diff instances per scope. + const result = await buildChangelogPackageDefaultConfig('asyncapi-deduplication/shared-schema-across-operations') + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('shared schema, same scope (both receive)', async () => { + // Two operations (both receive) on different channels, + // both messages referencing SharedPayload. Changing SharedPayload type (number → string). + // Same scope → diffs should be deduplicated by reference identity within one apiDiff call. + const result = await buildChangelogPackageDefaultConfig('asyncapi-deduplication/shared-schema-same-scope') + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('should count info.version change once in changesSummary but impact all operations', async () => { + // Two operations. info.version changed (1.0.0 → 2.0.0). + // The info diff is extracted and added to every operation via extractInfoDiffs(), + // but it's the same semantic change — changesSummary should count 1, impacted 2. + const result = await buildChangelogPackageDefaultConfig('asyncapi-deduplication/root-info-change-multiple-operations') + + expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('should count root server change once in changesSummary but impact all operations', async () => { + // Two operations on different channels, both channels reference servers.production. + // Root server host changed (old → new). + // Each scope (receive/send) gets its own unclassified diff via channel.servers aggregation. + // No root-level diffs — server diffs come only through channel aggregation. + // unclassified: 2 in summary (one per scope), impacted 2. + const result = await buildChangelogPackageDefaultConfig('asyncapi-deduplication/root-server-change-multiple-operations') + + expect(result).toEqual(changesSummaryMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [UNCLASSIFIED_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('should deduplicate defaultContentType diff across multiple messages without explicit contentType', async () => { + // One operation with two messages, both without explicit contentType. + // defaultContentType changed (json → xml) — both messages inherit it. + // The diff should be counted once in changesSummary but impact both apihub operations. + const result = await buildChangelogPackageDefaultConfig('asyncapi-deduplication/default-content-type-multiple-messages') + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + }) + + describe('Shared entities across different specifications', () => { + test('shared schema name in two specs, different scopes (receive vs send)', async () => { + // operation1 (receive) in doc1, operation2 (send) in doc2. + // Both specs define SharedPayload with same change (number → string). + // Different scopes → separate apiDiff calls → separate diff instances. + // Cross-document content-based dedup (calculateDiffId) applies per operation, + // but these operations have different scope, so both changes are counted. + const result = await buildChangelogPackageDefaultConfig( + 'asyncapi-deduplication/shared-schema-cross-specs', + [{ fileId: 'before1.yaml', publish: true }, { fileId: 'before2.yaml', publish: true }], + [{ fileId: 'after1.yaml' }, { fileId: 'after2.yaml' }], + ) + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('shared schema name in two specs, same scope (both receive)', async () => { + // operation1 (receive) in doc1, operation2 (receive) in doc2. + // Both specs define SharedPayload with same change (number → string). + // Same scope → same group, but different documents → separate doc pairs → two apiDiff calls. + // Cross-document content-based dedup via calculateDiffId merges identical diffs. + const result = await buildChangelogPackageDefaultConfig( + 'asyncapi-deduplication/shared-schema-cross-specs-same-scope', + [{ fileId: 'before1.yaml', publish: true }, { fileId: 'before2.yaml', publish: true }], + [{ fileId: 'after1.yaml' }, { fileId: 'after2.yaml' }], + ) + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + test('same schema name in two specs but different content should not deduplicate', async () => { + // operation1 in doc1 with SharedPayload{userId: number→string}, + // operation2 in doc2 with SharedPayload{orderId: integer→string}. + // Same schema name but different properties/changes → no dedup, both counted separately. + const result = await buildChangelogPackageDefaultConfig( + 'asyncapi-deduplication/shared-schema-cross-specs-different-content', + [{ fileId: 'before1.yaml', publish: true }, { fileId: 'before2.yaml', publish: true }], + [{ fileId: 'after1.yaml' }, { fileId: 'after2.yaml' }], + ) + + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 2 }, ASYNCAPI_API_TYPE)) + }) + + }) +}) diff --git a/test/asyncapi-deprecated.test.ts b/test/asyncapi-deprecated.test.ts index 370ea132..83299488 100644 --- a/test/asyncapi-deprecated.test.ts +++ b/test/asyncapi-deprecated.test.ts @@ -50,7 +50,7 @@ describe('AsyncAPI 3.0 Deprecated tests', () => { deprecatedItems = Array.from(result.operations.values()).flatMap(operation => operation.deprecatedItems ?? []) }) - test('should detect deprecated messages', async () => { + test('should report deprecated messages', async () => { const [deprecatedItem] = deprecatedItems expect(deprecatedItems.length).toBeGreaterThan(0) @@ -79,7 +79,7 @@ describe('AsyncAPI 3.0 Deprecated tests', () => { expect(operation.deprecated).toBe(true) }) - test('should detect deprecated schemas (flag "deprecated" in payload schema)', async () => { + test('should report deprecated schemas (flag "deprecated" in payload schema)', async () => { const result = await buildPackageWithDefaultConfig('asyncapi/deprecated/schemas') const deprecatedItems = Array.from(result.operations.values()).flatMap(operation => operation.deprecatedItems ?? []) expect(deprecatedItems.length).toBeGreaterThan(0) diff --git a/test/asyncapi-operation.test.ts b/test/asyncapi-operation.test.ts index a25ab1c3..4aef3fd9 100644 --- a/test/asyncapi-operation.test.ts +++ b/test/asyncapi-operation.test.ts @@ -18,12 +18,19 @@ import { beforeAll, describe, expect, it, test } from '@jest/globals' import { v3 as AsyncAPIV3 } from '@asyncapi/parser/esm/spec-types' import { createOperationSpec, createOperationSpecWithInlineRefs } from '../src/apitypes/async/async.operation' import { calculateAsyncOperationId } from '../src/utils' -import { buildPackageWithDefaultConfig, cloneDocument, loadYamlFile } from './helpers' +import { buildPackageWithDefaultConfig, cloneDocument, loadYamlFile, LocalRegistry } from './helpers' import { extractProtocol } from '../src/apitypes/async/async.utils' import { FIRST_REFERENCE_KEY_PROPERTY, INLINE_REFS_FLAG } from '../src/consts' -import { ASYNC_EFFECTIVE_NORMALIZE_OPTIONS } from '../src' +import { ASYNC_EFFECTIVE_NORMALIZE_OPTIONS, BUILD_TYPE, VERSION_STATUS } from '../src' import { normalize } from '@netcracker/qubership-apihub-api-unifier' +const normalizeAsyncApiDocument = (doc: AsyncAPIV3.AsyncAPIObject): AsyncAPIV3.AsyncAPIObject => + normalize(doc, { + ...ASYNC_EFFECTIVE_NORMALIZE_OPTIONS, + firstReferenceKeyProperty: FIRST_REFERENCE_KEY_PROPERTY, + inlineRefsFlag: INLINE_REFS_FLAG, + }) as AsyncAPIV3.AsyncAPIObject + describe('AsyncAPI 3.0 Operation Tests', () => { describe('Building Package with Operations', () => { @@ -250,11 +257,7 @@ describe('AsyncAPI 3.0 Operation Tests', () => { baseDocument = await loadYamlFile('asyncapi/operations/base.yaml') - normalizedDocument = normalize(baseDocument, { - ...ASYNC_EFFECTIVE_NORMALIZE_OPTIONS, - firstReferenceKeyProperty: FIRST_REFERENCE_KEY_PROPERTY, - inlineRefsFlag: INLINE_REFS_FLAG, - }) as AsyncAPIV3.AsyncAPIObject + normalizedDocument = normalizeAsyncApiDocument(baseDocument) }) test('should select a single operation by key', () => { @@ -372,4 +375,80 @@ describe('AsyncAPI 3.0 Operation Tests', () => { expect(operationKeys).not.toContain(OPERATION_KEY_2) }) }) + + // TODO: unskip after api-unifier propagates root servers to channels during normalization. + describe('Root servers propagation to channels without explicit servers', () => { + const ROOT_SERVERS_DOC_PATH = 'asyncapi/operations/root-servers-no-channel-servers.yaml' + const OP_KEY = 'operation1' + const MSG_ID = 'message1' + let rootServersDoc: AsyncAPIV3.AsyncAPIObject + let rootServersNormalizedDoc: AsyncAPIV3.AsyncAPIObject + let rootServersOpId: string + + const createRefsMsg = (messageId: string, inlineRefs: string[]): Record => { + const message: Record = {} + message[FIRST_REFERENCE_KEY_PROPERTY] = messageId + message[INLINE_REFS_FLAG] = inlineRefs + return message + } + + beforeAll(async () => { + rootServersOpId = calculateAsyncOperationId(OP_KEY, MSG_ID) + rootServersDoc = await loadYamlFile(ROOT_SERVERS_DOC_PATH) + rootServersNormalizedDoc = normalizeAsyncApiDocument(rootServersDoc) + }) + + test.skip('createOperationSpec should include root servers when channel has no explicit servers', () => { + // After api-unifier normalization, channel1.servers should contain all root servers. + // createOperationSpec works on the normalized document, so the operation spec + // should include the servers that were propagated to the channel. + const result = createOperationSpec(rootServersNormalizedDoc, rootServersOpId) + + expect(result.servers).toBeDefined() + expect(Object.keys(result.servers!)).toEqual(expect.arrayContaining(['production', 'staging'])) + }) + + test.skip('createOperationSpecWithInlineRefs should include root servers when channel has no explicit servers', () => { + // Same as above but via createOperationSpecWithInlineRefs path. + const refsOnlyDocument = { + operations: { + [OP_KEY]: { + messages: [ + createRefsMsg(MSG_ID, ['#/channels/channel1/messages/message1']), + ], + }, + }, + [INLINE_REFS_FLAG]: [ + '#/servers/production', + '#/servers/staging', + '#/channels/channel1', + '#/channels/channel1/messages/message1', + '#/components/messages/message1', + ], + } as unknown as AsyncAPIV3.AsyncAPIObject + + const result = createOperationSpecWithInlineRefs(rootServersDoc, rootServersOpId, refsOnlyDocument) + + expect(result.servers).toBeDefined() + expect(Object.keys(result.servers!)).toEqual(expect.arrayContaining(['production', 'staging'])) + }) + }) + + describe('Duplicate operationId validation', () => { + test('should throw error during build when same operationId appears in multiple documents', async () => { + const packageId = 'asyncapi-changes/operation/duplicate-cross-document' + const portal = new LocalRegistry(packageId) + + await expect(portal.publish(packageId, { + packageId, + version: 'v1', + status: VERSION_STATUS.RELEASE, + buildType: BUILD_TYPE.BUILD, + files: [ + { fileId: 'spec1.yaml', publish: true }, + { fileId: 'spec2.yaml', publish: true }, + ], + })).rejects.toThrow(/Duplicated operationId 'operation1-message1'/) + }) + }) }) diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/after.yaml new file mode 100644 index 00000000..f4ecb13d --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/before.yaml new file mode 100644 index 00000000..f4d418b5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-bwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/after.yaml new file mode 100644 index 00000000..4260cd79 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/before.yaml new file mode 100644 index 00000000..f4d418b5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-nobwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/before.yaml new file mode 100644 index 00000000..f4d418b5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/bwc-to-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/after.yaml new file mode 100644 index 00000000..f4ecb13d --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/before.yaml new file mode 100644 index 00000000..4ca386aa --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-bwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/after.yaml new file mode 100644 index 00000000..4260cd79 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/before.yaml new file mode 100644 index 00000000..4ca386aa --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-nobwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/before.yaml new file mode 100644 index 00000000..4ca386aa --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/nobwc-to-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/after.yaml new file mode 100644 index 00000000..f4ecb13d --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-bwc/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/after.yaml new file mode 100644 index 00000000..4260cd79 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-nobwc/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/channel/none-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/channel/none-to-none/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/channel/none-to-none/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/after.yaml new file mode 100644 index 00000000..414505a8 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/before.yaml new file mode 100644 index 00000000..f980de0f --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-bwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/after.yaml new file mode 100644 index 00000000..5c2abbe5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/before.yaml new file mode 100644 index 00000000..f980de0f --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-nobwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/before.yaml new file mode 100644 index 00000000..f980de0f --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/bwc-to-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/after.yaml new file mode 100644 index 00000000..f4ecb13d --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/before.yaml new file mode 100644 index 00000000..c5ff24b0 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-nobwc/before.yaml @@ -0,0 +1,27 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/after.yaml new file mode 100644 index 00000000..f4ecb13d --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/before.yaml new file mode 100644 index 00000000..f4d418b5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-bwc-operation-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/after.yaml new file mode 100644 index 00000000..4260cd79 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/before.yaml new file mode 100644 index 00000000..4b644d10 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-bwc/before.yaml @@ -0,0 +1,27 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/after.yaml new file mode 100644 index 00000000..4260cd79 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/before.yaml new file mode 100644 index 00000000..4ca386aa --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/channel-nobwc-operation-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/after.yaml new file mode 100644 index 00000000..414505a8 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/before.yaml new file mode 100644 index 00000000..3d87cb75 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-bwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/after.yaml new file mode 100644 index 00000000..5c2abbe5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/before.yaml new file mode 100644 index 00000000..3d87cb75 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-nobwc/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/before.yaml new file mode 100644 index 00000000..3d87cb75 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/nobwc-to-none/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/after.yaml new file mode 100644 index 00000000..414505a8 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-bwc/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/after.yaml new file mode 100644 index 00000000..5c2abbe5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-nobwc/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-none/after.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-none/after.yaml new file mode 100644 index 00000000..3ed5e13e --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changelog-apikind/operation/none-to-none/before.yaml b/test/projects/asyncapi-changelog-apikind/operation/none-to-none/before.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/operation/none-to-none/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/after.yaml new file mode 100644 index 00000000..c5ff24b0 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/after.yaml @@ -0,0 +1,27 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/before.yaml new file mode 100644 index 00000000..f9a62b05 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-nobwc/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/after.yaml new file mode 100644 index 00000000..f4d418b5 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/before.yaml new file mode 100644 index 00000000..3696306c --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-bwc-operation-none/before.yaml @@ -0,0 +1,40 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/after.yaml new file mode 100644 index 00000000..4b644d10 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/after.yaml @@ -0,0 +1,27 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/before.yaml new file mode 100644 index 00000000..dd577566 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-bwc/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/after.yaml new file mode 100644 index 00000000..4ca386aa --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/before.yaml new file mode 100644 index 00000000..732f52cb --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-channel-nobwc-operation-none/before.yaml @@ -0,0 +1,40 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + x-api-kind: no-BWC + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/after.yaml new file mode 100644 index 00000000..f980de0f --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/before.yaml new file mode 100644 index 00000000..a001f188 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-bwc/before.yaml @@ -0,0 +1,41 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + x-api-kind: BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/after.yaml new file mode 100644 index 00000000..3d87cb75 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/before.yaml new file mode 100644 index 00000000..23be21dd --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-nobwc/before.yaml @@ -0,0 +1,41 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + x-api-kind: no-BWC + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/after.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/after.yaml new file mode 100644 index 00000000..1b57b3d6 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/before.yaml b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/before.yaml new file mode 100644 index 00000000..9aa04b51 --- /dev/null +++ b/test/projects/asyncapi-changelog-apikind/remove/remove-operation-none/before.yaml @@ -0,0 +1,39 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number + message2: + payload: + type: object + properties: + orderId: + type: number diff --git a/test/projects/asyncapi-changes/channel/add-message-not-in-operation/after.yaml b/test/projects/asyncapi-changes/channel/add-message-not-in-operation/after.yaml new file mode 100644 index 00000000..dbe6803c --- /dev/null +++ b/test/projects/asyncapi-changes/channel/add-message-not-in-operation/after.yaml @@ -0,0 +1,33 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/operation/rename/before.yaml b/test/projects/asyncapi-changes/channel/add-message-not-in-operation/before.yaml similarity index 99% rename from test/projects/asyncapi-changes/operation/rename/before.yaml rename to test/projects/asyncapi-changes/channel/add-message-not-in-operation/before.yaml index 8139850a..4bc38c26 100644 --- a/test/projects/asyncapi-changes/operation/rename/before.yaml +++ b/test/projects/asyncapi-changes/channel/add-message-not-in-operation/before.yaml @@ -23,4 +23,3 @@ components: properties: userId: type: string - diff --git a/test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/after.yaml b/test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/after.yaml new file mode 100644 index 00000000..baef25a0 --- /dev/null +++ b/test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/after.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: new-address + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/channel/remove/before.yaml b/test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/before.yaml similarity index 67% rename from test/projects/asyncapi-changes/channel/remove/before.yaml rename to test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/before.yaml index fcd6da1c..b3b61c0a 100644 --- a/test/projects/asyncapi-changes/channel/remove/before.yaml +++ b/test/projects/asyncapi-changes/channel/change-address-no-impact-on-other-channel/before.yaml @@ -4,15 +4,15 @@ info: version: 1.0.0 channels: channel1: - address: address1 + address: old-address messages: message1: $ref: '#/components/messages/message1' channel2: - address: address2 + address: channel2 messages: - message1: - $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' operations: operation1: action: receive @@ -25,7 +25,7 @@ operations: channel: $ref: '#/channels/channel2' messages: - - $ref: '#/channels/channel2/messages/message1' + - $ref: '#/channels/channel2/messages/message2' components: messages: message1: @@ -34,3 +34,9 @@ components: properties: userId: type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/channel/change-address-shared-channel/after.yaml b/test/projects/asyncapi-changes/channel/change-address-shared-channel/after.yaml new file mode 100644 index 00000000..b6f43d0b --- /dev/null +++ b/test/projects/asyncapi-changes/channel/change-address-shared-channel/after.yaml @@ -0,0 +1,39 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: new-address + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/channel/change-address-shared-channel/before.yaml b/test/projects/asyncapi-changes/channel/change-address-shared-channel/before.yaml new file mode 100644 index 00000000..55b18758 --- /dev/null +++ b/test/projects/asyncapi-changes/channel/change-address-shared-channel/before.yaml @@ -0,0 +1,39 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: old-address + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/channel/change/after.yaml b/test/projects/asyncapi-changes/channel/change-address/after.yaml similarity index 100% rename from test/projects/asyncapi-changes/channel/change/after.yaml rename to test/projects/asyncapi-changes/channel/change-address/after.yaml diff --git a/test/projects/asyncapi-changes/channel/change/before.yaml b/test/projects/asyncapi-changes/channel/change-address/before.yaml similarity index 100% rename from test/projects/asyncapi-changes/channel/change/before.yaml rename to test/projects/asyncapi-changes/channel/change-address/before.yaml diff --git a/test/projects/asyncapi-changes/channel/add/after.yaml b/test/projects/asyncapi-changes/channel/change-reference/after.yaml similarity index 100% rename from test/projects/asyncapi-changes/channel/add/after.yaml rename to test/projects/asyncapi-changes/channel/change-reference/after.yaml diff --git a/test/projects/asyncapi-changes/channel/add/before.yaml b/test/projects/asyncapi-changes/channel/change-reference/before.yaml similarity index 100% rename from test/projects/asyncapi-changes/channel/add/before.yaml rename to test/projects/asyncapi-changes/channel/change-reference/before.yaml diff --git a/test/projects/asyncapi-changes/operation/rename/after.yaml b/test/projects/asyncapi-changes/channel/remove-unused/after.yaml similarity index 96% rename from test/projects/asyncapi-changes/operation/rename/after.yaml rename to test/projects/asyncapi-changes/channel/remove-unused/after.yaml index c486def8..4bc38c26 100644 --- a/test/projects/asyncapi-changes/operation/rename/after.yaml +++ b/test/projects/asyncapi-changes/channel/remove-unused/after.yaml @@ -9,7 +9,7 @@ channels: message1: $ref: '#/components/messages/message1' operations: - new-operation1: + operation1: action: receive channel: $ref: '#/channels/channel1' @@ -23,4 +23,3 @@ components: properties: userId: type: string - diff --git a/test/projects/asyncapi-changes/channel/remove/after.yaml b/test/projects/asyncapi-changes/channel/remove-unused/before.yaml similarity index 75% rename from test/projects/asyncapi-changes/channel/remove/after.yaml rename to test/projects/asyncapi-changes/channel/remove-unused/before.yaml index b94ac3ac..04bed214 100644 --- a/test/projects/asyncapi-changes/channel/remove/after.yaml +++ b/test/projects/asyncapi-changes/channel/remove-unused/before.yaml @@ -4,7 +4,12 @@ info: version: 1.0.0 channels: channel1: - address: address1 + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + unusedChannel: + address: unused messages: message1: $ref: '#/components/messages/message1' @@ -15,12 +20,6 @@ operations: $ref: '#/channels/channel1' messages: - $ref: '#/channels/channel1/messages/message1' - operation2: - action: receive - channel: - $ref: '#/channels/channel1' - messages: - - $ref: '#/channels/channel1/messages/message1' components: messages: message1: diff --git a/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/after.yaml b/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/after.yaml new file mode 100644 index 00000000..a64187a4 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/after.yaml @@ -0,0 +1,36 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/xml +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/before.yaml b/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/before.yaml new file mode 100644 index 00000000..ec39e3a7 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type-mixed-messages/before.yaml @@ -0,0 +1,36 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/json +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/after.yaml b/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/after.yaml new file mode 100644 index 00000000..cd55ff34 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/xml +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/before.yaml b/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/before.yaml new file mode 100644 index 00000000..a0f70b48 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type-with-removed-override/before.yaml @@ -0,0 +1,27 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/json +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-default-content-type/after.yaml b/test/projects/asyncapi-changes/info/change-default-content-type/after.yaml new file mode 100644 index 00000000..cd55ff34 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/xml +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-default-content-type/before.yaml b/test/projects/asyncapi-changes/info/change-default-content-type/before.yaml new file mode 100644 index 00000000..faa6b464 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-default-content-type/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/json +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-id/after.yaml b/test/projects/asyncapi-changes/info/change-id/after.yaml new file mode 100644 index 00000000..dd85dcf8 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-id/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +id: urn:example:com:new +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-id/before.yaml b/test/projects/asyncapi-changes/info/change-id/before.yaml new file mode 100644 index 00000000..60389aeb --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-id/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +id: urn:example:com:old +info: + title: Test + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-title/after.yaml b/test/projects/asyncapi-changes/info/change-title/after.yaml new file mode 100644 index 00000000..2d22df2a --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-title/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: New Title + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-title/before.yaml b/test/projects/asyncapi-changes/info/change-title/before.yaml new file mode 100644 index 00000000..873caf9e --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-title/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Old Title + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-version/after.yaml b/test/projects/asyncapi-changes/info/change-version/after.yaml new file mode 100644 index 00000000..b728733f --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-version/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 2.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/info/change-version/before.yaml b/test/projects/asyncapi-changes/info/change-version/before.yaml new file mode 100644 index 00000000..4bc38c26 --- /dev/null +++ b/test/projects/asyncapi-changes/info/change-version/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/after.yaml b/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/after.yaml new file mode 100644 index 00000000..1fbdc18a --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/after.yaml @@ -0,0 +1,43 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' + - $ref: '#/channels/channel1/messages/message3' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/before.yaml b/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/before.yaml new file mode 100644 index 00000000..d06f58e4 --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-message-no-sibling-impact/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/after.yaml b/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/after.yaml new file mode 100644 index 00000000..382d8dff --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/after.yaml @@ -0,0 +1,51 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + channel2: + address: channel2 + messages: + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message3' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/before.yaml b/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/before.yaml new file mode 100644 index 00000000..99b18fe5 --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-to-one-of-multiple-operations/before.yaml @@ -0,0 +1,50 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + channel2: + address: channel2 + messages: + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message3' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-to-operation/after.yaml b/test/projects/asyncapi-changes/message/add-to-operation/after.yaml new file mode 100644 index 00000000..a6ae7999 --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-to-operation/after.yaml @@ -0,0 +1,34 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-to-operation/before.yaml b/test/projects/asyncapi-changes/message/add-to-operation/before.yaml new file mode 100644 index 00000000..dbe6803c --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-to-operation/before.yaml @@ -0,0 +1,33 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-unused-component-message/after.yaml b/test/projects/asyncapi-changes/message/add-unused-component-message/after.yaml new file mode 100644 index 00000000..d8a4af2d --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-unused-component-message/after.yaml @@ -0,0 +1,31 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + unusedMessage: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/add-unused-component-message/before.yaml b/test/projects/asyncapi-changes/message/add-unused-component-message/before.yaml new file mode 100644 index 00000000..4bc38c26 --- /dev/null +++ b/test/projects/asyncapi-changes/message/add-unused-component-message/before.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/after.yaml b/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/after.yaml new file mode 100644 index 00000000..0b56932f --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/after.yaml @@ -0,0 +1,36 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/xml + payload: + type: object + properties: + userId: + type: string + message2: + contentType: application/json + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/before.yaml b/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/before.yaml new file mode 100644 index 00000000..9964ded9 --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-content-type-with-multiple-messages/before.yaml @@ -0,0 +1,36 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string + message2: + contentType: application/json + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/change-content-type/after.yaml b/test/projects/asyncapi-changes/message/change-content-type/after.yaml new file mode 100644 index 00000000..69007815 --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-content-type/after.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + contentType: application/xml + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/message/change-content-type/before.yaml b/test/projects/asyncapi-changes/message/change-content-type/before.yaml new file mode 100644 index 00000000..0dae41b1 --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-content-type/before.yaml @@ -0,0 +1,26 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/after.yaml b/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/after.yaml new file mode 100644 index 00000000..2dac214b --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/after.yaml @@ -0,0 +1,34 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/before.yaml b/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/before.yaml new file mode 100644 index 00000000..1813f211 --- /dev/null +++ b/test/projects/asyncapi-changes/message/change-shared-payload-with-multiple-messages/before.yaml @@ -0,0 +1,34 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/after.yaml b/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/after.yaml new file mode 100644 index 00000000..20a039ba --- /dev/null +++ b/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/after.yaml @@ -0,0 +1,37 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + description: updated description + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/xml + payload: + type: object + properties: + userId: + type: string + message2: + contentType: application/json + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/before.yaml b/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/before.yaml new file mode 100644 index 00000000..7315b9fe --- /dev/null +++ b/test/projects/asyncapi-changes/message/mixed-operation-and-message-changes/before.yaml @@ -0,0 +1,37 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + description: original description + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + contentType: application/json + payload: + type: object + properties: + userId: + type: string + message2: + contentType: application/json + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/after.yaml b/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/after.yaml new file mode 100644 index 00000000..de517899 --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/after.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message3' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/before.yaml b/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/before.yaml new file mode 100644 index 00000000..1fbdc18a --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-from-operation-with-remaining-messages/before.yaml @@ -0,0 +1,43 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' + message3: + $ref: '#/components/messages/message3' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' + - $ref: '#/channels/channel1/messages/message3' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string + message3: + payload: + type: object + properties: + productId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-from-operation/after.yaml b/test/projects/asyncapi-changes/message/remove-from-operation/after.yaml new file mode 100644 index 00000000..dbe6803c --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-from-operation/after.yaml @@ -0,0 +1,33 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-from-operation/before.yaml b/test/projects/asyncapi-changes/message/remove-from-operation/before.yaml new file mode 100644 index 00000000..a6ae7999 --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-from-operation/before.yaml @@ -0,0 +1,34 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-unused-component-message/after.yaml b/test/projects/asyncapi-changes/message/remove-unused-component-message/after.yaml new file mode 100644 index 00000000..4bc38c26 --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-unused-component-message/after.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/message/remove-unused-component-message/before.yaml b/test/projects/asyncapi-changes/message/remove-unused-component-message/before.yaml new file mode 100644 index 00000000..d8a4af2d --- /dev/null +++ b/test/projects/asyncapi-changes/message/remove-unused-component-message/before.yaml @@ -0,0 +1,31 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + unusedMessage: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/operation/add-multiple/after.yaml b/test/projects/asyncapi-changes/operation/add-multiple/after.yaml index 8cfc4dbe..5d55e1dc 100644 --- a/test/projects/asyncapi-changes/operation/add-multiple/after.yaml +++ b/test/projects/asyncapi-changes/operation/add-multiple/after.yaml @@ -35,4 +35,3 @@ components: properties: userId: type: string - diff --git a/test/projects/asyncapi-changes/operation/add-multiple/before.yaml b/test/projects/asyncapi-changes/operation/add-multiple/before.yaml index 8139850a..4bc38c26 100644 --- a/test/projects/asyncapi-changes/operation/add-multiple/before.yaml +++ b/test/projects/asyncapi-changes/operation/add-multiple/before.yaml @@ -23,4 +23,3 @@ components: properties: userId: type: string - diff --git a/test/projects/asyncapi-changes/operation/add-with-changed-message/after.yaml b/test/projects/asyncapi-changes/operation/add-with-changed-message/after.yaml new file mode 100644 index 00000000..4c536eb4 --- /dev/null +++ b/test/projects/asyncapi-changes/operation/add-with-changed-message/after.yaml @@ -0,0 +1,34 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: integer diff --git a/test/projects/asyncapi-changes/operation/add-with-changed-message/before.yaml b/test/projects/asyncapi-changes/operation/add-with-changed-message/before.yaml new file mode 100644 index 00000000..48bde53a --- /dev/null +++ b/test/projects/asyncapi-changes/operation/add-with-changed-message/before.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/operation/add-with-multiple-messages/after.yaml b/test/projects/asyncapi-changes/operation/add-with-multiple-messages/after.yaml new file mode 100644 index 00000000..6ebe752f --- /dev/null +++ b/test/projects/asyncapi-changes/operation/add-with-multiple-messages/after.yaml @@ -0,0 +1,40 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: integer diff --git a/test/projects/asyncapi-changes/operation/add-with-multiple-messages/before.yaml b/test/projects/asyncapi-changes/operation/add-with-multiple-messages/before.yaml new file mode 100644 index 00000000..7a12b6cc --- /dev/null +++ b/test/projects/asyncapi-changes/operation/add-with-multiple-messages/before.yaml @@ -0,0 +1,33 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: integer diff --git a/test/projects/asyncapi-changes/operation/change/after.yaml b/test/projects/asyncapi-changes/operation/change-action/after.yaml similarity index 100% rename from test/projects/asyncapi-changes/operation/change/after.yaml rename to test/projects/asyncapi-changes/operation/change-action/after.yaml diff --git a/test/projects/asyncapi-changes/operation/change/before.yaml b/test/projects/asyncapi-changes/operation/change-action/before.yaml similarity index 100% rename from test/projects/asyncapi-changes/operation/change/before.yaml rename to test/projects/asyncapi-changes/operation/change-action/before.yaml diff --git a/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/after.yaml b/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/after.yaml new file mode 100644 index 00000000..3f04fd84 --- /dev/null +++ b/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/after.yaml @@ -0,0 +1,35 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + description: test2 + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/before.yaml b/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/before.yaml new file mode 100644 index 00000000..87e3276d --- /dev/null +++ b/test/projects/asyncapi-changes/operation/change-description-with-multiple-messages/before.yaml @@ -0,0 +1,35 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + description: test1 + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec1.yaml b/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec1.yaml new file mode 100644 index 00000000..c7bfb00e --- /dev/null +++ b/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec1.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec2.yaml b/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec2.yaml new file mode 100644 index 00000000..b8e88116 --- /dev/null +++ b/test/projects/asyncapi-changes/operation/duplicate-cross-document/spec2.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-changes/schema/add-property/after.yaml b/test/projects/asyncapi-changes/schema/add-property/after.yaml new file mode 100644 index 00000000..e6c75af8 --- /dev/null +++ b/test/projects/asyncapi-changes/schema/add-property/after.yaml @@ -0,0 +1,30 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string + email: + type: string diff --git a/test/projects/asyncapi-changes/schema/add-property/before.yaml b/test/projects/asyncapi-changes/schema/add-property/before.yaml new file mode 100644 index 00000000..48bde53a --- /dev/null +++ b/test/projects/asyncapi-changes/schema/add-property/before.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/schema/change-property-type/after.yaml b/test/projects/asyncapi-changes/schema/change-property-type/after.yaml new file mode 100644 index 00000000..917ad86f --- /dev/null +++ b/test/projects/asyncapi-changes/schema/change-property-type/after.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: integer diff --git a/test/projects/asyncapi-changes/schema/change-property-type/before.yaml b/test/projects/asyncapi-changes/schema/change-property-type/before.yaml new file mode 100644 index 00000000..48bde53a --- /dev/null +++ b/test/projects/asyncapi-changes/schema/change-property-type/before.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/schema/remove-property/after.yaml b/test/projects/asyncapi-changes/schema/remove-property/after.yaml new file mode 100644 index 00000000..48bde53a --- /dev/null +++ b/test/projects/asyncapi-changes/schema/remove-property/after.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/schema/remove-property/before.yaml b/test/projects/asyncapi-changes/schema/remove-property/before.yaml new file mode 100644 index 00000000..e6c75af8 --- /dev/null +++ b/test/projects/asyncapi-changes/schema/remove-property/before.yaml @@ -0,0 +1,30 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + $ref: '#/components/schemas/Message1Payload' + schemas: + Message1Payload: + type: object + properties: + userId: + type: string + email: + type: string diff --git a/test/projects/asyncapi-changes/server/change-in-channel/after.yaml b/test/projects/asyncapi-changes/server/change-in-channel/after.yaml new file mode 100644 index 00000000..5cdd55c7 --- /dev/null +++ b/test/projects/asyncapi-changes/server/change-in-channel/after.yaml @@ -0,0 +1,31 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + production: + protocol: amqp + host: api.production.example.com +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/production' + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/server/change-in-channel/before.yaml b/test/projects/asyncapi-changes/server/change-in-channel/before.yaml new file mode 100644 index 00000000..aa7418d1 --- /dev/null +++ b/test/projects/asyncapi-changes/server/change-in-channel/before.yaml @@ -0,0 +1,31 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + production: + protocol: amqp + host: api.example.com +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/production' + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-changes/server/change-isolated-servers/after.yaml b/test/projects/asyncapi-changes/server/change-isolated-servers/after.yaml new file mode 100644 index 00000000..8c9cd195 --- /dev/null +++ b/test/projects/asyncapi-changes/server/change-isolated-servers/after.yaml @@ -0,0 +1,53 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + server1: + protocol: amqp + host: new-api1.example.com + server2: + protocol: kafka + host: api2.example.com +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/server1' + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + servers: + - $ref: '#/servers/server2' + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/server/change-isolated-servers/before.yaml b/test/projects/asyncapi-changes/server/change-isolated-servers/before.yaml new file mode 100644 index 00000000..c0d7cc36 --- /dev/null +++ b/test/projects/asyncapi-changes/server/change-isolated-servers/before.yaml @@ -0,0 +1,53 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + server1: + protocol: amqp + host: api1.example.com + server2: + protocol: kafka + host: api2.example.com +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/server1' + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + servers: + - $ref: '#/servers/server2' + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-changes/server/remove-from-channel/before.yaml b/test/projects/asyncapi-changes/server/remove-from-channel/before.yaml index 1ee10c9d..3a7cf703 100644 --- a/test/projects/asyncapi-changes/server/remove-from-channel/before.yaml +++ b/test/projects/asyncapi-changes/server/remove-from-channel/before.yaml @@ -9,6 +9,8 @@ servers: channels: channel1: address: channel1 + servers: + - $ref: '#/servers/production' messages: message1: $ref: '#/components/messages/message1' diff --git a/test/projects/asyncapi-changes/tags/after.yaml b/test/projects/asyncapi-changes/tags/after.yaml index 3d3c7f00..322bf105 100644 --- a/test/projects/asyncapi-changes/tags/after.yaml +++ b/test/projects/asyncapi-changes/tags/after.yaml @@ -36,6 +36,8 @@ operations: tags: - name: sameTagInDifferentChannels1 - name: sameTagInDifferentChannels3 + messages: + - $ref: '#/channels/userSignup/messages/userSignedUp' added2: action: send channel: @@ -44,12 +46,16 @@ operations: - name: sameTagInDifferentChannels1 - name: sameTagInDifferentChannels3 - name: sameTagInDifferentSiblings2 + messages: + - $ref: '#/channels/userUpdate/messages/userUpdated' added3: action: receive channel: $ref: '#/channels/orderCreate' tags: - name: sameTagInDifferentSiblings2 + messages: + - $ref: '#/channels/orderCreate/messages/orderCreated' changed1: action: send channel: @@ -58,12 +64,16 @@ operations: - name: sameTagInOperationSiblings1 - name: sameTagInDifferentSiblings3 - name: tag + messages: + - $ref: '#/channels/orderUpdate/messages/orderUpdated' changed2: action: receive channel: $ref: '#/channels/orderDelete' tags: - name: sameTagInDifferentSiblings3 + messages: + - $ref: '#/channels/orderDelete/messages/orderDeleted' components: messages: UserSignedUp: diff --git a/test/projects/asyncapi-changes/tags/before.yaml b/test/projects/asyncapi-changes/tags/before.yaml index f04171f2..191311c6 100644 --- a/test/projects/asyncapi-changes/tags/before.yaml +++ b/test/projects/asyncapi-changes/tags/before.yaml @@ -36,6 +36,8 @@ operations: tags: - name: sameTagInDifferentChannels1 - name: sameTagInDifferentChannels2 + messages: + - $ref: '#/channels/userSignup/messages/userSignedUp' removed2: action: send channel: @@ -44,12 +46,16 @@ operations: - name: sameTagInDifferentChannels1 - name: sameTagInDifferentChannels2 - name: sameTagInDifferentSiblings1 + messages: + - $ref: '#/channels/userUpdate/messages/userUpdated' removed3: action: receive channel: $ref: '#/channels/orderCreate' tags: - name: sameTagInDifferentSiblings1 + messages: + - $ref: '#/channels/orderCreate/messages/orderCreated' changed1: action: send channel: @@ -58,12 +64,16 @@ operations: - name: sameTagInOperationSiblings1 - name: tag - name: missingByDesign + messages: + - $ref: '#/channels/orderUpdate/messages/orderUpdated' changed2: action: receive channel: $ref: '#/channels/orderDelete' tags: - name: missingByDesign + messages: + - $ref: '#/channels/orderDelete/messages/orderDeleted' components: messages: UserSignedUp: diff --git a/test/projects/asyncapi-deduplication/cross-document-dedup/after1.yaml b/test/projects/asyncapi-deduplication/cross-document-dedup/after1.yaml new file mode 100644 index 00000000..95df4997 --- /dev/null +++ b/test/projects/asyncapi-deduplication/cross-document-dedup/after1.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-deduplication/cross-document-dedup/after2.yaml b/test/projects/asyncapi-deduplication/cross-document-dedup/after2.yaml new file mode 100644 index 00000000..0f976837 --- /dev/null +++ b/test/projects/asyncapi-deduplication/cross-document-dedup/after2.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-deduplication/cross-document-dedup/before1.yaml b/test/projects/asyncapi-deduplication/cross-document-dedup/before1.yaml new file mode 100644 index 00000000..c7bfb00e --- /dev/null +++ b/test/projects/asyncapi-deduplication/cross-document-dedup/before1.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-deduplication/cross-document-dedup/before2.yaml b/test/projects/asyncapi-deduplication/cross-document-dedup/before2.yaml new file mode 100644 index 00000000..b8e88116 --- /dev/null +++ b/test/projects/asyncapi-deduplication/cross-document-dedup/before2.yaml @@ -0,0 +1,25 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: number diff --git a/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/after.yaml b/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/after.yaml new file mode 100644 index 00000000..0b99f5dc --- /dev/null +++ b/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/after.yaml @@ -0,0 +1,35 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/xml +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + userId: + type: string \ No newline at end of file diff --git a/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/before.yaml b/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/before.yaml new file mode 100644 index 00000000..f7153476 --- /dev/null +++ b/test/projects/asyncapi-deduplication/default-content-type-multiple-messages/before.yaml @@ -0,0 +1,35 @@ +asyncapi: 3.0.0 +info: + title: Test + version: 1.0.0 +defaultContentType: application/json +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + - $ref: '#/channels/channel1/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + userId: + type: string diff --git a/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/after.yaml b/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/after.yaml new file mode 100644 index 00000000..bde349bd --- /dev/null +++ b/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/after.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 2.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/before.yaml b/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/before.yaml new file mode 100644 index 00000000..8c736e79 --- /dev/null +++ b/test/projects/asyncapi-deduplication/root-info-change-multiple-operations/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/after.yaml b/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/after.yaml new file mode 100644 index 00000000..2cdd3a62 --- /dev/null +++ b/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/after.yaml @@ -0,0 +1,50 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + production: + host: new.example.com + protocol: kafka +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/production' + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + servers: + - $ref: '#/servers/production' + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/before.yaml b/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/before.yaml new file mode 100644 index 00000000..3d0a1cb5 --- /dev/null +++ b/test/projects/asyncapi-deduplication/root-server-change-multiple-operations/before.yaml @@ -0,0 +1,50 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +servers: + production: + host: old.example.com + protocol: kafka +channels: + channel1: + address: channel1 + servers: + - $ref: '#/servers/production' + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + servers: + - $ref: '#/servers/production' + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string + message2: + payload: + type: object + properties: + orderId: + type: string diff --git a/test/projects/asyncapi-deduplication/shared-schema-across-operations/after.yaml b/test/projects/asyncapi-deduplication/shared-schema-across-operations/after.yaml new file mode 100644 index 00000000..b9246ffb --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-across-operations/after.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-across-operations/before.yaml b/test/projects/asyncapi-deduplication/shared-schema-across-operations/before.yaml new file mode 100644 index 00000000..23db4f22 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-across-operations/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after1.yaml new file mode 100644 index 00000000..bc7cc96c --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after2.yaml new file mode 100644 index 00000000..2e81e1c5 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/after2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + orderId: + type: string + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before1.yaml new file mode 100644 index 00000000..fce21230 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before2.yaml new file mode 100644 index 00000000..92e08261 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-different-content/before2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + orderId: + type: integer + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after1.yaml new file mode 100644 index 00000000..bc7cc96c --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after2.yaml new file mode 100644 index 00000000..c8698486 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/after2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before1.yaml new file mode 100644 index 00000000..fce21230 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before2.yaml new file mode 100644 index 00000000..d25efdf0 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs-same-scope/before2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after1.yaml new file mode 100644 index 00000000..bc7cc96c --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after2.yaml new file mode 100644 index 00000000..3b166833 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/after2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before1.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before1.yaml new file mode 100644 index 00000000..fce21230 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before1.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc1 + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before2.yaml b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before2.yaml new file mode 100644 index 00000000..b40b9d86 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-cross-specs/before2.yaml @@ -0,0 +1,28 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI Doc2 + version: 1.0.0 +channels: + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation2: + action: send + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-same-scope/after.yaml b/test/projects/asyncapi-deduplication/shared-schema-same-scope/after.yaml new file mode 100644 index 00000000..33563b89 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-same-scope/after.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: string + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi-deduplication/shared-schema-same-scope/before.yaml b/test/projects/asyncapi-deduplication/shared-schema-same-scope/before.yaml new file mode 100644 index 00000000..c083e434 --- /dev/null +++ b/test/projects/asyncapi-deduplication/shared-schema-same-scope/before.yaml @@ -0,0 +1,42 @@ +asyncapi: 3.0.0 +info: + title: Test AsyncAPI + version: 1.0.0 +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' + channel2: + address: channel2 + messages: + message2: + $ref: '#/components/messages/message2' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' + operation2: + action: receive + channel: + $ref: '#/channels/channel2' + messages: + - $ref: '#/channels/channel2/messages/message2' +components: + schemas: + SharedPayload: + type: object + properties: + userId: + type: number + messages: + message1: + payload: + $ref: '#/components/schemas/SharedPayload' + message2: + payload: + $ref: '#/components/schemas/SharedPayload' diff --git a/test/projects/asyncapi/api-kind/base/spec.yaml b/test/projects/asyncapi/api-kind/base/spec.yaml index 50863103..a2a998f7 100644 --- a/test/projects/asyncapi/api-kind/base/spec.yaml +++ b/test/projects/asyncapi/api-kind/base/spec.yaml @@ -28,13 +28,13 @@ operations: $ref: '#/channels/channel' messages: - $ref: '#/channels/channel/messages/UserSignedUp' - operation-with-cannel-bwc: + operation-with-channel-bwc: action: send channel: $ref: '#/channels/channel-bwc' messages: - $ref: '#/channels/channel-bwc/messages/UserSignedUp' - operation-with-cannel-no-bwc: + operation-with-channel-no-bwc: action: send channel: $ref: '#/channels/channel-no-bwc' diff --git a/test/projects/asyncapi/operations/root-servers-no-channel-servers.yaml b/test/projects/asyncapi/operations/root-servers-no-channel-servers.yaml new file mode 100644 index 00000000..72f08c72 --- /dev/null +++ b/test/projects/asyncapi/operations/root-servers-no-channel-servers.yaml @@ -0,0 +1,32 @@ +asyncapi: 3.0.0 +info: + title: Root Servers Test + version: 1.0.0 +servers: + production: + host: api.example.com + protocol: amqp + staging: + host: staging.example.com + protocol: amqp +channels: + channel1: + address: channel1 + messages: + message1: + $ref: '#/components/messages/message1' +operations: + operation1: + action: receive + channel: + $ref: '#/channels/channel1' + messages: + - $ref: '#/channels/channel1/messages/message1' +components: + messages: + message1: + payload: + type: object + properties: + userId: + type: string