Hosting Swagger Editor in own domain

161 views
Skip to first unread message

neophyt...@gmail.com

unread,
Sep 30, 2016, 8:48:56 PM9/30/16
to Swagger
Hi All- I was just introduced to swagger yesterday, and was trying to figure out how to host the swagger editor in my own domain to test out some post requests. I eventually got the swagger editor files to be served (using flask, testing locally), but only with some tinkering with the bundle.js file. (so not satisfied with that approach)

What I did:
- I downloaded the latest release (v2.10.3) from github
- Dropped the swagger-editor folder into an existing web applications static folder
- Initially I tried a Flask route decorator to send_static_file ("swagger-editor/index.html"), but had some issues with a Request URL with *worker.js so I stopped tinkering with the Flask decorator

- Decided to access the file directly via http://localhost:8000/static/swagger-editor/index.html
- At this point a handful of files were served, but received a 404 on defaults.json and noticed that the Request URL was: http://localhost:8000/static/swagger-editor/index.html/config/defaults.json
- Couldn't find where this was configured, so I just searched the bundle.js file for defaults.json
- Saw: s=a+"config/defaults.json" and edited to be: s="http://localhost:8000/static/swagger-editor/config/defaults.json"
- Refreshed browser and swagger-editor was online!

I'm guessing that editing the bundle.js probably isn't the preferred/correct method, can someone advise me on how I could have resolved the issue with defaults.json?
You might be wondering why I didn't pull the project and build- I tried pulling the project down to one of our linux servers, but had issues with the build (something about ERROR in Use of const in strict mode (?possibly due to old node package, but didn't want to investigate that at the moment)

Directory structure:
webapp
-src
-static
|-swagger-editor
||-config
||-dist
||-images
||-...
||-index.html
-web.py

tony tam

unread,
Sep 30, 2016, 8:55:04 PM9/30/16
to swagger-sw...@googlegroups.com
The fastest way to do this is to use the public docker image.  It’s just one step to run it:


--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

neophyt...@gmail.com

unread,
Sep 30, 2016, 11:00:55 PM9/30/16
to Swagger
Hi Tony-

Not sure if that answers the question I had? I did get it running, but wasn't sure about my method.

I don't have much experience with docker, but if I were to run the docker image wouldn't I still be dealing with CORS when I submitted post requests (for testing) from the editor? I'd like to avoid this...

Alan


To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages