4.1.8 • Published 1 year ago

postman-collection-transformer v4.1.8

Weekly downloads
289,153
License
Apache-2.0
Repository
github
Last release
1 year ago

Postman Collection Transformer Build Status

Perform rapid conversion of JSON structure between Postman Collection Format v1 and v2.

The formats are documented at https://schema.postman.com

Installation

For CLI usage:

$ npm install -g postman-collection-transformer

As a library:

$ npm install --save postman-collection-transformer

Usage

Converting Entire Collections

The transformer provides a Command line API to convert collections.

Example:

$ postman-collection-transformer convert \
    --input ./v1-collection.json \
    --input-version 2.0.0 \
    --output ./v2-collection.json \
    --output-version 1.0.0 \
    --pretty \
    --overwrite

All options:

$ postman-collection-transformer convert -h

  Usage: convert [options]

  Convert Postman Collection from one format to another

  Options:

    -h, --help                      output usage information
    -i, --input <path>              path to the input postman collection file
    -j, --input-version [version]   the version of the input collection format standard (v1 or v2)
    -o, --output <path>             target file path where the converted collection will be written
    -p, --output-version [version]  required version to which the collection is needed to be converted to
    -P, --pretty                    Pretty print the output
    --retain-ids                    Retain the request and folder IDs during conversion (collection ID is always retained)
    -w, --overwrite                 Overwrite the output file if it exists

If you'd rather use the transformer as a library:

    var transformer = require('postman-collection-transformer'),
        collection = require('./path/to/collection.json'),
        inspect = require('util').inspect,

        options = {
            inputVersion: '1.0.0',
            outputVersion: '2.0.0',
            retainIds: true  // the transformer strips request-ids etc by default.
        };

    transformer.convert(collection, options, function (error, result) {
        if (error) {
            return console.error(error);
        }

        // result <== the converted collection as a raw Javascript object
        console.log(inspect(result, {colors: true, depth: 10000}));
    });

Converting Individual Requests

The transformer also allows you to convert individual requests (only supported when used as a library):

Example
    var transformer = require('postman-collection-transformer'),

        objectToConvert = { /* A valid collection v1 Request or a collection v2 Item */ },

        options = {
            inputVersion: '1.0.0',
            outputVersion: '2.0.0',
            retainIds: true  // the transformer strips request-ids etc by default.
        };

    transformer.convertSingle(objectToConvert, options, function (err, converted) {
        console.log(converted);
    });

Converting Individual Responses

You can convert individual responses too if needed:

Example
    var transformer = require('postman-collection-transformer'),

        objectToConvert = { /* A v1 Response or a v2 Response */ },

        options = {
            inputVersion: '1.0.0',
            outputVersion: '2.0.0',
            retainIds: true  // the transformer strips request-ids etc by default.
        };

    transformer.convertResponse(objectToConvert, options, function (err, converted) {
        console.log(converted);
    });

Normalizing v1 collections

The transformer also provides a Command line API to normalize collections for full forward compatibility.

Example:

$ postman-collection-transformer normalize \
    --input ./v1-collection.json \
    --normalize-version 1.0.0 \
    --output ./v1-norm-collection.json \
    --pretty \
    --overwrite

All options:

$ postman-collection-transformer normalize -h

  Usage: normalize [options]

  Normalizes a postman collection according to the provided version


  Options:

    -i, --input <path>                 Path to the collection JSON file to be normalized
    -n, --normalize-version <version>  The version to normalizers the provided collection on
    -o, --output <path>                Path to the target file, where the normalized collection will be written
    -P, --pretty                       Pretty print the output
    --retain-ids                       Retain the request and folder IDs during conversion (collection ID is always retained)
    -w, --overwrite                    Overwrite the output file if it exists
    -h, --help                         Output usage information

