Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update postman collection from swagger specification file

I'm importing a swagger specification file into postman to create a collection, at this point, works as expected and the collection is generated with all requests & sub-folders, fine!!. But when the api is updated, I need update the postman to update all requests based on the new specification. I can't find a action like "update" or something else. I'm trying import the new specification into postman and he say:

A collection APIName already exists. What would you like to do?

Replace or Import as copy

a copy its a not feasible option, then I use replace and the existent collection is updated, but all tests, parameters, pre-req scripts are remove and I need reconfigure all again.

I'm missing something, exist a way to import & update a existent collection from a specification file, without losing existent tests & configuration?

thanks in advance!

like image 718
rafrsr Avatar asked Jul 31 '17 15:07

rafrsr


People also ask

How do you update API collection in Postman?

To update the collection that users see when they use the Run in Postman button, you'll need to update the collection link. From the SHARE COLLECTION modal in the Postman app, click the Update Link button to refresh the collection.


2 Answers

I have made a small tool to do this: swagger2postman: convert swagger to postman collection and update exist collection

The tool will combine new and old collection, when conflict, it will use saved in postman. The tool can detect update in query parameter, but not post body. It will keep all your collection and test cases.

like image 77
ysjiang Avatar answered Dec 11 '22 22:12

ysjiang


Postman does not support this as of now. Link

Alternative I learned from this blog. In short:

  1. Update your OpenAPI YAML/JSON files.
  2. Import to Postman as a new collection.
  3. Export the new collection from Postman. As JSON in Collection v2.1 format (recommended).
  4. Using Postman API (Update Collection), update the existing collection with the JSON in step 3 as body. Make sure to update collection_uid accordingly.

Postman update collection API body sample:

{
  "collection": 
  <------- YOUR EXPORTED COLLECTION HERE --------->
}
like image 42
Mr3381 Avatar answered Dec 12 '22 00:12

Mr3381