下面是我用来启动服务器的胶水清单:
var Config = require('../config.json');
var internals = {
    manifest: {
        connections: [
        {
            host    : Config.host || process.env.IP,
            port    : Config.apiPort || process.env.PORT,
            labels  : ['api']
        }],
        plugins: {
            './decorate': [{ 'select': ['api']}],
            'hapi-auth-jwt': [{ 'select': ['api']}],
            './authentication': [{ 'select': ['api']}],
            './controllers': [{ 'select': ['api']}],
            './models': [{ 'select': ['api']}],
            './api': [{ 'select': ['api']}],
            good: {
                opsInterval: 5000,
                reporters: [
                    { 'reporter': 'good-console', 'events': { 'log': '*' } }
                ]
            }
        }
    }
};
if (!process.env.PRODUCTION) {
    internals.manifest.plugins['blipp'] = [{}];
    internals.manifest.plugins['good'].reporters[0].events['ops'] =  '*';
}
module.exports = internals.manifest;一旦我在插件列表中添加“hapi-swagger”,服务器就会停止响应./api文件中定义的路由。这些路线都不起作用。是把hapi-swagger添加到胶水清单的正确方式,还是我在做一些荒谬的事情?
编辑:下面是api.js
exports.register = function (plugin, options, next) {
    plugin.dependency('controllers');
    plugin.dependency('models');
    var Controllers = plugin.plugins.controllers.handlers;
    var Models = plugin.plugins.models.models;
    plugin.bind({
        models: Models
    });
    plugin.route([
        { method: 'GET',    path: '/token',             config: Controllers.Membership.token },
        { method: 'GET',    path: '/',                  config: Controllers.Home.status },
        { method: 'GET',    path: '/nodes',             config: Controllers.Node.search },
        { method: 'GET',    path: '/services',          config: Controllers.Node.services },
        { method: 'GET',    path: '/createnodetree',    config: Controllers.Loader.createNodeTree }
    ]);
    next();
};
exports.register.attributes = {
    name: 'api',
    version: require('../package.json').version
};发布于 2016-02-04 02:39:05
如果您尝试使用hapi-swagger而不包括文档视图依赖项或正确禁用文档支持,则会发生这种情况。来自文档
如果您想从API中查看文档,您还需要安装支持模板和静态内容服务的惰性和视觉插件。如果您只想使用没有文档的swagger.json,例如,swagger-codegen,只需将options.enableDocumentation设置为false。
您没有显示您是如何添加hapi-swagger插件的,但是您只需将'enableDocumentation': false添加到您定义的选项中。您可以在上面的链接中找到示例。
https://stackoverflow.com/questions/34394182
复制相似问题