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.


Another way to find the actual url is to use the browser console and evaluate one of the following values, depending on your UI version:

  • Swagger UI 3.x and later:

    ui.getConfigs().url
    
  • Swagger UI 2.x:

    swaggerUi.api.url
    


Sometimes the OpenAPI definition may be embedded within a .js file – in this case take this file and strip out the extra parts.

Answer from Helen on Stack Overflow
🌐
Swagger
swagger.io › docs › open-source-tools › swagger-ui › usage › configuration
Configuration | Swagger Docs
Example: Terminal window · 1 · SPEC="{ \"openapi\": \"3.0.4\" }" Terminal window · 1 · SUPPORTED_SUBMIT_METHODS=['get', 'post'] 2 · URLS=[ { url: 'https://petstore.swagger.io/v2/swagger.json', name: 'Petstore' } ]
Top answer
1 of 12
225

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.


Another way to find the actual url is to use the browser console and evaluate one of the following values, depending on your UI version:

  • Swagger UI 3.x and later:

    ui.getConfigs().url
    
  • Swagger UI 2.x:

    swaggerUi.api.url
    


Sometimes the OpenAPI definition may be embedded within a .js file – in this case take this file and strip out the extra parts.

2 of 12
28

Though it's already been answered and it's the correct one, I thought I shall post the much detailed version of it.. Hope this helps,

  1. If you do have the swagger json file which you feed to the swagger UI, then to generate .yaml file just click on the below link copy-paste your json in the editor and download the yaml file. This is a straight forward method

link : https://editor.swagger.io/#

  1. Now the second way where you don't have any swagger json file then the following steps should help,

Open the swagger ui, inspect (Shift+Ctrl+i), refresh the page and you will get the tabs like below

Choose XHR or All tab under Network tab, check for the file api-doc?group=* and click subtab response. *Now copy the content of ap-doc?group.** file and use the same editor link to convert to yaml file

link : https://editor.swagger.io/#

Discussions

