Skip to content

Commit a3e689c

Browse files
authored
Merge pull request #956 from postmanlabs/release/v6.3.0
Release version v6.3.0
2 parents 50ed171 + b848e6c commit a3e689c

12 files changed

Lines changed: 324 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [v6.3.0] - 2026-07-07
6+
57
## [v6.2.0] - 2026-06-29
68

79
## [v6.1.0] - 2026-06-09
@@ -695,7 +697,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com/en/1.0.0
695697

696698
- Base release
697699

698-
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v6.2.0...HEAD
700+
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v6.3.0...HEAD
701+
702+
[v6.3.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v6.2.0...v6.3.0
699703

700704
[v6.2.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v6.1.0...v6.2.0
701705

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,18 @@ $ openapi2postmanv2 -s spec.yaml --sync collection.json --sync-options-config sy
142142
**sync-options.json:**
143143
```json
144144
{
145-
"syncExamples": true
145+
"syncExamples": true,
146+
"deleteOrphanedRequests": false
146147
}
147148
```
148149

150+
#### Available Sync Options
151+
152+
| id | type | default | description |
153+
|---|---|---|---|
154+
| `syncExamples` | boolean | `false` | Whether to sync response examples from the OpenAPI specification to the collection. When enabled, response examples in the spec are synced with existing collection responses. |
155+
| `deleteOrphanedRequests` | boolean | `false` | Whether to delete requests and folders that exist in the collection but no longer exist in the OpenAPI specification. When disabled (default), such orphans are preserved to avoid unintentional data loss. |
156+
149157
For a complete list of sync options and their usage, see [SYNC_OPTIONS.md](/SYNC_OPTIONS.md)
150158

151159

@@ -314,7 +322,8 @@ const fs = require('fs'),
314322
existingCollection = JSON.parse(fs.readFileSync('collection.json', {encoding: 'UTF8'}));
315323

316324
const syncOptions = {
317-
syncExamples: true
325+
syncExamples: true,
326+
deleteOrphanedRequests: false
318327
};
319328

320329
Converter.syncCollection(

SYNC_OPTIONS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This document describes the available options for syncing OpenAPI specifications
77
| id | type | default | description | version |
88
|---|---|---|---|---|
99
| syncExamples | boolean | false | Whether to sync response examples from the OpenAPI specification to the collection. When enabled, response examples in the spec will be synced with existing collection responses. | v2 |
10+
| deleteOrphanedRequests | boolean | false | Whether to delete requests and folders that exist in the collection but no longer exist in the OpenAPI specification. When disabled (default), such orphans are preserved to avoid unintentional data loss. | v2 |
1011

1112
## Usage
1213

lib/options.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,19 @@ module.exports = {
486486
usage: ['SYNC'],
487487
supportedIn: [VERSION20, VERSION30, VERSION31, VERSION32],
488488
supportedModuleVersion: [MODULE_VERSION.V2]
489+
},
490+
{
491+
name: 'Delete orphaned requests',
492+
id: 'deleteOrphanedRequests',
493+
type: 'boolean',
494+
default: false,
495+
description: 'Whether to delete requests and folders that exist in the collection but no longer ' +
496+
'exist in the OpenAPI specification. When disabled (default), such orphans are preserved to ' +
497+
'avoid unintentional data loss.',
498+
external: true,
499+
usage: ['SYNC'],
500+
supportedIn: [VERSION20, VERSION30, VERSION31, VERSION32],
501+
supportedModuleVersion: [MODULE_VERSION.V2]
489502
}
490503
];
491504

libV2/SpecificationCollectionSyncing/shared/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ export const ALLOWED_AUTH_PARAM_KEYS_BY_TYPE: Record<string, Set<string>> = {
4343
};
4444

4545
export const DEFAULT_SYNC_OPTIONS: SyncOptions = {
46-
syncExamples: false
46+
syncExamples: false,
47+
deleteOrphanedRequests: false
4748
};

libV2/SpecificationCollectionSyncing/shared/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,10 @@ export interface AuthMergeResult {
8484

8585
export type SyncOptions = {
8686
syncExamples: boolean;
87+
/**
88+
* When true, requests (and folders) that exist in the collection but no longer exist in the
89+
* specification are removed during spec -> collection syncing.
90+
* When false (default), such orphans are preserved to avoid unintentional data loss.
91+
*/
92+
deleteOrphanedRequests?: boolean;
8793
};

libV2/SpecificationCollectionSyncing/spec-to-collection/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ export function syncCollection(
164164
}
165165
});
166166

167+
// When opted in, remove orphans: requests and folders that exist in the collection but no longer
168+
// exist in the latest spec-derived state. Matched folders are pruned recursively above via the
169+
// sync loop (mergedOptions is propagated), so here we only drop unmatched items at this level.
170+
if (mergedOptions.deleteOrphanedRequests) {
171+
currentCollectionState.items.remove((item: Item | ItemGroup<Item>) => {
172+
if (item instanceof ItemGroup) {
173+
return !findFolderItemByName(latestCollectionState, item.name);
174+
}
175+
176+
return !findRequestItemByPathAndMethod(latestCollectionState, getRequestIdentifier(item));
177+
}, currentCollectionState);
178+
}
179+
167180
currentCollectionState.description = latestCollectionState.description;
168181

169182
const existingCollectionAuth = _.cloneDeep(currentCollectionState?.auth?.toJSON()) ?? {},

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-to-postmanv2",
3-
"version": "6.2.0",
3+
"version": "6.3.0",
44
"description": "Convert a given OpenAPI specification to Postman Collection v2.0",
55
"homepage": "https://github.com/postmanlabs/openapi-to-postman",
66
"bugs": "https://github.com/postmanlabs/openapi-to-postman/issues",

test/unit/CollectionGenerationAndSyncing/fixtures/OpenAPI3/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
shouldSyncRequestToFirstResponseOnly: require('./shouldSyncRequestToFirstResponseOnly'),
3131
shouldPreserveOtherSameCodeResponsesOnRequestSync: require('./shouldPreserveOtherSameCodeResponsesOnRequestSync'),
3232
shouldPairSameCodeExamplesPositionallyOnSync: require('./shouldPairSameCodeExamplesPositionallyOnSync'),
33+
shouldDeleteOrphanRequestsWhenEnabled: require('./shouldDeleteOrphanRequestsWhenEnabled'),
3334
// Multi-file specification test cases
3435
multiFileSpecs: require('./multiFileSpecs')
3536
};

0 commit comments

Comments
 (0)