swagger-api / swagger-node

Swagger module for node.js
http://swagger.io
Apache License 2.0
3.97k stars 584 forks source link

How to open swagger documentation #515

Open MrEldin opened 7 years ago

MrEldin commented 7 years ago

Hi,

My question is, how to open swagger documentation, to show my frontend team the exact routes that they can use, I thought about this Documentation.

Thanks

joshualim92 commented 7 years ago

@MrEldin you'll need to add swagger-ui into your project. Either the static dist or via npm https://www.npmjs.com/package/swagger-ui

Afterwards just serve the static files from the api you're using. In hapi it'd look something like this:

    app.register(require('inert'), (err) => {
        if (err) {
            throw err;
        }

        app.route({
            method: 'GET',
            path: '/{param*}',
            handler: {
                directory: {
                    path: 'dist'
                }
            }
        });
    });
MrApe commented 7 years ago

You may also just run the docker container, provided by swagger-ui. See #524 for details.