@postman-enricher/core 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -19,6 +19,14 @@ import { preserveIds } from './enrichers/preserveIds.js';
19
19
  * @returns Enriched Postman collection
20
20
  */
21
21
  export declare function enrichCollection(collection: PostmanCollection, config?: EnrichmentConfig | string, existingCollectionPath?: string): PostmanCollection;
22
+ /**
23
+ * Convert OpenAPI spec to Postman collection and enrich it
24
+ * @param openApiPath - Path to OpenAPI spec file (YAML or JSON)
25
+ * @param config - Enrichment configuration (object or path to YAML file)
26
+ * @param existingCollectionPath - Optional path to existing collection for ID preservation
27
+ * @returns Promise of enriched Postman collection
28
+ */
29
+ export declare function convertAndEnrich(openApiPath: string, config?: EnrichmentConfig | string, existingCollectionPath?: string): Promise<PostmanCollection>;
22
30
  /**
23
31
  * Load enrichment configuration from a YAML file
24
32
  * @param filePath - Path to YAML configuration file
package/dist/index.js CHANGED
@@ -12,6 +12,8 @@ import { addTests } from './enrichers/tests.js';
12
12
  import { organizeByResources } from './enrichers/organize.js';
13
13
  import { setupPathVariables } from './enrichers/pathVariables.js';
14
14
  import { preserveIds } from './enrichers/preserveIds.js';
15
+ // @ts-expect-error - openapi-to-postmanv2 doesn't have types
16
+ import Converter from 'openapi-to-postmanv2';
15
17
  /**
16
18
  * Enrich a Postman collection with additional metadata and functionality
17
19
  * @param collection - Postman collection to enrich
@@ -57,6 +59,32 @@ export function enrichCollection(collection, config = {}, existingCollectionPath
57
59
  }
58
60
  return enriched;
59
61
  }
62
+ /**
63
+ * Convert OpenAPI spec to Postman collection and enrich it
64
+ * @param openApiPath - Path to OpenAPI spec file (YAML or JSON)
65
+ * @param config - Enrichment configuration (object or path to YAML file)
66
+ * @param existingCollectionPath - Optional path to existing collection for ID preservation
67
+ * @returns Promise of enriched Postman collection
68
+ */
69
+ export async function convertAndEnrich(openApiPath, config = {}, existingCollectionPath) {
70
+ const openApiSpec = readFileSync(openApiPath, 'utf8');
71
+ // Convert OpenAPI to Postman collection
72
+ const baseCollection = await new Promise((resolve, reject) => {
73
+ Converter.convert({ type: 'string', data: openApiSpec }, {}, (err, result) => {
74
+ if (err) {
75
+ reject(err);
76
+ }
77
+ else if (!result.result) {
78
+ reject(new Error(result.reason || 'Conversion failed'));
79
+ }
80
+ else {
81
+ resolve(result.output[0].data);
82
+ }
83
+ });
84
+ });
85
+ // Enrich the collection
86
+ return enrichCollection(baseCollection, config, existingCollectionPath);
87
+ }
60
88
  /**
61
89
  * Load enrichment configuration from a YAML file
62
90
  * @param filePath - Path to YAML configuration file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-enricher/core",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Core enrichment logic for Postman Enricher",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,8 +15,9 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
+ "openapi-to-postmanv2": "^5.5.0",
18
19
  "yaml": "^2.8.1",
19
- "@postman-enricher/shared": "1.1.0"
20
+ "@postman-enricher/shared": "1.2.1"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@anolilab/semantic-release-pnpm": "^3.0.0",