Search code examples
apicurlswaggerswagger-ui

Extract all requests from Swagger documentation


I've been given a URL for the swagger frontend, offering the documentation for a number of POST, GET, PUT and DELETE requests and I need to extract all requests (possibly as cURL commands), without opening each of the items and manually copying the request.

How?


Solution

  • According to https://petstore.swagger.io/ the app is written in React and it's not possible to see the curl request before you click on the section (because it's not in HTML tree at that point). You can try to install CJS plugin for chrome and write jQuery that:

    1. creates temporary textarea
    2. clicks through all necessary sections, their try now button and then their execute button
    3. copies .curl contents to the temporary textarea

    After that you can simpy copy the contents of the textarea to a textfile or something.