I am QA engineer. The Dev team produces documentation for our product's RESTful API using Swagger. I need to import this to Postman to make it easy to invoke the product's API.
After importing the JSON file (in Swagger format) into Postman, there is 1 but big problem: All titles (and descriptions) of individual requests are blank! (see screen shot below).
Apparently, this is a known issue, documented here: https://github.com/postmanlabs/postman-app-support/issues/1434
We have literally hundreds of requests. I need to find a sufficiently effective yet simple way to ensure all request titles in Postman are populated with a value which I would like to calculate on the fly.
I have been considering the following approach:
Write a command line tool (using NodeJS or another solid platform) which will receive: 1. ID of the collection to fix 2. api key
It will iterate through all requests in the collection. For each request: if Name field is blank, then a substring of the request URL will be assigned to the Name field; if name is not blank, the request is left alone.
What I am unsure about:
- Can I do this programmatically from Postman? It does not make sense to put this code into any one individual request (as pre or post).
(If I have to code this util outside of Postman)
For NodeJS there are "postman-collection" and "postman-sdk" but I am slightly confused which I should use.
Unfortunately, I have not yet found any suitable > library for maintaining Postman collections using C# > or Java.
I am quite frankly confused by the available options. Any guidance will be appreciated.
Importing Link. If we have the Swagger-UI link, we can directly use the link to import the API into Postman.
I had the same problem, solved it thanks to Ian T Price solution (just copy operationId
value into a new key summary
). I decided to write a little javascript utility for this:
function swagPostman(swaggerJson) {
for (let path in swaggerJson.paths) {
let methods = ["get", "head", "post", "put", "delete", "connect", "options", "trace", "patch"];
methods.map(method => {
if ((swaggerJson.paths[path] || {})[method]) {
swaggerJson.paths[path][method].summary =
swaggerJson.paths[path][method].operationId;
}
});
}
return JSON.stringify(swaggerJson);
}
Also made a simple pen where to run the script with a GUI: https://codepen.io/0x616c65/full/pMaQpb. You just copy-paste your swagger.json file in that pen and woilà!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With