If you'd rather use the transformer as a library:

    var transformer = require('postman-collection-transformer'),
        collection = require('./path/to/collection.json'),
        inspect = require('util').inspect,

        options = {
            normalizeVersion: '1.0.0',
            mutate: false, // performs in-place normalization, false by default.
            noDefaults: false, // when set to true, sensible defaults for missing properties are skipped. Default: false
            prioritizeV2: false, // when set to true, v2 attributes are used as the source of truth for normalization.
            retainEmptyValues: false, // when set to true, empty values are set to '', not removed. False by default.
            retainIds: true  // the transformer strips request-ids etc by default.
        };

    transformer.normalize(collection, options, function (error, result) {
        if (error) {
            return console.error(error);
        }

        // result <== the converted collection as a raw Javascript object
        console.log(inspect(result, {colors: true, depth: 10000}));
    });
4.1.8

1 year ago

4.1.7

1 year ago

4.1.6

3 years ago

4.1.5

3 years ago

4.1.4

3 years ago

4.1.3

3 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.3.3

4 years ago

3.3.2

4 years ago

3.3.1

5 years ago

3.3.1-beta.1

5 years ago

3.3.0

5 years ago

3.3.0-beta.2

5 years ago

3.3.0-beta.1

5 years ago

3.2.0

5 years ago

3.1.3-beta.1

5 years ago

3.1.2

5 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

3.0.0-beta.3

6 years ago

3.0.0-beta.2

6 years ago

3.0.0-beta.1

6 years ago

2.8.0-hotfix.1

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.3

6 years ago

2.6.2-hotfix.2

6 years ago

2.6.1-hotfix.1

6 years ago

2.6.2-hotfix.1

6 years ago

2.6.2

6 years ago

2.6.1

6 years ago

2.6.0

6 years ago

2.5.10

6 years ago

2.5.9

7 years ago

2.5.8

7 years ago

2.5.7

7 years ago

2.5.6

7 years ago

2.5.5

7 years ago

2.5.4

7 years ago

2.5.3

7 years ago

2.5.2

7 years ago

2.5.1

7 years ago

2.5.0

7 years ago

2.5.0-beta.1

7 years ago

2.4.3

7 years ago

2.4.3-beta.1

7 years ago

2.4.2

7 years ago

2.4.2-beta.2

7 years ago

2.4.2-beta.1

7 years ago

2.4.1

7 years ago

2.4.1-beta.1

7 years ago

2.4.0

7 years ago

2.4.0-beta.9

7 years ago

2.4.0-beta.8

7 years ago

2.4.0-beta.7

7 years ago

2.4.0-beta.6

7 years ago

2.4.0-beta.5

7 years ago

2.4.0-beta.4

7 years ago

2.4.0-beta.3

7 years ago

2.4.0-beta.2

7 years ago

2.4.0-beta.1

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.2.0-beta.1

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.1-beta.2

8 years ago

2.1.1-beta.1

8 years ago

2.1.0

8 years ago

2.1.0-beta.6

8 years ago

2.1.0-beta.5

8 years ago

2.1.0-beta.4

8 years ago

2.1.0-beta.3

8 years ago

2.1.0-beta.2

8 years ago

2.1.0-beta.1

8 years ago

2.0.14

8 years ago

2.0.13

8 years ago

2.0.13-beta.2

8 years ago

2.0.13-beta.1

8 years ago

2.0.12

8 years ago

2.0.11-beta.1

8 years ago

2.0.10

8 years ago

2.0.9

8 years ago

2.0.9-beta.1

8 years ago

2.0.9-beta.0

8 years ago

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.7.7

8 years ago

1.7.6

8 years ago

1.7.5

8 years ago

1.7.4

8 years ago

1.7.3

8 years ago

1.7.2

8 years ago

1.7.1

8 years ago

1.7.0

8 years ago

1.6.3

8 years ago

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

0.1.1-hotfix.3

9 years ago

0.1.1-hotfix.2

9 years ago

1.5.6

9 years ago

1.5.5

9 years ago

1.5.4

9 years ago

1.5.3

9 years ago

1.5.2

9 years ago

1.5.0

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

0.1.1-hotfix.1

9 years ago

1.1.0-hotfix.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago