How can I export a Swagger definition file (it should be a JSON or YAML file)? I am being asked for such and I have only cursory knowledge about Swagger.
We do have an endpoint looking like http://example.com//swagger/ui/index#!
which looks like this (the screenshot is not our real endpoint though, I can't post that):
The version is api version: v1
.
There is no "Export" button that I can see. So how do I export it?
The URL of the API definiton is displayed in the top bar of Swagger UI – in your example it's
/v2/api-docs?group=full-petstore-api
So the full URL appears to be
http://localhost:8080/v2/api-docs?group=full-petstore-api
In newer versions of Swagger UI, the link to the API definition is often displayed below the API title, so you can right-click the link and Save As.
If your Swagger UI does not have a visible link to the API definition, view the page source and look for the url
parameter, such as:
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json", // <-------
dom_id: '#swagger-ui',
If you don't see the url
or if url
is a code expression, open the browser dev tools, switch to the Network tab and disable caching. Then refresh the page and search for the API definition file (swagger.json
, swagger.yaml
, api-docs
or similar) among HTTP requests. You can filter by XHR to narrow down the list.
Sometimes the OpenAPI definition may be embedded within a .js file – in this case take this file and strip out the extra parts.