# Swagger path to access directly from browser

**URL:** <https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197>\
**Category:** General\
**Created:** [3 February 2020 14:02 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197 "2020-02-03T14:02:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [3 February 2020 14:02 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/1 "2020-02-03T14:02:46Z")

</div>

Hello,

I use Node-RED version 1.0.3 and Node.js version 10.18.1  
I installed node-red-node-swagger and all is OK.

But, I don`t know what to do to access swagger , directly from browser , like [http://localhost:1880/swagger-docs/](http://localhost:1880/swagger-docs/)  
I need a clean page, only with swagger.

I tried various changes to the "basePath":"/" in settings.js, without success, I'm sure I'm wrong somewhere.

NodeRed is running on Windows 10.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [3 February 2020 15:27 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/2 "2020-02-03T15:27:31Z")

</div>

Have you followed the instructions for setting up this node from the Readme?

> **[node-red-node-swagger](https://flows.nodered.org/node/node-red-node-swagger)**
>
> A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow

  
Take a look at step 5: "The generated swagger is then available at [http://localhost:1880/http-api/swagger.json](http://localhost:1880/http-api/swagger.json) ."

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [3 February 2020 17:36 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/3 "2020-02-03T17:36:32Z")

</div>

I don`t need json file.

I searching for something like this : [https://petstore.swagger.io/?\_ga=2.252125578.2084557169.1580751320-1190130577.1580751320](https://petstore.swagger.io/?_ga=2.252125578.2084557169.1580751320-1190130577.1580751320)

But with local link , like : [http://localhost:1880/swagger-docs/](http://localhost:1880/swagger-docs/)

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [3 February 2020 18:16 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/4 "2020-02-03T18:16:43Z")

</div>

Have you checked the Readme yet? If you scroll further down it says that the UI (which I assume you’re looking for) is added as sidebar panel. So start looking there.

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [3 February 2020 18:49 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/5 "2020-02-03T18:49:56Z")

</div>

I probably can't explain it very well, especially since I'm not a native English speaker.  
I know that the UI is accessible laterally. What I need is a direct link to the swegger interface. As a separate external link, with no connection to the nodered.

For example, you can access the DashBoard with a direct link, such as [http://127.0.0.1:1880/ui/#!/0](http://127.0.0.1:1880/ui/#!/0). Thus, I only have access to the dashboard.

Basically, I need a link with direct access only for the Swagger UI

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [3 February 2020 19:04 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/6 "2020-02-03T19:04:12Z")

</div>

Okay, I understand what you mean. I'm not using swagger myself, but I've utilised this interface for published APIs myself before. Looking through the code of the node, take a look at [http://localhost:1880/swagger-ui/swagger-ui.html](http://localhost:1880/swagger-ui/swagger-ui.html) and see if that does the trick. That page is loaded inside an iframe in the sidebar. If that doesn't give the result you're looking for, I'm afraid there's no ready solution. This is what the capabilities of this node are limited to.

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [4 February 2020 11:55 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/7 "2020-02-04T11:55:01Z")

</div>

Unfortunately it doesn't work ...

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [4 February 2020 13:12 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/8 "2020-02-04T13:12:27Z")

</div>

In that case I see one more option beyond trying a different node (having no clue if that node would exist): put an http endpoint yourself, method GET. Add a template node, followed by HTTP response. In that template node replicate the way the sidebar swagger UI is set up. Then use that endpoint for your needs.

> <https://github.com/node-red/node-red-node-swagger/blob/fe011e63bb20ed5a6420a3f6b912c7625e0be238/swagger/swagger.html#L117-L145>

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [4 February 2020 13:15 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/9 "2020-02-04T13:15:08Z")

</div>

> [@softy2k](#):
>
> For example, you can access the DashBoard with a direct link, such as [http://127.0.0.1:1880/ui/#!/0](http://127.0.0.1:1880/ui/#!/0).

If the internal ip address works for the dashboard ui, then it should work for swagger as well... try  
[http://127.0.0.1:1880/swagger-ui/](http://127.0.0.1:1880/swagger-ui/)

instead of using localhost (but it's odd that localhost does not work for you) -- are you sure your are running a browser on the same hardware that node-red is running?

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [4 February 2020 13:18 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/10 "2020-02-04T13:18:22Z")

</div>

Steve, looking at the code I’m seeing now that it might be caused by the iframe looking for `parent.swaggerDocUrl` to decide how to load it, which is a variable created inside the onPaletteAdd function. Sounds to me that with a bit of a template node it can be set up to use that instead...

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [4 February 2020 13:54 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/11 "2020-02-04T13:54:54Z")

</div>

[http://127.0.0.1:1880/swagger-ui/](http://127.0.0.1:1880/swagger-ui/)  
or  
[http://localhost:1880/swagger-ui/](http://localhost:1880/swagger-ui/)

Both links respond with me "Cannot GET /swagger-ui/"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 April 2020 13:54 UTC](https://discourse.nodered.org/t/swagger-path-to-access-directly-from-browser/21197/12 "2020-04-04T13:54:55Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
