https://github.com/kevcui/varman
:guardsman: A script to generate postman/newman global variable json from human readable yaml file
https://github.com/kevcui/varman
bash newm postman
Last synced: about 1 month ago
JSON representation
:guardsman: A script to generate postman/newman global variable json from human readable yaml file
- Host: GitHub
- URL: https://github.com/kevcui/varman
- Owner: KevCui
- License: mit
- Created: 2019-03-23T19:50:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-21T12:17:19.000Z (almost 6 years ago)
- Last Synced: 2025-10-29T06:53:36.415Z (7 months ago)
- Topics: bash, newm, postman
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# varman 
Varman is a script to generate global variables used by [postman](https://www.getpostman.com/) or [newman](https://github.com/postmanlabs/newman) from yaml file. Using YAML format to maintain global variables is easier and human-friendly. Sometimes, it gives you confidence to quickly change variables before execution without messing up json format. :wink:
## Table of Contents
- [How to use?](#how-to-use)
- [Usage](#usage)
- [Example](#example)
- [How can I initialize yaml file?](#how-can-i-initialize-yaml-file)
- [1. Write yaml file from scratch](#1-write-yaml-file-from-scratch)
- [2. Generate yaml file from existing postman collection](#2-generate-yaml-file-from-existing-postman-collection)
- [3. Generate yaml file from existing postman global/environment json](#3-generate-yaml-file-from-existing-postman-globalenvironment-json)
- [How to run tests](#how-to-run-tests)
## How to use?
### Usage
```
Usage:
./varman.sh -i -o
Options
-i: Input yaml file
-o: Output json file
-h --help: Display this help message
```
### Example
Generate `test.json` from `input.yaml`:
```bash
~$ ./varman.sh -i test/input.yaml -o test.json
```
Use generated `test.json` in newman execution:
```bash
~$ newman run -g test.json --export-globals test.json
```
## How can I initialize yaml file?
### 1. Write yaml file from scratch
:pencil:
### 2. Generate yaml file from existing postman collection
```bash
~$ cat | grep -oh "{{\w*}}" | sort | uniq | sed -e 's/{{//;s/}}/: ""/'g > .yaml
```
### 3. Generate yaml file from existing postman global/environment json
```bash
~$ cat .json | jq -r '.values[] | "\(.key): \"\(.value)\""' > .yaml
```
## How to run tests
```bash
~$ bats test/varman.bats
```