简体   繁体   中英

How to update Postman collection from Swagger

I use Swagger in a Java app and have a collection that sets the parameters eg uuid, name on the corresponding POST requests. However,on every changes on database, the collections should be updated and I fed up with updating the Postman collections manually. I could not found a proper way except from some export approach eg Convert Swagger documentation to Postman Collection .

In this stage, I think I make something wrong and there is a better approach as lots of experienced developers use these tools :

1. How should I transfer swagger requests to Postman and set the parameters while GET requests and use them while POST/PUT requests?

2. How can I update these requests whenever the request parameters are changed on Swagger?

Postman offers the ability to have a 2-way API sync with your Git Repo. Update the Git repo with the new OpenAPI spec. Postman will see the diffs and allow you to pull in the new changes Then you can push the changes to your collections How to Connect to Your Git Repository (4min) Using an External Git Repository (Docs)

Postman has an manual option to import open-api. But in your case you need a utility. Thankfully postman team has written a converter.

Postman provides an open source project to convert OpenAPI 3.0 specs to the Postman Collection (v2) .

It provides a CLI openapi2postmanv2

$ openapi2postmanv2 -s spec.yaml -o collection.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false

Add it to your build process, so you dont have to manually convert.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM