I have my API's document in Swagger which have different endpoints or request.
I used the swagger.json
link from my API's in Swagger to import them to Postman as collections and then add test cases there.
But I am confused on one thing that if the developers add more requests to the API how can I import the new request without impacting the test cases.
For e.g.:
In one case I have one API with 65 requests that I imported from Swagger UI and test cases written.
Then after few days I used the same link to import and number of requests changed to 69 which means 4 new request got added but Postman replaced the whole collection with test cases gone.
As posted in a related question, there is no straightforward solution for now. All you can do now is merging the requests outside of Postman. After all, Postman collections are really just JSON data and can be manipulated as such.
I made myself a simple manual helper for step 3 (see the code below), but it can be easily automated in a scripting language of your preference. Steps 1, 2 and 4 can be automated with Newman.
function execute() {
collection = JSON.parse($(".collection").val());
swagger = JSON.parse($(".swagger").val());
result = JSON.stringify($.extend(true, {}, swagger, collection));
$(".result").val(result);
}
<html><body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<br>Collection: <br> <textarea class="collection"></textarea>
<br>Swagger: <br> <textarea class="swagger"></textarea>
<br>Result: <br> <textarea class="result"></textarea>
<br>
<button onClick="execute()">EXECUTE</button>
</body></html>
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