In the Swagger tutorial, you explored the Swagger Petstore site, learned how the Swagger Editor works, and how to download and integrate your OpenAPI specification document into Swagger UI. Now it’s time to put this learning into practice by integrating the specification document into your own Swagger UI site.
Open the index.html file in the folder and update the reference to swagger.json to your own specification document.
A local web server simulates a web server on your local machine. To run a simple Python web server in the directory, you can follow use this simple HTTP server.
Python -V. If you don’t have Python, download and install it.
cdinto the same directory as your Swagger UI project.
Do one of the following:
If you have Python 2.x, run the following command:
python -m SimpleHTTPServer 7800
If you have Python 3.x, run the following command:
python -m http.server 7800
Open a browser (such as Chrome), and go to
http://localhost:7800/. The web server serves up the index.html file in that directory by default. You should see your Swagger UI project load the spedification document.
Make a request with the Swagger UI display to make sure it’s working. If you’re using the Sunset and sunrise times API example, you can use these values for latitude and longitude:
Get new posts delivered straight to your inbox.
© 2017, Tom Johnson