The easiest way to get started with this Collection is to click the fork button to fork this Collection to your own Workspace and use Postman to send requests.
Fetch the ID of the Collection you wish to convert. This can be found by selecting the Collection in Postman, navigating to the right-hand sidebar, clicking the Info tab (symbolized by the i icon), and copying the ID.
Method: GET
URL: https://api.getpostman.com/collections/31XXX524-0XX23617-XXXX-XXXX-XXXX-XXXXX22b1
Headers: X-API-Key:PMAK-XXXXXXXX-XXXXXXXXXXXXXXX11e613
Scripts [ Post-response ]
const res = pm.response.json();
const collection = JSON.stringify(res.collection);
const makeVisualizerTemplate = (swagger, errors, warnings) => `Swagger:<br> <textarea style="width: 100vw; height: 100vh; font-family: monospace;">${JSON.stringify(swagger)}</textarea><br>
Errors:<br><textarea style="width: 100vw; height: 100vh; font-family: monospace;">${JSON.stringify(errors)}</textarea><br>
Warnings:<br><textarea style="width: 100vw; height: 100vh; font-family: monospace;">${JSON.stringify(warnings)}</textarea>`;
pm.sendRequest({
url: `https://demo.postmansolutions.com/postman2swagger`,
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'raw',
raw: collection
}
}, (err, res) => {
const payload = JSON.parse(res.text());
const visualizerTemplate = makeVisualizerTemplate(payload.swagger, payload.errors, payload.warnings);
pm.visualizer.set(visualizerTemplate);
});This request will generate a Swagger 2.0 Schema from a Postman Collection. Just hit Send, and click Visualize in the response!