Skip to content

Commit 5fd571f

Browse files
committed
chore: merge branch 'feature/performance-optimization' into feature/security-changes-classification
2 parents 1dc10d9 + 5c6cb18 commit 5fd571f

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

src/apitypes/rest/rest.changes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { REST_API_TYPE } from './rest.consts'
6060
import { OpenAPIV3 } from 'openapi-types'
6161
import {
6262
extractOperationSecurityDiffs,
63+
extractOpenapiVersionDiff,
6364
extractPathParamRenameDiff,
6465
extractRootSecurityDiffs,
6566
extractRootServersDiffs,
@@ -174,6 +175,7 @@ export const compareDocuments = async (
174175
const relevantSecuritySchemesNames = shouldTakeRootSecurityDiffs ? extractSecuritySchemesNames(merged.security ?? []) : extractSecuritySchemesNames(methodData?.security ?? [])
175176
operationDiffs = [
176177
...(methodData as WithAggregatedDiffs<OpenAPIV3.OperationObject>)[DIFFS_AGGREGATED_META_KEY] ?? [],
178+
...extractOpenapiVersionDiff(merged),
177179
...extractRootServersDiffs(merged),
178180
...shouldTakeRootSecurityDiffs ? extractRootSecurityDiffs(merged) : [],
179181
...extractSecuritySchemesDiffs(merged.components, relevantSecuritySchemesNames),

src/apitypes/rest/rest.utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export const dump = (value: unknown, format: typeof FILE_FORMAT_YAML | typeof FI
7070
throw new Error(`Unsupported format: ${format}`)
7171
}
7272

73+
export const extractOpenapiVersionDiff = (doc: OpenAPIV3.Document): Diff[] => {
74+
const diff = (doc as WithDiffMetaRecord<OpenAPIV3.Document>)[DIFF_META_KEY]?.openapi
75+
return diff ? [diff] : []
76+
}
77+
7378
export const extractPathParamRenameDiff = (doc: OpenAPIV3.Document, path: string): Diff[] => {
7479
const diff = (doc.paths as WithDiffMetaRecord<OpenAPIV3.PathsObject>)[DIFF_META_KEY]?.[path]
7580
return diff && isPathParamRenameDiff(diff) ? [diff] : []

test/changes.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ describe('Changelog build type', () => {
244244
[UNCLASSIFIED_CHANGE_TYPE]: 1,
245245
}))
246246
})
247+
248+
test('Change openapi version', async () => {
249+
const result = await buildChangelogPackage('changelog/change-openapi-version')
250+
251+
expect(result).toEqual(changesSummaryMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }))
252+
expect(result).toEqual(numberOfImpactedOperationsMatcher({ [ANNOTATION_CHANGE_TYPE]: 1 }))
253+
})
247254
})
248255

249256
test('Operation changes fields are correct', async () => {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
openapi: 3.0.4
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
get:
8+
responses:
9+
'200':
10+
description: OK
11+
content: {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
openapi: 3.0.3
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
get:
8+
responses:
9+
'200':
10+
description: OK
11+
content: {}

0 commit comments

Comments
 (0)