How to get Topbar to work with Swagger UI multiple urls configuration

2,697 views
Skip to first unread message

Bob V

unread,
Feb 22, 2018, 3:10:10 PM2/22/18
to Swagger
Hi
I've pulled the latest Swagger-UI, dated Feb 19, 2018. I want to use the 'urls:' and 'urls.primaryName' configuration option. After building with docker and loading the page into the browser I get an error 'Could not find component Topbar'. I'm trying to have my Swagger UI be able to offer multiple APIs. The only thing I've changed is the dist/index.html as seen below. I thought that Topbar should be enabled and loaded automatically,  How do I get past this error?
Thanks
Bob

> git diff dist/index.html
diff --git a/dist/index.html b/dist/index.html
index 0de47c6..0ac200c 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -74,7 +74,12 @@ window.onload = function() {
   
   // Build a system
   const ui = SwaggerUIBundle({
+       //url: "http://localhost:8080/api/rest",
+    urls: [ 
+               { url: "http://petstore.swagger.io/v2/swagger.json", name: "pets" },
+               { url: "http://localhost:8080/api/rest", name: "myapi" }
+    ],
+    "urls.primaryName": "pets",
     dom_id: '#swagger-ui',
     deepLinking: true,
     presets: [

index.html

Bob V

unread,
Feb 22, 2018, 3:33:30 PM2/22/18
to Swagger
Now I see that if I point my browser the dist/index.html I get the pull down for my APIs. Why doesn't this work when built and run as a docker image?

Bob V

unread,
Feb 26, 2018, 11:09:52 AM2/26/18
to Swagger
Had to update the swagger ui js packages to the most recent and it works.


On Thursday, February 22, 2018 at 3:10:10 PM UTC-5, Bob V wrote:
Reply all
Reply to author
Forward
0 new messages