1

I have a basic webpage built, and a Swagger document JSON file of my API. I am unsure of how to actually add the data from the document to the website so that it can be browsed.

I want to build hosted documentation for the API.

This is the example given by Swagger: http://petstore.swagger.wordnik.com/#!/pet/addPet

Do I just download Swagger UI and use it in conjunction with the JSON file.

But I am unsure on to achieve this. Any advice on how to go about creating something like this would be very helpful.

1 Answer 1

1

Swagger-ui is basically a set of static files you can host on your server to display your API.

Unless you may any major changes, you just need to copy the contents of the /dist folder to your server and host it as part of your application (or static website, doesn't matter).

The SwaggerUi object can be customized to your needs, including the URL of the spec you're hosting.

Keep in mind that if you don't host the ui and spec on the same server, (that is, same host and same port), you need to enable CORS.

Sign up to request clarification or add additional context in comments.

1 Comment

3 years have gone by, and I find your answer very helpful. Thank you, sir.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.