Skip to content

Commit 8beb95c

Browse files
github-actions[bot]VShingalathim81Yashkrit-Singhbarshan23
authored
Release version v4.25.0 (#838)
* Fix undefined example.$ref * Throw fatal error to allow error handling in module usage * Revert back * Fix Table of Contents links and validate preview * [AB-290]-Extracting-type-information from OAS (#834) - AB-290-extracting-type-information * Prepare release v4.25.0 --------- Co-authored-by: Vishal Shingala <[email protected]> Co-authored-by: Thim <[email protected]> Co-authored-by: Yashkrit-Singh <[email protected]> Co-authored-by: Avishek Saha <[email protected]> Co-authored-by: Ayush Shrivastav <[email protected]> Co-authored-by: GitHub Actions <[email protected]>
1 parent ba8a7a1 commit 8beb95c

File tree

11 files changed

+632
-60
lines changed

11 files changed

+632
-60
lines changed

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+
## [v4.25.0] - 2025-01-15
6+
57
## [v4.24.0] - 2024-08-13
68

79
### Added
@@ -647,7 +649,9 @@ Newer releases follow the [Keep a Changelog](https://keepachangelog.com/en/1.0.0
647649

648650
- Base release
649651

650-
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.24.0...HEAD
652+
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.25.0...HEAD
653+
654+
[v4.25.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.24.0...v4.25.0
651655

652656
[v4.24.0]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.23.1...v4.24.0
653657

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
---
3434
---
3535

36-
## 💭 Getting Started
36+
<h2 id="getting-started">💭 Getting Started</h2>
3737

3838
To use the converter as a Node module, you need to have a copy of the NodeJS runtime. The easiest way to do this is through npm. If you have NodeJS installed you have npm installed as well.
3939

@@ -48,7 +48,7 @@ $ npm i -g openapi-to-postmanv2
4848
```
4949

5050

51-
## 📖 Command Line Interface
51+
<h2 id="command-line-interface">📖 Command Line Interface</h2>
5252

5353
The converter can be used as a CLI tool as well. The following [command line options](#options) are available.
5454

@@ -107,7 +107,7 @@ $ openapi2postmanv2 --test
107107
```
108108

109109

110-
## 🛠 Using the converter as a NodeJS module
110+
<h2 id="using-the-converter-as-a-nodejs-module">🛠 Using the converter as a NodeJS module</h2>
111111

112112
In order to use the convert in your node application, you need to import the package using `require`.
113113

@@ -219,7 +219,7 @@ The validate function is synchronous and returns a status object which conforms
219219

220220
- `reason` - Provides a reason for an unsuccessful validation of the specification
221221

222-
## 🧭 Conversion Schema
222+
<h2 id="conversion-schema">🧭 Conversion Schema</h2>
223223

224224
| *postman* | *openapi* | *related options* |
225225
| --- | --- | :---: |

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ module.exports = {
2828
return cb(new UserError(_.get(schema, 'validationResult.reason', DEFAULT_INVALID_ERROR)));
2929
},
3030

31+
convertV2WithTypes: function(input, options, cb) {
32+
const enableTypeFetching = true;
33+
var schema = new SchemaPack(input, options, MODULE_VERSION.V2, enableTypeFetching);
34+
35+
if (schema.validated) {
36+
return schema.convertV2(cb);
37+
}
38+
39+
return cb(new UserError(_.get(schema, 'validationResult.reason', DEFAULT_INVALID_ERROR)));
40+
},
41+
3142
validate: function (input) {
3243
var schema = new SchemaPack(input);
3344
return schema.validationResult;

lib/schemapack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let path = require('path'),
3838
pathBrowserify = require('path-browserify');
3939

4040
class SchemaPack {
41-
constructor (input, options = {}, moduleVersion = MODULE_VERSION.V1) {
41+
constructor (input, options = {}, moduleVersion = MODULE_VERSION.V1, enableTypeFetching = false) {
4242
if (input.type === schemaUtils.MULTI_FILE_API_TYPE_ALLOWED_VALUE &&
4343
input.data && input.data[0] && input.data[0].path) {
4444
input = schemaUtils.mapDetectRootFilesInputToFolderInput(input);
@@ -57,7 +57,7 @@ class SchemaPack {
5757
actualStack: 0,
5858
numberOfRequests: 0
5959
};
60-
60+
this.enableTypeFetching = enableTypeFetching;
6161
this.computedOptions = utils.mergeOptions(
6262
// predefined options
6363
_.keyBy(this.definedOptions, 'id'),

libV2/index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ module.exports = {
3232

3333
let preOrderTraversal = GraphLib.alg.preorder(collectionTree, 'root:collection');
3434

35-
let collection = {};
35+
let collection = {},
36+
extractedTypesObject = {};
3637

3738
/**
3839
* individually start generating the folder, request, collection
@@ -91,16 +92,19 @@ module.exports = {
9192
// generate the request form the node
9293
let request = {},
9394
collectionVariables = [],
94-
requestObject = {};
95+
requestObject = {},
96+
requestTypesObject = {};
9597

9698
try {
97-
({ request, collectionVariables } = resolvePostmanRequest(context,
99+
({ request, collectionVariables, requestTypesObject } = resolvePostmanRequest(context,
98100
context.openapi.paths[node.meta.path],
99101
node.meta.path,
100102
node.meta.method
101103
));
102104

103105
requestObject = generateRequestItemObject(request);
106+
extractedTypesObject = Object.assign({}, extractedTypesObject, requestTypesObject);
107+
104108
}
105109
catch (error) {
106110
console.error(error);
@@ -217,7 +221,17 @@ module.exports = {
217221
if (!_.isEmpty(collection.variable)) {
218222
collection.variable = _.uniqBy(collection.variable, 'key');
219223
}
220-
224+
if (context.enableTypeFetching) {
225+
return cb(null, {
226+
result: true,
227+
output: [{
228+
type: 'collection',
229+
data: collection
230+
}],
231+
analytics: this.analytics || {},
232+
extractedTypes: extractedTypesObject || {}
233+
});
234+
}
221235
return cb(null, {
222236
result: true,
223237
output: [{

0 commit comments

Comments
 (0)