diff --git a/src/apitypes/rest/index.ts b/src/apitypes/rest/index.ts index 8082515..2a1a5fa 100644 --- a/src/apitypes/rest/index.ts +++ b/src/apitypes/rest/index.ts @@ -19,10 +19,10 @@ import { OpenAPIV3 } from 'openapi-types' import { buildRestDocument, createRestExportDocument, dumpRestDocument } from './rest.document' import { REST_API_TYPE, REST_DOCUMENT_TYPE } from './rest.consts' import { compareRestOperationsData } from './rest.changes' -import { buildRestOperations, createNormalizedOperationId } from './rest.operations' +import { buildRestOperations } from './rest.operations' import { parseRestFile } from './rest.parser' - import { ApiBuilder } from '../../types' +import { calculateNormalizedOperationId } from '../../utils' export * from './rest.consts' @@ -34,6 +34,6 @@ export const restApiBuilder: ApiBuilder = { buildOperations: buildRestOperations, dumpDocument: dumpRestDocument, compareOperationsData: compareRestOperationsData, - createNormalizedOperationId: createNormalizedOperationId, + createNormalizedOperationId: calculateNormalizedOperationId, createExportDocument: createRestExportDocument, } diff --git a/src/apitypes/rest/rest.operation.ts b/src/apitypes/rest/rest.operation.ts index c95fe9a..45d9e29 100644 --- a/src/apitypes/rest/rest.operation.ts +++ b/src/apitypes/rest/rest.operation.ts @@ -19,21 +19,27 @@ import { OpenAPIV3 } from 'openapi-types' import { REST_API_TYPE, REST_KIND_KEY } from './rest.consts' import { operationRules } from './rest.rules' import type * as TYPE from './rest.types' -import type { +import { RestOperationData } from './rest.types' +import { BuildConfig, CrawlRule, DeprecateItem, NotificationMessage, OperationCrawlState, + OperationId, SearchScopes, } from '../../types' import { buildSearchScope, + calculateOperationId, capitalize, + extractSymbolProperty, getKeyValue, getSplittedVersionKey, + getSymbolValueIfDefined, isDeprecatedOperationItem, isOperationDeprecated, + isValidHttpMethod, normalizePath, rawToApiKind, setValueByPath, @@ -41,7 +47,7 @@ import { takeIfDefined, } from '../../utils' import { API_KIND, INLINE_REFS_FLAG, ORIGINS_SYMBOL, VERSION_STATUS } from '../../consts' -import { getCustomTags, resolveApiAudience } from './rest.utils' +import { getCustomTags, getOperationBasePath, resolveApiAudience } from './rest.utils' import { DebugPerformanceContext, syncDebugPerformance } from '../../utils/logs' import { calculateDeprecatedItems, @@ -59,6 +65,7 @@ import { } from '@netcracker/qubership-apihub-api-unifier' import { calculateObjectHash } from '../../utils/hashes' import { calculateTolerantHash } from '../../components/deprecated' +import { getValueByPath } from '../../utils/path' export const buildRestOperation = ( operationId: string, @@ -143,7 +150,7 @@ export const buildRestOperation = ( security, components?.securitySchemes, ) - calculateSpecRefs(document.data, refsOnlySingleOperationSpec, specWithSingleOperation, models, componentsHashMap) + calculateSpecRefs(document.data, refsOnlySingleOperationSpec, specWithSingleOperation, [operationId], models, componentsHashMap) const dataHash = calculateObjectHash(specWithSingleOperation) return [specWithSingleOperation, dataHash] }, debugCtx) @@ -180,7 +187,14 @@ export const buildRestOperation = ( } } -export const calculateSpecRefs = (sourceDocument: unknown, normalizedSpec: unknown, resultSpec: unknown, models?: Record, componentsHashMap?: Map): void => { +export const calculateSpecRefs = ( + sourceDocument: TYPE.RestOperationData, + normalizedSpec: TYPE.RestOperationData, + resultSpec: TYPE.RestOperationData, + operations: OperationId[], + models?: Record, + componentsHashMap?: Map, +): void => { const handledObjects = new Set() const inlineRefs = new Set() syncCrawl( @@ -212,10 +226,11 @@ export const calculateSpecRefs = (sourceDocument: unknown, normalizedSpec: unkno return } const componentName = matchResult.grepValues[grepKey].toString() - const component = getKeyValue(sourceDocument, ...matchResult.path) + const component = getKeyValue(sourceDocument, ...matchResult.path) as Record if (!component) { return } + if (models && !models[componentName] && isComponentsSchemaRef(matchResult.path)) { let componentHash = componentsHashMap?.get(componentName) if (componentHash) { @@ -226,8 +241,68 @@ export const calculateSpecRefs = (sourceDocument: unknown, normalizedSpec: unkno models[componentName] = componentHash } } + setValueByPath(resultSpec, matchResult.path, component) }) + + if (operations?.length) { + reduceComponentPathItemsToOperations(resultSpec, normalizedSpec, operations) + } +} + +function reduceComponentPathItemsToOperations( + resultSpec: RestOperationData, + normalizedDocument: RestOperationData, + operations: OperationId[], +): void { + const { paths } = normalizedDocument + + for (const path of Object.keys(paths)) { + const sourcePathItem = paths[path] as OpenAPIV3.PathItemObject + const pathItemComponentJsonPath = getPathItemComponentJsonPath(sourcePathItem) + if (!pathItemComponentJsonPath) { + continue + } + + const pathItemComponent = getValueByPath(resultSpec, pathItemComponentJsonPath) as OpenAPIV3.PathItemObject + + const operationIds: OpenAPIV3.HttpMethods[] = (Object.keys(pathItemComponent) as OpenAPIV3.HttpMethods[]) + .filter((httpMethod) => isValidHttpMethod(httpMethod)) + .filter(httpMethod => { + const methodData = sourcePathItem[httpMethod as OpenAPIV3.HttpMethods] + if (!methodData) return false + const basePath = getOperationBasePath( + methodData?.servers || + sourcePathItem?.servers || + [], + ) + const operationId = calculateOperationId(basePath, httpMethod, path) + return operations.includes(operationId) + }) + + if (operationIds?.length) { + const pathItemObject = { + ...extractCommonPathItemProperties(pathItemComponent), + ...operationIds.reduce((pathItemObject: OpenAPIV3.PathItemObject, operationId: OpenAPIV3.HttpMethods) => { + const operationData = pathItemComponent[operationId] + if (operationData) { + pathItemObject[operationId] = { ...operationData } + } + return pathItemObject + }, {}), + } + setValueByPath(resultSpec, pathItemComponentJsonPath, pathItemObject) + } + } +} + +const getPathItemComponentJsonPath = (sourcePathItem: OpenAPIV3.PathItemObject): JsonPath | undefined => { + const refs = getSymbolValueIfDefined(sourcePathItem, INLINE_REFS_FLAG) as string[] | undefined + if (!refs || refs.length === 0) { + return undefined + } + + return parseRef(refs[0])?.jsonPath } export const isComponentsSchemaRef = (path: JsonPath): boolean => { @@ -236,6 +311,7 @@ export const isComponentsSchemaRef = (path: JsonPath): boolean => { [[OPEN_API_PROPERTY_COMPONENTS, OPEN_API_PROPERTY_SCHEMAS, PREDICATE_UNCLOSED_END]], ) } + const isOperationPaths = (paths: JsonPath[]): boolean => { return !!matchPaths( paths, @@ -257,15 +333,19 @@ const createSingleOperationSpec = ( ): TYPE.RestOperationData => { const pathData = document.paths[path] as OpenAPIV3.PathItemObject + const isRefPathData = !!pathData.$ref return { openapi: openapi ?? '3.0.0', ...takeIfDefined({ servers }), ...takeIfDefined({ security }), // TODO: remove duplicates in security paths: { - [path]: { - ...extractCommonPathItemProperties(pathData), - [method]: { ...pathData[method] }, - }, + [path]: isRefPathData + ? pathData + : { + ...extractCommonPathItemProperties(pathData), + [method]: { ...pathData[method] }, + ...extractSymbolProperty(pathData, INLINE_REFS_FLAG), + }, }, components: { ...takeIfDefined({ securitySchemes }), diff --git a/src/apitypes/rest/rest.operations.ts b/src/apitypes/rest/rest.operations.ts index d23ba7b..3dedace 100644 --- a/src/apitypes/rest/rest.operations.ts +++ b/src/apitypes/rest/rest.operations.ts @@ -17,14 +17,8 @@ import { OpenAPIV3 } from 'openapi-types' import { buildRestOperation } from './rest.operation' -import { OperationIdNormalizer, OperationsBuilder } from '../../types' -import { - createBundlingErrorHandler, - IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER, - removeComponents, - removeFirstSlash, - slugify, -} from '../../utils' +import { OperationsBuilder } from '../../types' +import { calculateOperationId, createBundlingErrorHandler, removeComponents } from '../../utils' import { getOperationBasePath } from './rest.utils' import type * as TYPE from './rest.types' import { HASH_FLAG, INLINE_REFS_FLAG, MESSAGE_SEVERITY, NORMALIZE_OPTIONS, ORIGINS_SYMBOL } from '../../consts' @@ -61,7 +55,7 @@ export const buildRestOperations: OperationsBuilder = async debugCtx, ) - const { paths, servers } = document.data + const { paths, servers } = effectiveDocument const operations: TYPE.VersionRestOperation[] = [] if (!paths) { return [] } @@ -77,9 +71,8 @@ export const buildRestOperations: OperationsBuilder = async await asyncFunction(() => { const methodData = pathData[key as OpenAPIV3.HttpMethods] const basePath = getOperationBasePath(methodData?.servers || pathData?.servers || servers || []) - const operationPath = basePath + path - const operationId = slugify(`${removeFirstSlash(operationPath)}-${key}`) + const operationId = calculateOperationId(basePath, key, path) if (ctx.operationResolver(operationId)) { ctx.notifications.push({ @@ -112,8 +105,3 @@ export const buildRestOperations: OperationsBuilder = async } return operations } - -export const createNormalizedOperationId: OperationIdNormalizer = (operation) => { - const { metadata: { path, method } } = operation - return slugify(`${path}-${method}`, [], IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER) -} diff --git a/src/consts.ts b/src/consts.ts index 3e8f434..6d4fe56 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -27,6 +27,7 @@ import { VALIDATION_RULES_SEVERITY_LEVEL_WARNING, ValidationRulesSeverity, } from './types' +import { OpenAPIV3 } from 'openapi-types' export const DEFAULT_BATCH_SIZE = 32 @@ -169,3 +170,4 @@ export const EMPTY_CHANGE_SUMMARY_DTO = { } export const CUSTOM_PARAMETER_API_AUDIENCE = 'x-api-audience' +export const HTTP_METHODS_SET = new Set(Object.values(OpenAPIV3.HttpMethods) as string[]) diff --git a/src/strategies/document-group.strategy.ts b/src/strategies/document-group.strategy.ts index 1d5b0c7..a62d09e 100644 --- a/src/strategies/document-group.strategy.ts +++ b/src/strategies/document-group.strategy.ts @@ -26,10 +26,10 @@ import { } from '../types' import { REST_API_TYPE } from '../apitypes' import { + calculateOperationId, EXPORT_FORMAT_TO_FILE_FORMAT, fromBase64, - removeFirstSlash, - slugify, + isValidHttpMethod, takeIfDefined, toVersionDocument, } from '../utils' @@ -43,19 +43,12 @@ import { calculateSpecRefs, extractCommonPathItemProperties } from '../apitypes/ function getTransformedDocument(document: ResolvedGroupDocument, format: FileFormat, packages: ResolvedReferenceMap): VersionRestDocument { const versionDocument = toVersionDocument(document, format) - const source = extractDocumentData(versionDocument) + const sourceDocument = extractDocumentData(versionDocument) versionDocument.data = transformDocumentData(versionDocument) - const normalizedDocument = normalize( - versionDocument.data, - { - ...NORMALIZE_OPTIONS, - inlineRefsFlag: INLINE_REFS_FLAG, - source, - }, - ) as OpenAPIV3.Document + const normalizedDocument = normalizeOpenApi(versionDocument.data, sourceDocument) versionDocument.publish = true - calculateSpecRefs(source, normalizedDocument, versionDocument.data) + calculateSpecRefs(sourceDocument, normalizedDocument, versionDocument.data, versionDocument.operationIds) // dashboard case if (document.packageRef) { @@ -103,7 +96,7 @@ export class DocumentGroupStrategy implements BuilderStrategy { } } -function parseBase64String(value: string): object { +function parseBase64String(value: string): unknown { return JSON.parse(fromBase64(value)) } @@ -116,48 +109,76 @@ function extractDocumentData(versionDocument: VersionDocument): OpenAPIV3.Docume } function transformDocumentData(versionDocument: VersionDocument): OpenAPIV3.Document { + const sourceDocument = extractDocumentData(versionDocument) + const normalizedDocument = normalizeOpenApi(sourceDocument) + const { paths: sourcePaths, components: sourceComponents, ...restOfSource } = sourceDocument + const { paths: normalizedPaths } = normalizedDocument - const documentData = extractDocumentData(versionDocument) - const { paths, components, ...rest } = documentData - const result: OpenAPIV3.Document = { - ...rest, + const resultDocument: OpenAPIV3.Document = { + ...restOfSource, paths: {}, } - for (const path of Object.keys(paths)) { - const pathData = paths[path] - if (typeof pathData !== 'object' || !pathData) { + for (const path of Object.keys(normalizedPaths)) { + const sourcePathItem = sourcePaths[path] + const normalizedPathItem = normalizedPaths[path] + + if (!isNonNullObject(sourcePathItem) || !isNonNullObject(normalizedPathItem)) { continue } - const commonPathItemProperties = extractCommonPathItemProperties(pathData) - for (const method of Object.keys(pathData)) { - const inferredMethod = method as OpenAPIV3.HttpMethods + const commonPathItemProperties = extractCommonPathItemProperties(sourcePathItem) - // check if field is a valid openapi http method defined in OpenAPIV3.HttpMethods - if (!Object.values(OpenAPIV3.HttpMethods).includes(inferredMethod)) { - continue - } + for (const method of Object.keys(normalizedPathItem)) { + const httpMethod = method as OpenAPIV3.HttpMethods + if (!isValidHttpMethod(httpMethod)) continue + + const methodData = normalizedPathItem[httpMethod] + const basePath = getOperationBasePath( + methodData?.servers || + sourcePathItem?.servers || + sourceDocument?.servers || + [], + ) - const methodData = pathData[inferredMethod] - const basePath = getOperationBasePath(methodData?.servers || pathData?.servers || documentData?.servers || []) - const operationPath = basePath + path + const operationId = calculateOperationId(basePath, method, path) - const operationId = slugify(`${removeFirstSlash(operationPath)}-${method}`) + if (!versionDocument.operationIds.includes(operationId)) { + continue + } if (versionDocument.operationIds.includes(operationId)) { - const pathData = documentData.paths[path]! - result.paths[path] = { - ...result.paths[path], - ...commonPathItemProperties, - [inferredMethod]: { ...pathData[inferredMethod] }, - } - result.components = { - ...takeIfDefined({ securitySchemes: components?.securitySchemes }), + const pathData = sourceDocument.paths[path]! + const isRefPathData = !!pathData.$ref + resultDocument.paths[path] = isRefPathData + ? pathData + : { + ...resultDocument.paths[path], + ...commonPathItemProperties, + [httpMethod]: { ...pathData[httpMethod] }, + } + + resultDocument.components = { + ...takeIfDefined({ securitySchemes: sourceComponents?.securitySchemes }), } } } } - return result + return resultDocument +} + +function normalizeOpenApi(document: OpenAPIV3.Document, source?: OpenAPIV3.Document): OpenAPIV3.Document { + return normalize( + document, + { + ...NORMALIZE_OPTIONS, + inlineRefsFlag: INLINE_REFS_FLAG, + ...(source ? { source } : {}), + }, + ) as OpenAPIV3.Document +} + +function isNonNullObject(value: unknown): value is Record { + return typeof value === 'object' && value !== null } diff --git a/src/utils/objects.ts b/src/utils/objects.ts index f904ee4..8cfa317 100644 --- a/src/utils/objects.ts +++ b/src/utils/objects.ts @@ -65,3 +65,20 @@ export const isSymbol = (value: unknown): value is symbol => { export const isObject = (value: unknown): value is Record => { return typeof value === 'object' && value !== null } + +export const getSymbolValueIfDefined = ( + obj: T, + symbol: symbol, +): unknown => { + const symbolObj = obj as { [key: symbol]: unknown } + + return symbol in symbolObj ? symbolObj[symbol] : undefined +} + +export const extractSymbolProperty = ( + obj: T, + symbol: symbol, +): { [key: symbol]: unknown } => { + const value = getSymbolValueIfDefined(obj, symbol) + return value !== undefined ? { [symbol]: value } : {} +} diff --git a/src/utils/operations.utils.ts b/src/utils/operations.utils.ts index ff565bf..cc112fb 100644 --- a/src/utils/operations.utils.ts +++ b/src/utils/operations.utils.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import { ApiOperation, BuildResult } from '../types' +import { ApiOperation, BuildResult, OperationIdNormalizer } from '../types' import { GraphApiComponents, GraphApiDirectiveDefinition } from '@netcracker/qubership-apihub-graphapi' -import type { OpenAPIV3 } from 'openapi-types' +import { OpenAPIV3 } from 'openapi-types' import { isObject } from './objects' -import { slugify } from './document' +import { IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER, slugify } from './document' import { removeFirstSlash } from './builder' import { Diff, DiffAction } from '@netcracker/qubership-apihub-api-diff' import { matchPaths, OPEN_API_PROPERTY_PATHS, PREDICATE_ANY_VALUE } from '@netcracker/qubership-apihub-api-unifier' import { DirectiveLocation } from 'graphql/language' +import { HTTP_METHODS_SET } from '../consts' export function getOperationsList(buildResult: BuildResult): ApiOperation[] { return [...buildResult.operations.values()] @@ -82,3 +83,21 @@ export function isOperationRemove(operationDiff: Diff): boolean { // length is 2 because json path has view like ['paths', '/test/element'] return operationDiff.action === DiffAction.remove && !!matchPaths(operationDiff.beforeDeclarationPaths, [[OPEN_API_PROPERTY_PATHS, PREDICATE_ANY_VALUE]]) } + +export const isValidHttpMethod = (method: string): method is OpenAPIV3.HttpMethods => { + return HTTP_METHODS_SET.has(method) +} + +export const calculateNormalizedOperationId: OperationIdNormalizer = (operation) => { + const { metadata: { path, method } } = operation + return slugify(`${path}-${method}`, [], IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER) +} + +export const calculateOperationId = ( + basePath: string, + key: string, + path: string, +): string => { + const operationPath = basePath + path + return slugify(`${removeFirstSlash(operationPath)}-${key}`) +} diff --git a/src/utils/path.ts b/src/utils/path.ts index d9bf36c..a16a3f5 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -64,3 +64,6 @@ export function areDeclarationPathsEqual(firstItemDeclarationPaths: JsonPath[], return true } + +export const getValueByPath = (value: any, path: JsonPath): any => path.reduce((data, key) => data[key], value) + diff --git a/test/builder.test.ts b/test/builder.test.ts index f4ba0ac..18ae650 100644 --- a/test/builder.test.ts +++ b/test/builder.test.ts @@ -145,4 +145,33 @@ describe('Editor scenarios', () => { }) }) }) + + describe('PathItems build', () => { + const COMPONENTS_ITEM_1_PATH = ['components', 'pathItems', 'componentsPathItem1'] + test('should have separate operations with pathitems', async () => { + const pkg = LocalRegistry.openPackage('builder/define-pathitems-via-reference-object-chain') + const editor = await Editor.openProject(pkg.packageId, pkg) + + await pkg.publish(pkg.packageId, { packageId: pkg.packageId }) + const result = await editor.run({ + version: 'v1', + status: VERSION_STATUS.RELEASE, + buildType: BUILD_TYPE.BUILD, + }) + + const resultOperations = Array.from(result.operations.values()) + expect(resultOperations.length).toEqual(2) + + const [postOperation, getOperation] = resultOperations + // check that we have only path operation in componentsPathItem1 for path1-post + expect(postOperation.operationId).toEqual('path1-post') + expect(postOperation.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post']) + expect(postOperation.data).not.toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get']) + + // check that we have only get operation in componentsPathItem1 for path1-get + expect(getOperation.operationId).toEqual('path1-get') + expect(getOperation.data).not.toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post']) + expect(getOperation.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get']) + }) + }) }) diff --git a/test/declarative-changes-in-rest-operation.test.ts b/test/declarative-changes-in-rest-operation.test.ts index dff9182..9cbe8b3 100644 --- a/test/declarative-changes-in-rest-operation.test.ts +++ b/test/declarative-changes-in-rest-operation.test.ts @@ -30,6 +30,12 @@ describe('Number of declarative changes in rest operation test', () => { expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 })) }) + test('Multiple use of one schema in another schema which is used in response pathItems', async () => { + const result = await buildChangelogPackage('declarative-changes-in-rest-operation/case8') + expect(result).toEqual(changesSummaryMatcher({ [BREAKING_CHANGE_TYPE]: 1 })) + expect(result).toEqual(numberOfImpactedOperationsMatcher({ [BREAKING_CHANGE_TYPE]: 1 })) + }) + test('Multiple use of one schema in both request and response (different severity)', async () => { const result = await buildChangelogPackage('declarative-changes-in-rest-operation/case3') expect(result).toEqual(changesSummaryMatcher({ diff --git a/test/document-group.test.ts b/test/document-group.test.ts index 6fb3d73..b51ac79 100644 --- a/test/document-group.test.ts +++ b/test/document-group.test.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Editor, loadFileAsString, LocalRegistry } from './helpers' -import { BUILD_TYPE, REST_API_TYPE } from '../src' +import { Editor, loadFileAsString, LocalRegistry, VERSIONS_PATH } from './helpers' +import { BUILD_TYPE, BuildConfigAggregator, BuildResult, PACKAGE, PackageNotifications, REST_API_TYPE } from '../src' import { load } from 'js-yaml' const GROUP_NAME = 'manualGroup' @@ -32,62 +32,283 @@ const groupToOperationIdsMap2 = { 'some-path2-post', ], } + +const groupToOnePathOperationIdsMap = { + [GROUP_NAME]: [ + 'path1-get', + 'path1-post', + ], +} + +const groupWithOneOperationIdsMap = { + [GROUP_NAME]: [ + 'path1-post', + ], +} + +const groupToOneServerPrefixPathOperationIdsMap = { + [GROUP_NAME]: [ + 'api-v1-path1-get', + 'api-v1-path2-post', + ], +} + const EXPECTED_RESULT_FILE = 'result.yaml' +const BASE_OPERATION_PATH = 'path-operations' +const PATH_ITEMS_OPERATION_PATH = 'pathitems-operations' +type DOCUMENT_GROUP_PATHS = typeof BASE_OPERATION_PATH | typeof PATH_ITEMS_OPERATION_PATH + describe('Document Group test', () => { - test('should have documents stripped of operations other than from provided group', async () => { - // todo - }) + describe('Base path operations', () => { + runCommonTests(BASE_OPERATION_PATH) + + test('should have documents stripped of operations other than from provided group', async () => { + // todo + }) + + test('should have merged operations from provided group', async () => { + // todo + }) - test('should have merged operations from provided group', async () => { - // todo + test('should have properly merged documents', async () => { + await runMergeOperationsCase('basic-documents-for-merge') + }) + + test('should have components schema object which is referenced', async () => { + const { result } = await runPublishPackage( + `document-group/${BASE_OPERATION_PATH}/referenced-json-schema-object`, + groupToOnePathOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + expect(document.data).toHaveProperty(['components', 'schemas', 'MySchema']) + } + }) + + test('should rename documents with matching names', async () => { + const dashboard = LocalRegistry.openPackage('documents-collision', groupToOperationIdsMap2) + const package1 = LocalRegistry.openPackage('documents-collision/package1') + const package2 = LocalRegistry.openPackage('documents-collision/package2') + const package3 = LocalRegistry.openPackage('documents-collision/package3') + + await dashboard.publish(dashboard.packageId, { packageId: dashboard.packageId }) + await package1.publish(package1.packageId, { packageId: package1.packageId }) + await package2.publish(package2.packageId, { packageId: package2.packageId }) + await package3.publish(package3.packageId, { packageId: package3.packageId }) + + const editor = await Editor.openProject(dashboard.packageId, dashboard) + const result = await editor.run({ + packageId: dashboard.packageId, + buildType: BUILD_TYPE.REDUCED_SOURCE_SPECIFICATIONS, + groupName: GROUP_NAME, + apiType: REST_API_TYPE, + }) + + expect(Array.from(result.documents.values())).toEqual( + expect.toIncludeSameMembers([ + expect.objectContaining({ + fileId: 'documents-collision/package1_1.yaml', + filename: 'documents-collision/package1_1.json', + }), + expect.objectContaining({ + fileId: 'documents-collision/package1_2.yaml', + filename: 'documents-collision/package1_2.json', + }), + expect.objectContaining({ + fileId: 'documents-collision/package2_1.yaml', + filename: 'documents-collision/package2_1.json', + }), + expect.objectContaining({ + fileId: 'documents-collision/package3_1.yaml', + filename: 'documents-collision/package3_1.json', + }), + ]), + ) + + for (const document of Array.from(result.documents.values())) { + expect(Object.keys(document.data.paths).length).toEqual(document.operationIds.length) + } + }) }) - test('should have properly merged documents', async () => { - const pkg = LocalRegistry.openPackage('merge-operations', groupToOperationIdsMap) - const editor = await Editor.openProject(pkg.packageId, pkg) + describe('PathItems operations', () => { + runCommonTests(PATH_ITEMS_OPERATION_PATH) - await pkg.publish(pkg.packageId, { packageId: pkg.packageId }) - const result = await editor.run({ - packageId: pkg.packageId, - buildType: BUILD_TYPE.MERGED_SPECIFICATION, - groupName: GROUP_NAME, - apiType: REST_API_TYPE, + test('should have properly merged documents', async () => { + await runMergeOperationsCase('basic-documents-pathitems-for-merge') + }) + + test('should have properly merged documents mixed formats (operation + pathItems operation)', async () => { + await runMergeOperationsCase('documents-pathitems-with-mixed-formats') + }) + + test('should have save pathItems in components', async () => { + const { result } = await runPublishPackage( + `document-group/${PATH_ITEMS_OPERATION_PATH}/multiple-pathitems-operations`, + groupToOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + expect(Object.keys(document.data.components.pathItems).length).toEqual(document.operationIds.length) + } + }) + + test('second level object are the same when overriding for pathitems response', async () => { + const { pkg, result } = await runPublishPackage( + `document-group/${PATH_ITEMS_OPERATION_PATH}/second-level-object-are-the-same-when-overriding-for-response`, groupToOnePathOperationIdsMap, + ) + + const expectedResult = load( + (await loadFileAsString(pkg.projectsDir, pkg.packageId, EXPECTED_RESULT_FILE))!, + ) + for (const document of Array.from(result.documents.values())) { + expect(document.data).toEqual(expectedResult) + } + }) + + describe('Chain pathItems Refs', () => { + const COMPONENTS_ITEM_1_PATH = ['components', 'pathItems', 'componentsPathItem1'] + + test('should have documents with keep pathItems in components', async () => { + const { result } = await runPublishPackage( + `document-group/${PATH_ITEMS_OPERATION_PATH}/define-pathitems-via-reference-object-chain`, + groupToOnePathOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + expect(document.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post']) + expect(document.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get']) + } + }) + + test('should have documents stripped of operations other than from provided group', async () => { + const { result } = await runPublishPackage( + `document-group/${PATH_ITEMS_OPERATION_PATH}/define-pathitems-via-reference-object-chain`, + groupWithOneOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + expect(document.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post']) + expect(document.data).not.toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get']) + } + }) }) - const expectedResult = load((await loadFileAsString(pkg.projectsDir, pkg.packageId, EXPECTED_RESULT_FILE))!) - expect(result.merged?.data).toEqual(expectedResult) }) - test('should rename documents with matching names', async () => { - const dashboard = LocalRegistry.openPackage('documents-collision', groupToOperationIdsMap2) - const package1 = LocalRegistry.openPackage('documents-collision/package1') - const package2 = LocalRegistry.openPackage('documents-collision/package2') - const package3 = LocalRegistry.openPackage('documents-collision/package3') + function runCommonTests(folder: DOCUMENT_GROUP_PATHS): void { + test('should have keep a multiple operations in one path', async () => { + const { result } = await runPublishPackage( + `document-group/${folder}/multiple-operations-in-one-path`, + groupToOnePathOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + folder === PATH_ITEMS_OPERATION_PATH + ? expect(Object.keys(document.data.components.pathItems['pathItem1']).length).toEqual(document.operationIds.length) + : expect(Object.keys(document.data.paths['/path1']).length).toEqual(document.operationIds.length) + } + }) - await dashboard.publish(dashboard.packageId, { packageId: dashboard.packageId }) - await package1.publish(package1.packageId, { packageId: package1.packageId }) - await package2.publish(package2.packageId, { packageId: package2.packageId }) - await package3.publish(package3.packageId, { packageId: package3.packageId }) + test('should define operations with servers prefix', async () => { + const { result } = await runPublishPackage( + `document-group/${folder}/define-operations-with-servers-prefix`, + groupToOneServerPrefixPathOperationIdsMap, + ) - const editor = await Editor.openProject(dashboard.packageId, dashboard) - const result = await editor.run({ - packageId: dashboard.packageId, - buildType: BUILD_TYPE.REDUCED_SOURCE_SPECIFICATIONS, - groupName: GROUP_NAME, - apiType: REST_API_TYPE, - }) - - expect(Array.from(result.documents.values())).toEqual( - expect.toIncludeSameMembers([ - expect.objectContaining({ fileId: 'documents-collision/package1_1.yaml', filename: 'documents-collision/package1_1.json' }), - expect.objectContaining({ fileId: 'documents-collision/package1_2.yaml', filename: 'documents-collision/package1_2.json' }), - expect.objectContaining({ fileId: 'documents-collision/package2_1.yaml', filename: 'documents-collision/package2_1.json' }), - expect.objectContaining({ fileId: 'documents-collision/package3_1.yaml', filename: 'documents-collision/package3_1.json' }), - ]), + for (const document of Array.from(result.documents.values())) { + expect(Object.keys(document.data.paths).length).toEqual(document.operationIds.length) + } + }) + + test('should delete pathItems object which is not referenced', async () => { + const { result } = await runPublishPackage( + `document-group/${folder}/not-referenced-object`, + groupToOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + folder === PATH_ITEMS_OPERATION_PATH + ? expect(Object.keys(document.data.components.pathItems).length).toEqual(document.operationIds.length) + : expect(Object.keys(document.data.paths).length).toEqual(document.operationIds.length) + } + }) + + test('should have documents stripped of operations other than from provided group', async () => { + const { result } = await runPublishPackage( + `document-group/${folder}/stripped-of-operations`, + groupToOperationIdsMap, + ) + + for (const document of Array.from(result.documents.values())) { + expect(Object.keys(document.data.paths).length).toEqual(document.operationIds.length) + } + }) + + test('should not hang up when processing for response which points to itself', async () => { + const { result } = await runPublishPackage( + `document-group/${folder}/not-hang-up-when-processing-for-response-which-points-to-itself`, + groupToOnePathOperationIdsMap, + ) + + expect(result.documents.size).toEqual(0) + }) + + test('should not hang up when processing cycled chain for response', async () => { + const pkg = LocalRegistry.openPackage(`document-group/${folder}/not-hang-up-when-processing-cycled-chain-for-response`, groupToOnePathOperationIdsMap) + await pkg.publish(pkg.packageId, { packageId: pkg.packageId }) + + const notificationFile = await loadFileAsString( + VERSIONS_PATH, + `${pkg.packageId}/v1`, + `${PACKAGE.NOTIFICATIONS_FILE_NAME}`, + ) + expect(notificationFile).not.toBeNull() + + const { notifications } = JSON.parse(notificationFile!) as PackageNotifications + + const brokenRefMessages = [ + '$ref can\'t be resolved: #/components/responses/SuccessResponse2', + '$ref can\'t be resolved: #/components/responses/SuccessResponse', + ] + + brokenRefMessages.forEach((message) => { + const found = notifications.some(notification => notification.message === message) + expect(found).toBe(true) + }) + }) + } + + async function runMergeOperationsCase(caseName: string): Promise { + const { pkg, result } = await runPublishPackage( + `merge-operations/${caseName}`, + groupToOperationIdsMap, + { buildType: BUILD_TYPE.MERGED_SPECIFICATION, apiType: REST_API_TYPE }, ) - for (const document of Array.from(result.documents.values())) { - expect(Object.keys(document.data.paths).length).toEqual(document.operationIds.length) - } - }) + const expectedResult = load( + (await loadFileAsString(pkg.projectsDir, pkg.packageId, EXPECTED_RESULT_FILE))!, + ) + + expect(result.merged?.data).toEqual(expectedResult) + } + + async function runPublishPackage( + packageId: string, + groupOperationIds: Record, + options: Partial = { buildType: BUILD_TYPE.REDUCED_SOURCE_SPECIFICATIONS }, + ): Promise<{ pkg: LocalRegistry; result: BuildResult }> { + const pkg = LocalRegistry.openPackage(packageId, groupOperationIds) + const editor = await Editor.openProject(pkg.packageId, pkg) + await pkg.publish(pkg.packageId, { packageId: pkg.packageId }) + + const result = await editor.run({ + ...{ + packageId: pkg.packageId, + groupName: GROUP_NAME, + }, + ...options, + }) + return { pkg, result } + } }) diff --git a/test/hash.test.ts b/test/hash.test.ts new file mode 100644 index 0000000..74c09b6 --- /dev/null +++ b/test/hash.test.ts @@ -0,0 +1,40 @@ +import { loadFileAsString, LocalRegistry, VERSIONS_PATH } from './helpers' +import { PACKAGE } from '../src' + +const GROUP_NAME = 'manualGroup' + +const groupToOnePathOperationIdsMap = { + [GROUP_NAME]: [ + 'path1-get', + 'path1-post', + ], +} + +describe('Hash test', () => { + describe('Document group hash', () => { + async function publishAndGetHash(packagePath: string): Promise { + const pkg = LocalRegistry.openPackage(packagePath, groupToOnePathOperationIdsMap) + await pkg.publish(pkg.packageId, { packageId: pkg.packageId }) + + const operationFile = await loadFileAsString( + VERSIONS_PATH, + `${pkg.packageId}/v1`, + `${PACKAGE.OPERATIONS_FILE_NAME}`, + ) + expect(operationFile).not.toBeNull() + + const operationData = JSON.parse(operationFile!) + + expect(operationData.operations.length).toBe(2) + expect(operationData.operations[0]).not.toEqual(operationData.operations[1]) + } + + test('should be different hashes for each operation', async () => { + await publishAndGetHash('hash/different-hashes-for-each-operation') + }) + + test('should be different hashes for each pathitems operation', async () => { + await publishAndGetHash('hash/different-hashes-for-each-pathitems-operation') + }) + }) +}) diff --git a/test/merge/openapi/openapi.test.ts b/test/merge/openapi/openapi.test.ts index 4df303a..4cdc51c 100644 --- a/test/merge/openapi/openapi.test.ts +++ b/test/merge/openapi/openapi.test.ts @@ -258,12 +258,19 @@ describe('Merge openapi schemas', () => { }) test('Should throw on different methods content', async () => { - // 1: [[../should-throw-on-different-methods/1.yaml]] - // 2: [[../should-throw-on-different-methods/2.yaml]] - const testId = 'should-throw-on-different-methods' + // 1: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-path/1.yaml]] + // 2: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-path/2.yaml]] + const testId = 'should-throw-on-different-methods/should-throw-on-different-methods-in-path' await expect(getTestData(testId)).rejects.toThrowError(/paths.\/path1/) }) + test('Should throw on different pathItems methods content', async () => { + // 1: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/1.yaml]] + // 2: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/2.yaml]] + const testId = 'should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component' + await expect(getTestData(testId)).rejects.toThrowError(/components.pathItems.path1/) + }) + test('Should merge with empty template', async () => { // 1: [[../should-merge-with-empty-template/1.yaml]] // 2: [[../should-merge-with-empty-template/2.yaml]] diff --git a/test/merge/openapi/should-throw-on-different-methods/1.yaml b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-path/1.yaml similarity index 100% rename from test/merge/openapi/should-throw-on-different-methods/1.yaml rename to test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-path/1.yaml diff --git a/test/merge/openapi/should-throw-on-different-methods/2.yaml b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-path/2.yaml similarity index 100% rename from test/merge/openapi/should-throw-on-different-methods/2.yaml rename to test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-path/2.yaml diff --git a/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/1.yaml b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/1.yaml new file mode 100644 index 0000000..450518f --- /dev/null +++ b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/1.yaml @@ -0,0 +1,20 @@ +openapi: 3.1.0 +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/path1' +components: + pathItems: + path1: + post: + parameters: + - name: p1 + in: query + schema: + type: object + responses: + '200': + description: OK + content: {} diff --git a/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/2.yaml b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/2.yaml new file mode 100644 index 0000000..5c8d93d --- /dev/null +++ b/test/merge/openapi/should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/2.yaml @@ -0,0 +1,20 @@ +openapi: 3.1.0 +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/path1' +components: + pathItems: + path1: + get: + parameters: + - name: p1 + in: query + schema: + type: object + responses: + '200': + description: OK + content: {} diff --git a/test/projects/builder/define-pathitems-via-reference-object-chain/1.yaml b/test/projects/builder/define-pathitems-via-reference-object-chain/1.yaml new file mode 100644 index 0000000..de16616 --- /dev/null +++ b/test/projects/builder/define-pathitems-via-reference-object-chain/1.yaml @@ -0,0 +1,34 @@ +openapi: 3.1.0 +info: + title: Pet Store API + version: 1.0.0 +paths: + /path1: + $ref: '#/components/pathItems/componentsPathItem' +components: + schemas: + MySchema: + type: object + properties: + message: + type: string + pathItems: + componentsPathItem: + $ref: '#/components/pathItems/componentsPathItem1' + componentsPathItem1: + post: + responses: + '200': + description: Pet successfully added + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' + get: + responses: + '200': + description: Pet successfully added + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' diff --git a/test/projects/builder/define-pathitems-via-reference-object-chain/config.json b/test/projects/builder/define-pathitems-via-reference-object-chain/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/builder/define-pathitems-via-reference-object-chain/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/declarative-changes-in-rest-operation/case8/after.yaml b/test/projects/declarative-changes-in-rest-operation/case8/after.yaml new file mode 100644 index 0000000..5df6002 --- /dev/null +++ b/test/projects/declarative-changes-in-rest-operation/case8/after.yaml @@ -0,0 +1,48 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /salesOrder: + $ref: '#/components/pathItems/path1' +components: + pathItems: + path1: + get: + operationId: getSalesOrder + summary: get sales order + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/SalesOrder' + schemas: + SalesOrder: + title: SalesOrder + type: object + properties: + id: + type: string + price: + $ref: '#/components/schemas/SalesOrderPrice' + SalesOrderPrice: + title: SalesOrderPrice + type: object + properties: + oneTimeDiscount: + $ref: '#/components/schemas/MonetaryValue' + oneTimeTotalWithTax: + $ref: '#/components/schemas/MonetaryValue' + oneTimeTotalWithTaxDiscounted: + $ref: '#/components/schemas/MonetaryValue' + MonetaryValue: + title: MonetaryValue + type: object + properties: + value: + type: string #! + currency: + type: string diff --git a/test/projects/declarative-changes-in-rest-operation/case8/before.yaml b/test/projects/declarative-changes-in-rest-operation/case8/before.yaml new file mode 100644 index 0000000..dcafdcc --- /dev/null +++ b/test/projects/declarative-changes-in-rest-operation/case8/before.yaml @@ -0,0 +1,48 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /salesOrder: + $ref: '#/components/pathItems/path1' +components: + pathItems: + path1: + get: + operationId: getSalesOrder + summary: get sales order + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/SalesOrder' + schemas: + SalesOrder: + title: SalesOrder + type: object + properties: + id: + type: string + price: + $ref: '#/components/schemas/SalesOrderPrice' + SalesOrderPrice: + title: SalesOrderPrice + type: object + properties: + oneTimeDiscount: + $ref: '#/components/schemas/MonetaryValue' + oneTimeTotalWithTax: + $ref: '#/components/schemas/MonetaryValue' + oneTimeTotalWithTaxDiscounted: + $ref: '#/components/schemas/MonetaryValue' + MonetaryValue: + title: MonetaryValue + type: object + properties: + value: + type: number #! + currency: + type: string diff --git a/test/projects/document-group/path-operations/define-operations-with-servers-prefix/1.yaml b/test/projects/document-group/path-operations/define-operations-with-servers-prefix/1.yaml new file mode 100644 index 0000000..d75e064 --- /dev/null +++ b/test/projects/document-group/path-operations/define-operations-with-servers-prefix/1.yaml @@ -0,0 +1,17 @@ +openapi: 3.1.0 +info: + title: ATUI Petstore 3.0 + version: 1.0.0 +servers: + - url: https://petstore3.swagger.io/api/v1 +paths: + /path1: + get: + responses: + '200': + description: response description main + /path2: + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/path-operations/define-operations-with-servers-prefix/config.json b/test/projects/document-group/path-operations/define-operations-with-servers-prefix/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/define-operations-with-servers-prefix/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/multiple-operations-in-one-path/1.yaml b/test/projects/document-group/path-operations/multiple-operations-in-one-path/1.yaml new file mode 100644 index 0000000..df212ab --- /dev/null +++ b/test/projects/document-group/path-operations/multiple-operations-in-one-path/1.yaml @@ -0,0 +1,16 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + get: + responses: + '200': + description: response description main + post: + responses: + '200': + description: response description main + + diff --git a/test/projects/document-group/path-operations/multiple-operations-in-one-path/config.json b/test/projects/document-group/path-operations/multiple-operations-in-one-path/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/multiple-operations-in-one-path/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml b/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml new file mode 100644 index 0000000..b9515b5 --- /dev/null +++ b/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml @@ -0,0 +1,17 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path1: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' +components: + responses: + SuccessResponse: + $ref: '#/components/responses/SuccessResponse2' + SuccessResponse2: + $ref: '#/components/responses/SuccessResponse' diff --git a/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json b/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml b/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml new file mode 100644 index 0000000..0d85479 --- /dev/null +++ b/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml @@ -0,0 +1,15 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' +components: + responses: + SuccessResponse: + $ref: '#/components/responses/SuccessResponse' diff --git a/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json b/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/not-referenced-object/1.yaml b/test/projects/document-group/path-operations/not-referenced-object/1.yaml new file mode 100644 index 0000000..43a0a2e --- /dev/null +++ b/test/projects/document-group/path-operations/not-referenced-object/1.yaml @@ -0,0 +1,33 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path1: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' +components: + responses: + SuccessResponse: + description: response description SuccessResponse + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + example: true + SuccessResponse1: + description: response description SuccessResponse1 + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + example: true diff --git a/test/projects/document-group/path-operations/not-referenced-object/config.json b/test/projects/document-group/path-operations/not-referenced-object/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/not-referenced-object/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/referenced-json-schema-object/1.yaml b/test/projects/document-group/path-operations/referenced-json-schema-object/1.yaml new file mode 100644 index 0000000..9bc31f6 --- /dev/null +++ b/test/projects/document-group/path-operations/referenced-json-schema-object/1.yaml @@ -0,0 +1,30 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + get: + responses: + '200': + description: response description main + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' + post: + responses: + '200': + description: response description main + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' + +components: + schemas: + MySchema: + type: object + properties: + message: + type: string diff --git a/test/projects/document-group/path-operations/referenced-json-schema-object/config.json b/test/projects/document-group/path-operations/referenced-json-schema-object/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/referenced-json-schema-object/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/path-operations/stripped-of-operations/1.yaml b/test/projects/document-group/path-operations/stripped-of-operations/1.yaml new file mode 100644 index 0000000..f1033ac --- /dev/null +++ b/test/projects/document-group/path-operations/stripped-of-operations/1.yaml @@ -0,0 +1,22 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + post: + responses: + '200': + description: response description main + /path2: + post: + responses: + '200': + description: response description main + # operation other than from provided group + /path3: + post: + responses: + '200': + description: response description main + diff --git a/test/projects/document-group/path-operations/stripped-of-operations/config.json b/test/projects/document-group/path-operations/stripped-of-operations/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/path-operations/stripped-of-operations/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/1.yaml b/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/1.yaml new file mode 100644 index 0000000..56b2cf7 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/1.yaml @@ -0,0 +1,23 @@ +openapi: 3.1.0 +info: + title: ATUI Petstore 3.0 + version: 1.0.0 +servers: + - url: https://petstore3.swagger.io/api/v1 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + $ref: '#/components/pathItems/pathItem2' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + pathItem2: + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/config.json b/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/define-operations-with-servers-prefix/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/1.yaml b/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/1.yaml new file mode 100644 index 0000000..de16616 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/1.yaml @@ -0,0 +1,34 @@ +openapi: 3.1.0 +info: + title: Pet Store API + version: 1.0.0 +paths: + /path1: + $ref: '#/components/pathItems/componentsPathItem' +components: + schemas: + MySchema: + type: object + properties: + message: + type: string + pathItems: + componentsPathItem: + $ref: '#/components/pathItems/componentsPathItem1' + componentsPathItem1: + post: + responses: + '200': + description: Pet successfully added + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' + get: + responses: + '200': + description: Pet successfully added + content: + application/json: + schema: + $ref: '#/components/schemas/MySchema' diff --git a/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/config.json b/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/define-pathitems-via-reference-object-chain/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/1.yaml b/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/1.yaml new file mode 100644 index 0000000..834a2ce --- /dev/null +++ b/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/1.yaml @@ -0,0 +1,18 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/config.json b/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/multiple-operations-in-one-path/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/1.yaml b/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/1.yaml new file mode 100644 index 0000000..4a61e4a --- /dev/null +++ b/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/1.yaml @@ -0,0 +1,21 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + $ref: '#/components/pathItems/pathItem2' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + pathItem2: + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/config.json b/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/multiple-pathitems-operations/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml new file mode 100644 index 0000000..0ab6278 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/1.yaml @@ -0,0 +1,20 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path1: + $ref: '#/components/pathItems/componentsPathItem' +components: + pathItems: + componentsPathItem: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' + responses: + SuccessResponse: + $ref: '#/components/responses/SuccessResponse2' + SuccessResponse2: + $ref: '#/components/responses/SuccessResponse' diff --git a/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-cycled-chain-for-response/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml new file mode 100644 index 0000000..733f306 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/1.yaml @@ -0,0 +1,18 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path: + $ref: '#/components/pathItems/componentsPathItem' +components: + pathItems: + componentsPathItem: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' + responses: + SuccessResponse: + $ref: '#/components/responses/SuccessResponse' diff --git a/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-hang-up-when-processing-for-response-which-points-to-itself/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/not-referenced-object/1.yaml b/test/projects/document-group/pathitems-operations/not-referenced-object/1.yaml new file mode 100644 index 0000000..a2dea66 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-referenced-object/1.yaml @@ -0,0 +1,26 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + $ref: '#/components/pathItems/pathItem2' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + pathItem2: + post: + responses: + '200': + description: response description main + pathItem3: + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/pathitems-operations/not-referenced-object/config.json b/test/projects/document-group/pathitems-operations/not-referenced-object/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/not-referenced-object/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/1.yaml b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/1.yaml new file mode 100644 index 0000000..7981275 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/1.yaml @@ -0,0 +1,23 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path1: + $ref: '#/components/pathItems/componentsPathItem' +components: + pathItems: + componentsPathItem: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' + description: Overriden description + responses: + SuccessResponse: + description: Successful response + content: + application/json: + schema: + type: object diff --git a/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/config.json b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/result.yaml b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/result.yaml new file mode 100644 index 0000000..7981275 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/second-level-object-are-the-same-when-overriding-for-response/result.yaml @@ -0,0 +1,23 @@ +openapi: 3.1.0 +info: + title: Sample API + description: API specification example + version: 1.0.0 +paths: + /path1: + $ref: '#/components/pathItems/componentsPathItem' +components: + pathItems: + componentsPathItem: + post: + responses: + '200': + $ref: '#/components/responses/SuccessResponse' + description: Overriden description + responses: + SuccessResponse: + description: Successful response + content: + application/json: + schema: + type: object diff --git a/test/projects/document-group/pathitems-operations/stripped-of-operations/1.yaml b/test/projects/document-group/pathitems-operations/stripped-of-operations/1.yaml new file mode 100644 index 0000000..2fb59ff --- /dev/null +++ b/test/projects/document-group/pathitems-operations/stripped-of-operations/1.yaml @@ -0,0 +1,29 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + $ref: '#/components/pathItems/pathItem2' + # operation other than from provided group + /path3: + $ref: '#/components/pathItems/pathItem3' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + pathItem2: + post: + responses: + '200': + description: response description main + pathItem3: + post: + responses: + '200': + description: response description main diff --git a/test/projects/document-group/pathitems-operations/stripped-of-operations/config.json b/test/projects/document-group/pathitems-operations/stripped-of-operations/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/document-group/pathitems-operations/stripped-of-operations/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/hash/different-hashes-for-each-operation/1.yaml b/test/projects/hash/different-hashes-for-each-operation/1.yaml new file mode 100644 index 0000000..df212ab --- /dev/null +++ b/test/projects/hash/different-hashes-for-each-operation/1.yaml @@ -0,0 +1,16 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + get: + responses: + '200': + description: response description main + post: + responses: + '200': + description: response description main + + diff --git a/test/projects/hash/different-hashes-for-each-operation/config.json b/test/projects/hash/different-hashes-for-each-operation/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/hash/different-hashes-for-each-operation/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/hash/different-hashes-for-each-pathitems-operation/1.yaml b/test/projects/hash/different-hashes-for-each-pathitems-operation/1.yaml new file mode 100644 index 0000000..834a2ce --- /dev/null +++ b/test/projects/hash/different-hashes-for-each-pathitems-operation/1.yaml @@ -0,0 +1,18 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main + post: + responses: + '200': + description: response description main diff --git a/test/projects/hash/different-hashes-for-each-pathitems-operation/config.json b/test/projects/hash/different-hashes-for-each-pathitems-operation/config.json new file mode 100644 index 0000000..7883400 --- /dev/null +++ b/test/projects/hash/different-hashes-for-each-pathitems-operation/config.json @@ -0,0 +1,13 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/merge-operations/1.yaml b/test/projects/merge-operations/basic-documents-for-merge/1.yaml similarity index 100% rename from test/projects/merge-operations/1.yaml rename to test/projects/merge-operations/basic-documents-for-merge/1.yaml diff --git a/test/projects/merge-operations/2.yaml b/test/projects/merge-operations/basic-documents-for-merge/2.yaml similarity index 100% rename from test/projects/merge-operations/2.yaml rename to test/projects/merge-operations/basic-documents-for-merge/2.yaml diff --git a/test/projects/merge-operations/config.json b/test/projects/merge-operations/basic-documents-for-merge/config.json similarity index 100% rename from test/projects/merge-operations/config.json rename to test/projects/merge-operations/basic-documents-for-merge/config.json diff --git a/test/projects/merge-operations/result.yaml b/test/projects/merge-operations/basic-documents-for-merge/result.yaml similarity index 100% rename from test/projects/merge-operations/result.yaml rename to test/projects/merge-operations/basic-documents-for-merge/result.yaml diff --git a/test/projects/merge-operations/basic-documents-pathitems-for-merge/1.yaml b/test/projects/merge-operations/basic-documents-pathitems-for-merge/1.yaml new file mode 100644 index 0000000..75d742a --- /dev/null +++ b/test/projects/merge-operations/basic-documents-pathitems-for-merge/1.yaml @@ -0,0 +1,44 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' +components: + pathItems: + pathItem1: + summary: path item summary + description: path item description + servers: + - url: https://example1.com + description: This is a server description in path item + parameters: + - $ref: "#/components/parameters/usedParameter1" + get: + summary: operation summary + description: operation description + servers: + - url: https://example2.com + description: This is a server description in operation + parameters: + - $ref: '#/components/parameters/usedParameter2' + responses: + '200': + description: response description + parameters: + usedParameter1: + name: usedParameter1 + in: query + usedParameter2: + name: usedParameter2 + in: query + unusedParameter: + name: unusedParameter + in: query + securitySchemes: + BearerAuth: + type: http + description: Bearer token authentication. Default security scheme for API usage. + scheme: bearer + bearerFormat: JWT diff --git a/test/projects/merge-operations/basic-documents-pathitems-for-merge/2.yaml b/test/projects/merge-operations/basic-documents-pathitems-for-merge/2.yaml new file mode 100644 index 0000000..d9232b0 --- /dev/null +++ b/test/projects/merge-operations/basic-documents-pathitems-for-merge/2.yaml @@ -0,0 +1,28 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path2: + $ref: '#/components/pathItems/pathItem2' +components: + pathItems: + pathItem2: + parameters: + - $ref: "#/components/parameters/usedParameter1" + post: + parameters: + - $ref: '#/components/parameters/usedParameter2' + responses: + '200': + description: response description + parameters: + usedParameter1: + name: usedParameter1 + in: query + usedParameter2: + name: usedParameter2 + in: query + unusedParameter: + name: unusedParameter + in: query diff --git a/test/projects/merge-operations/basic-documents-pathitems-for-merge/config.json b/test/projects/merge-operations/basic-documents-pathitems-for-merge/config.json new file mode 100644 index 0000000..de6cf52 --- /dev/null +++ b/test/projects/merge-operations/basic-documents-pathitems-for-merge/config.json @@ -0,0 +1,19 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a1cd" + }, + { + "fileId": "2.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/merge-operations/basic-documents-pathitems-for-merge/result.yaml b/test/projects/merge-operations/basic-documents-pathitems-for-merge/result.yaml new file mode 100644 index 0000000..2b56d4b --- /dev/null +++ b/test/projects/merge-operations/basic-documents-pathitems-for-merge/result.yaml @@ -0,0 +1,52 @@ +openapi: 3.1.0 +info: + title: manualGroup + version: v1 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + $ref: '#/components/pathItems/pathItem2' +components: + securitySchemes: + BearerAuth: + type: http + description: Bearer token authentication. Default security scheme for API usage. + scheme: bearer + bearerFormat: JWT + pathItems: + pathItem1: + summary: path item summary + description: path item description + servers: + - url: 'https://example1.com' + description: This is a server description in path item + parameters: + - $ref: '#/components/parameters/usedParameter1' + get: + summary: operation summary + description: operation description + servers: + - url: 'https://example2.com' + description: This is a server description in operation + parameters: + - $ref: '#/components/parameters/usedParameter2' + responses: + '200': + description: response description + pathItem2: + parameters: + - $ref: '#/components/parameters/usedParameter1' + post: + parameters: + - $ref: '#/components/parameters/usedParameter2' + responses: + '200': + description: response description + parameters: + usedParameter2: + name: usedParameter2 + in: query + usedParameter1: + name: usedParameter1 + in: query diff --git a/test/projects/merge-operations/documents-pathitems-with-mixed-formats/1.yaml b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/1.yaml new file mode 100644 index 0000000..0e44645 --- /dev/null +++ b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/1.yaml @@ -0,0 +1,14 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main diff --git a/test/projects/merge-operations/documents-pathitems-with-mixed-formats/2.yaml b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/2.yaml new file mode 100644 index 0000000..3ad0b78 --- /dev/null +++ b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/2.yaml @@ -0,0 +1,10 @@ +openapi: "3.1.0" +info: + title: test + version: 0.1.0 +paths: + /path2: + post: + responses: + '200': + description: response description main diff --git a/test/projects/merge-operations/documents-pathitems-with-mixed-formats/config.json b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/config.json new file mode 100644 index 0000000..de6cf52 --- /dev/null +++ b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/config.json @@ -0,0 +1,19 @@ +{ + "packageId": "55", + "apiType": "rest", + "version": "v1", + "files": [ + { + "fileId": "1.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a1cd" + }, + { + "fileId": "2.yaml", + "publish": true, + "labels": [], + "commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd" + } + ] +} diff --git a/test/projects/merge-operations/documents-pathitems-with-mixed-formats/result.yaml b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/result.yaml new file mode 100644 index 0000000..a3d123c --- /dev/null +++ b/test/projects/merge-operations/documents-pathitems-with-mixed-formats/result.yaml @@ -0,0 +1,19 @@ +openapi: 3.1.0 +info: + title: manualGroup + version: v1 +paths: + /path1: + $ref: '#/components/pathItems/pathItem1' + /path2: + post: + responses: + '200': + description: response description main +components: + pathItems: + pathItem1: + get: + responses: + '200': + description: response description main