zijam / swagger2postman

update postman collection from swagger json, to avoid create every time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UPDATE POSTMAN COLLECTION FROM SWAGGER

This tools can update postman collection from swagger json, to avoid create every time.

Note: The tools will merge old config with new, but for request body, it will keep the exist one, not merge.

Use

  1. Clone this repository

  2. Install packages

    Make sure you have install nodejs. Then in project root folder, run npm install to install libs.

  3. Get your postman api key
    In postman, click you account, select account settings. It will open the broswer, you can generate api key there.

  4. Set api key as environment.
    Example in Linux: export POSTMAN_API_KEY=${you key}

    you can also save it to you ~/.zhsrc or ~/.bashrc file

  5. Rename config/default-example.json file to config/default.json and edit like bellow

    {       
         "test":{
             "collection_name":"test import",
             "url":"http://127.0.0.1:8085/v2/api-docs"
         }
     }
    

    The key is command line value name.collection_name is the postman collection name you want to update. url is your swagger url.

  6. Run update
    In project root folder, open command line and run node index.js -s test
    you can also install as gloabl cli. run sudo npm link in root folder, then use apih -s xxx everywhere!

TODO

  • Merge same name collection

Reference

  1. openapi-to-postman/OPTIONS.md at develop · postmanlabs/openapi-to-postman
  2. Update Collection - Postman Public Workspace
  3. axios - npm
  4. postmanlabs/swagger2-postman2: Module and library to convert Swagger 2.0 to a Postman Collection (v2.0)
  5. boschni/json-merger: Merge JSON files and objects with indicators like $import $remove $replace $merge

About

update postman collection from swagger json, to avoid create every time

License:MIT License


Languages

Language:JavaScript 100.0%