How to use local json file in swagger-ui documentation - Stack Overflow
I am trying to use local swagger.json file to be displayed in swagger documentation. More on stackoverflow.com
🌐 stackoverflow.com
Using a source swagger.json Url directly from URL parameter
Unless I'm mistaken, I haven't found a way to create a URL that would encapsulate a target swagger.json. I think it would be useful to have this possibility: one could point people directly to an A... More on github.com
🌐 github.com
2
November 2, 2015
Customize Swagger UI and JSON URLs using Swashbuckle and .NET CORE 3.1 - Stack Overflow
NET Core 3.1 Web application with Swashbuckle.AspNetCore for swagger. I want to have a custom name added to both my swagger UI URL and swagger JSON URL. We have a proxy which redirects to different... More on stackoverflow.com
🌐 stackoverflow.com
spring mvc - How to generate swagger.json - Stack Overflow
I am using java spring boot framework to create REST api for my project and I am using "springfox-swagger2 and springfox-swagger-ui" for generating swagger documentation. I am able to see my documentation using the URL http://localhost:8080/swagger-ui.html. How can I create or generate swagger.json ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
FastAPI
fastapi.tiangolo.com › how-to › configure-swagger-ui
Configure Swagger UI - FastAPI
This is normally done automatically by FastAPI using the default URL `/openapi.json`. Read more about it in the [FastAPI docs for Conditional OpenAPI](https://fastapi.tiangolo.com/how-to/conditional-openapi/#conditional-openapi-from-settings-and-env-vars) """ ), ], title: Annotated[ str, Doc( """ The HTML `<title>` content, normally shown in the browser tab. Read more about it in the [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) """ ), ], swagger_js_url: Annotated[ str, Doc( """ The URL to use to load the Swagger UI JavaScript.
Top answer
1 of 3
2

The sample provided in the question cannot work at all (missing coma and spec is not a SwaggerUI property).

To show your swagger.json file which is in the same folder as index.html you just need to replace url = "http://petstore.swagger.io/v2/swagger.json" by url = "swagger.json"; in index.html.

Original index.html

      var url = window.location.search.match(/url=([^&]+)/);
      if (url && url.length > 1) {
        url = decodeURIComponent(url[1]);
      } else {
        url = "http://petstore.swagger.io/v2/swagger.json";
      }

      [...]

      window.swaggerUi = new SwaggerUi({
        url: url,
        dom_id: "swagger-ui-container",
        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
        onComplete: function(swaggerApi, swaggerUi){
          if(typeof initOAuth == "function") {
            initOAuth({
              clientId: "your-client-id",
              clientSecret: "your-client-secret-if-required",
              realm: "your-realms",
              appName: "your-app-name",
              scopeSeparator: ",",
              additionalQueryStringParams: {}
            });
          }

Modified:

      var url = window.location.search.match(/url=([^&]+)/);
      if (url && url.length > 1) {
        url = decodeURIComponent(url[1]);
      } else {
        url = "swagger.json";
      }

      [...]

      window.swaggerUi = new SwaggerUi({
        url: url,
        dom_id: "swagger-ui-container",
        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
        onComplete: function(swaggerApi, swaggerUi){
          if(typeof initOAuth == "function") {
            initOAuth({
              clientId: "your-client-id",
              clientSecret: "your-client-secret-if-required",
              realm: "your-realms",
              appName: "your-app-name",
              scopeSeparator: ",",
              additionalQueryStringParams: {}
            });
          }
2 of 3
2

Here was a solution I found here (pretty quick and painless if you have node installed):

  1. With Node, globally install package http-server npm install -g http-server

  2. Change directories to where json is located, and run the command http-server --cors (CORS has to be enabled for this to work)

  3. Open swagger ui (i.e. dist/index.html)

  4. Type http://localhost:8080/my.json in input field and click "Explore"

🌐
Swagger
swagger.io › docs › open-source-tools › swagger-ui › usage › installation
Installation | Swagger Docs
docker run -p 80:8080 -e SWAGGER_JSON_URL=https://petstore3.swagger.io/api/v3/openapi.json docker.swagger.io/swaggerapi/swagger-ui
🌐
Microsoft Learn
learn.microsoft.com › en-us › aspnet › core › tutorials › getting-started-with-swashbuckle
Get started with Swashbuckle and ASP.NET Core | Microsoft Learn
If using directories with IIS or a reverse proxy, set the Swagger endpoint to a relative path using the ./ prefix. For example, ./swagger/v1/swagger.json. Using /swagger/v1/swagger.json instructs the app to look for the JSON file at the true ...
🌐
Google Groups
groups.google.com › g › swagger-swaggersocket › c › RkfkrRFRnNA
How to view local JSON file in Swagger UI
The first being simply cloning the UI repo and placing my JSON file in the dist folder, then opening dist/index.html in a browser and searching for my file through the UI by searching "../my_swagger.json".
Find elsewhere
🌐
I'd Rather Be Writing
idratherbewriting.com › learnapidoc › pubapis_swagger.html
Swagger UI tutorial | I'd Rather Be Writing Blog and API doc course
14 hours ago - In the Example Value field, change the first id value to a random integer, such as 193844. Change the second name value to something you’d recognize (your pet’s name). Click Execute. ... Swagger UI submits the request and shows the curl that was submitted. The Responses section shows the response. (If you select JSON rather than XML in the “Response content type” drop-down box, the response’s format will be shown in JSON.)
🌐
Tibco
docs.tibco.com › pub › mdm › 9.2.0 › doc › html › GUID-E104EC0C-C433-48D5-A22F-7061E4BD1409.html
Generating a Swagger JSON File
On the Swagger UI, click the http://mdmhost:port/rest/v2/api-docs link to generate a Swagger.json file.
🌐
Swagger
editor.swagger.io
SwaggerEditor
You need to enable JavaScript to run this app · 5.3.6
🌐
Medium
medium.com › @vamsidogiparthi › learn-how-to-host-swagger-ui-and-swagger-json-to-custom-endpoint-06dc5c232104
Learn how to host Swagger UI and Swagger JSON to custom endpoint | by Vamsi Dogiparthi | Medium
July 8, 2024 - // an web application middleware method to allow you // to use the nSwag open api generated swagger json document // default hosting local url: http://localhost:{portnumber}/swagger/v1/swagger.json app.UseOpenApi((settings) => { settings.Path ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › aspnet › core › tutorials › web-api-help-pages-using-swagger
ASP.NET Core web API documentation with Swagger / OpenAPI | Microsoft Learn
February 23, 2026 - For example, OpenAPIGenerator and SwaggerUI. The OpenAPI specification is a document that describes the capabilities of your API. The document is based on the XML and attribute annotations within the controllers and models. It's the core part of the OpenAPI flow and is used to drive tooling such as SwaggerUI. By default, it's named openapi.json.
🌐
GitHub
github.com › swagger-api › swagger-ui › issues › 1719
Using a source swagger.json Url directly from URL parameter · Issue #1719 · swagger-api/swagger-ui
November 2, 2015 - Unless I'm mistaken, I haven't found a way to create a URL that would encapsulate a target swagger.json. I think it would be useful to have this possibility: one could point people directly to an API documentation page. (ex. http://petstore.swagger.io/target/http://myrestapi/) Right now I encapsulate the swagger-ui project in each of my project, but I think I'd be better off setting up a web instance of swagger-ui and let people use this instance to query my project's swagger.json.
Author   nodje
🌐
Swagger
swagger.io › docs › specification › v2_0 › basic-structure
Basic Structure | Swagger Docs
All API paths are relative to the base URL. For example, /users actually means https://api.example.com/v1/users.
🌐
Apidog
apidog.com › blog › swagger-ui-url
How to Change Swagger UI URL Defauth Path
February 5, 2026 - This will result in your Swagger UI URL. For example, if you are hosting your API at http://localhost:3000 and your swagger endpoint is /swagger-ui/, then your Swagger url will become http://localhost:8080/swagger-ui/.
🌐
Swagger
swagger.io › tools › swagger-ui
REST API Documentation Tool | Swagger UI
Swagger UI allows development team to visualize and interact with the API’s resources without having any of the implementation logic in place. Learn more.
Top answer
1 of 3
1
Generally speaking, swagger-core generates the API definition at runtime (just like another API endpoint). It's a bit unclear from your description how your application works. so: If your UI is intended to run alongside the API, you can simply point the UI to the generated definition at runtime. That way it's always up to date and there's no issue. If you need the UI to be completely independent from the application, you can use the maven plugin we have to generate the definition at build time and put it wherever you need. More information can be found at https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-maven-plugin.
2 of 3
0
Thank you for replying RonRatovsky  I would like to point the UI to the generated definition at runtime but i get a "Failed to Load spec". This may be because to access the definition, there must be some authentication and custom header added. I am using a url like this on index.html      window.onload = function() { // Build a system const ui = SwaggerUIBundle({ url: "https://localhost:8443/example.swagger.io/api/v1/swagger.json?Platform-TenantId=default&&Authorization=Basic bWlmb3M6cGFzc3dvcmQ=", dom_id: '#swagger-ui', validatorUrl : false, presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl ], layout: "StandaloneLayout" })   Also the try it out buttons on the swagger ui do not function when i use the path url to the locally saved swagger spec. I think it may be due to the authentication and header to be added on every request inorder to access to the server.  How can i resolve this please?
🌐
Quarkus
quarkus.io › guides › openapi-swaggerui
Using OpenAPI and Swagger UI - Quarkus
An OpenAPI document that conforms to the OpenAPI Specification is itself a valid JSON object, that can be represented in yaml or json formats. To see this in action, we’ll put OpenAPI documentation under META-INF/openapi.yaml for our /fruits endpoints. Quarkus also supports alternative OpenAPI document paths if you prefer. openapi: 3.1.0 info: title: Static OpenAPI document of fruits resource description: Fruit resources Open API documentation version: "1.0" servers: - url: http://localhost:8080/q/openapi description: Optional dev mode server description paths: /fruits: get: responses: 200: