Hi @z0mt3c, I'm trying to configure hapi-swaggered but I'm not able to display the authenticate button. Do you have a working example using the authorization option? Even with your example code, the configuration seems to be useless.
const Hapi = require('hapi');
const Joi = require('joi');
const server = Hapi.Server({ port: 8000 });
(async () => {
await server.register([
require('inert'),
require('vision'),
{
plugin: require('hapi-swaggered'),
options: {
tags: {
'foobar/test': 'Example foobar description',
},
info: {
title: 'Example API',
description: 'Desc...',
version: '1.0',
},
},
},
{
plugin: require('hapi-swaggered-ui'),
options: {
title: 'Example API',
path: '/docs',
authorization: {
field: 'apiKey',
scope: 'query', // header works as well
// valuePrefix: 'bearer', // prefix incase
defaultValue: 'demoKey',
placeholder: 'Enter your apiKey here',
},
swaggerOptions: {
validatorUrl: null,
},
},
},
]);
server.route({
path: '/',
method: 'GET',
async handler(request, h) {
return await h.redirect('/docs');
},
});
server.route({
path: '/foobar/test',
method: 'GET',
options: {
tags: ['api'],
description: 'My route description',
notes: 'My route notes',
handler() {
return {};
},
},
});
server.route({
path: '/foobar/{foo}/{bar}',
method: 'GET',
options: {
tags: ['api'],
validate: {
params: {
foo: Joi.string()
.required()
.description('test'),
bar: Joi.string().required(),
},
},
handler() {
return {};
},
},
});
try {
await server.start();
console.log('started on http://localhost:8000');
} catch (err) {
console.error(err);
}
})();
Result:

Thanks,
Samy
Hi @z0mt3c, I'm trying to configure hapi-swaggered but I'm not able to display the authenticate button. Do you have a working example using the
authorizationoption? Even with your example code, the configuration seems to be useless.Result:

Thanks,
Samy