lib/index.js
function (plugin, settings) {

    plugin.ext('onPostHandler', (request, reply) => {

        let response = request.response;
        // if the reply is a view add settings data into template system
        if (response.variety === 'view') {

            // Added to fix bug that cannot yet be reproduced in test - REVIEW
            /* $lab:coverage:off$ */
            if (!response.source.context) {
                response.source.context = {};
            }
            /* $lab:coverage:on$ */

            // append tags from document request to JSON request
            if (request.query.tags) {
                settings.jsonPath = appendQueryString(settings.jsonPath, 'tags', request.query.tags);
            } else {
                settings.jsonPath = appendQueryString(settings.jsonPath, null, null);
            }

            const prefixedSettings = Hoek.clone(settings);
            if (plugin.realm.modifiers.route.prefix) {
                ['jsonPath', 'swaggerUIPath'].forEach((setting) => {
                    prefixedSettings[setting] = plugin.realm.modifiers.route.prefix + prefixedSettings[setting];
                });
            }
            const prefix = findAPIKeyPrefix(settings);
            if (prefix) {
                prefixedSettings.keyPrefix = prefix;
            }
            prefixedSettings.stringified = JSON.stringify(prefixedSettings);

            response.source.context.hapiSwagger = prefixedSettings;
        }
        return reply.continue();
    });
}
function (plugin, settings) {

    plugin.ext('onPostHandler', (request, reply) => {

        let response = request.response;
        // if the reply is a view add settings data into template system
        if (response.variety === 'view') {

            // Added to fix bug that cannot yet be reproduced in test - REVIEW
            /* $lab:coverage:off$ */
            if (!response.source.context) {
                response.source.context = {};
            }
            /* $lab:coverage:on$ */

            // append tags from document request to JSON request
            if (request.query.tags) {
                settings.jsonPath = appendQueryString(settings.jsonPath, 'tags', request.query.tags);
            } else {
                settings.jsonPath = appendQueryString(settings.jsonPath, null, null);
            }

            const prefixedSettings = Hoek.clone(settings);
            if (plugin.realm.modifiers.route.prefix) {
                ['jsonPath', 'swaggerUIPath'].forEach((setting) => {
                    prefixedSettings[setting] = plugin.realm.modifiers.route.prefix + prefixedSettings[setting];
                });
            }
            const prefix = findAPIKeyPrefix(settings);
            if (prefix) {
                prefixedSettings.keyPrefix = prefix;
            }
            prefixedSettings.stringified = JSON.stringify(prefixedSettings);

            response.source.context.hapiSwagger = prefixedSettings;
        }
        return reply.continue();
    });
}
function ( plugin , settings ) { plugin . ext ( 'onPostHandler' , ( request , reply ) => { let response = request . response ; // if the reply is a view add settings data into template system if ( response . variety === 'view' ) { // Added to fix bug that cannot yet be reproduced in test - REVIEW /* $lab:coverage:off$ */ if ( ! response . source . context ) { response . source . context = { } ; } /* $lab:coverage:on$ */ // append tags from document request to JSON request if ( request . query . tags ) { settings . jsonPath = appendQueryString ( settings . jsonPath , 'tags' , request . query . tags ) ; } else { settings . jsonPath = appendQueryString ( settings . jsonPath , null , null ) ; } const prefixedSettings = Hoek . clone ( settings ) ; if ( plugin . realm . modifiers . route . prefix ) { [ 'jsonPath' , 'swaggerUIPath' ] . forEach ( ( setting ) => { prefixedSettings [ setting ] = plugin . realm . modifiers . route . prefix + prefixedSettings [ setting ] ; } ) ; } const prefix = findAPIKeyPrefix ( settings ) ; if ( prefix ) { prefixedSettings . keyPrefix = prefix ; } prefixedSettings . stringified = JSON . stringify ( prefixedSettings ) ; response . source . context . hapiSwagger = prefixedSettings ; } return reply . continue ( ) ; } ) ; }
appends settings data in template context

@param  {Object} plugin
@param  {Object} settings
@return {Object}
appends settings data in template context