outmoded/lout

How to include headers in documentation

Closed this issue · 2 comments

My application has some custom required headers, I would like to include them in the documentation /docs.

Here's the code:

const Hapi = require('hapi');
const Joi = require('joi');

const startServer = async () => {

    try {

        const server = Hapi.server({ port: 8088 });

        await server.register([require('vision'), require('inert'), require('lout')]);

        server.route({
            method: 'GET',
            path: '/hello',
            handler: () => 'hello',
            options: {
                validate: {
                    query: {
                        foo: Joi.any().valid('bar','foo').required(),
                    },
                    headers: Joi.object({
                        'x-request-id': Joi.string().guid().required(),
                    }).options({ allowUnknown: true })
                }
            }
        });

        await server.start();

        console.log('Server running at:', server.info.uri);
    }
    catch (err) {
        console.error(err);
        process.exit(1);
    }
};

startServer();

curl command:

$ curl ".:8088/hello?foo=bar" -H "x-request-id:452842F4-D331-45BC-9532-EC05D1F3F108"
hello%

but documentation doesn't list anything about the headers:
screen shot 2018-07-02 at 11 31 06 pm

It's just something nobody ever asked. Added support for it in the latest version.

Thanks!