Skip to content

Commit

Permalink
Release version v4.25.0 (#838)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
7 people authored Jan 15, 2025
1 parent ba8a7a1 commit 8beb95c
Show file tree
Hide file tree
Showing 11 changed files with 632 additions and 60 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

## [v4.25.0] - 2025-01-15

## [v4.24.0] - 2024-08-13

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

- Base release

[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.24.0...HEAD
[Unreleased]: https://github.com/postmanlabs/openapi-to-postman/compare/v4.25.0...HEAD

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

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

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
---
---

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

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.

Expand All @@ -48,7 +48,7 @@ $ npm i -g openapi-to-postmanv2
```


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

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

Expand Down Expand Up @@ -107,7 +107,7 @@ $ openapi2postmanv2 --test
```


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

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

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

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

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

| *postman* | *openapi* | *related options* |
| --- | --- | :---: |
Expand Down
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ module.exports = {
return cb(new UserError(_.get(schema, 'validationResult.reason', DEFAULT_INVALID_ERROR)));
},

convertV2WithTypes: function(input, options, cb) {
const enableTypeFetching = true;
var schema = new SchemaPack(input, options, MODULE_VERSION.V2, enableTypeFetching);

if (schema.validated) {
return schema.convertV2(cb);
}

return cb(new UserError(_.get(schema, 'validationResult.reason', DEFAULT_INVALID_ERROR)));
},

validate: function (input) {
var schema = new SchemaPack(input);
return schema.validationResult;
Expand Down
4 changes: 2 additions & 2 deletions lib/schemapack.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let path = require('path'),
pathBrowserify = require('path-browserify');

class SchemaPack {
constructor (input, options = {}, moduleVersion = MODULE_VERSION.V1) {
constructor (input, options = {}, moduleVersion = MODULE_VERSION.V1, enableTypeFetching = false) {
if (input.type === schemaUtils.MULTI_FILE_API_TYPE_ALLOWED_VALUE &&
input.data && input.data[0] && input.data[0].path) {
input = schemaUtils.mapDetectRootFilesInputToFolderInput(input);
Expand All @@ -57,7 +57,7 @@ class SchemaPack {
actualStack: 0,
numberOfRequests: 0
};

this.enableTypeFetching = enableTypeFetching;
this.computedOptions = utils.mergeOptions(
// predefined options
_.keyBy(this.definedOptions, 'id'),
Expand Down
22 changes: 18 additions & 4 deletions libV2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = {

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

let collection = {};
let collection = {},
extractedTypesObject = {};

/**
* individually start generating the folder, request, collection
Expand Down Expand Up @@ -91,16 +92,19 @@ module.exports = {
// generate the request form the node
let request = {},
collectionVariables = [],
requestObject = {};
requestObject = {},
requestTypesObject = {};

try {
({ request, collectionVariables } = resolvePostmanRequest(context,
({ request, collectionVariables, requestTypesObject } = resolvePostmanRequest(context,
context.openapi.paths[node.meta.path],
node.meta.path,
node.meta.method
));

requestObject = generateRequestItemObject(request);
extractedTypesObject = Object.assign({}, extractedTypesObject, requestTypesObject);

}
catch (error) {
console.error(error);
Expand Down Expand Up @@ -217,7 +221,17 @@ module.exports = {
if (!_.isEmpty(collection.variable)) {
collection.variable = _.uniqBy(collection.variable, 'key');
}

if (context.enableTypeFetching) {
return cb(null, {
result: true,
output: [{
type: 'collection',
data: collection
}],
analytics: this.analytics || {},
extractedTypes: extractedTypesObject || {}
});
}
return cb(null, {
result: true,
output: [{
Expand Down
Loading

0 comments on commit 8beb95c

Please sign in to comment.