<commit_before>const ExtensionBase = require('./../ExtensionBase');
const swagger = require('restify-swagger-jsdoc');

/**
 * Add Swagger explorer to API
 * 
 * @class AddSwaggerDocsExtension
 * @extends {ExtensionBase}
 */
class AddSwaggerDocsExtension extends ExtensionBase {

  /**
   * Activate the swagger UI
   * @param {any} config Configuration Settings
   * @returns 
   * @memberof AddSwaggerDocsExtension
   */
  execute(config) {
    //Get package.json
    var packageJSON = require(`${this.serverPath}/../package.json`);
    var config = {
      title: `${packageJSON.description} (${this.settings.env})`, // Page title (required) 
      version: packageJSON.version, // Server version (required) 
      server: this.server, // Restify server instance created with restify.createServer() 
      path: '/docs/swagger', // Public url where the swagger page will be available 
      apis: [`${this.settings.endpointsPath}/**/*.js`], // Path to the API docs 
      forceSecure: (this.settings.env == "DEV" ? false : true) // force swagger-ui to use https protocol to load JSON file (optional, default: false) 
    };
    //https://github.com/Surnet/swagger-jsdoc/blob/master/docs/GETTING-STARTED.md
    swagger.createSwaggerPage(config);

    // Register Manifiest Extension , maybe for later use
    this.registerUse("swagger-docs", config);

    return config;
  };

}

module.exports = AddSwaggerDocsExtension;
<commit_msg>FIX: is added support to configure swagger extension when api url has a base path<commit_after>const ExtensionBase = require('./../ExtensionBase');
const swagger = require('restify-swagger-jsdoc');

/**
 * Add Swagger explorer to API
 * 
 * @class AddSwaggerDocsExtension
 * @extends {ExtensionBase}
 */
class AddSwaggerDocsExtension extends ExtensionBase {

  /**
   * Activate the swagger UI
   * @param {any} config Configuration Settings
   * @returns 
   * @memberof AddSwaggerDocsExtension
   */
  execute(config) {
    //Get package.json
    var packageJSON = require(`${this.serverPath}/../package.json`);
    var config = {
      title: `${packageJSON.description} (${this.settings.env})`, // Page title (required) 
      version: packageJSON.version, // Server version (required) 
      server: this.server, // Restify server instance created with restify.createServer() 
      path: config.path || '/docs/swagger', // Public url where the swagger page will be available
      apis: [`${this.settings.endpointsPath}/**/*.js`], // Path to the API docs
      forceSecure: (this.settings.env == "DEV" ? false : true), // force swagger-ui to use https protocol to load JSON file (optional, default: false)
      routePrefix: config.routePrefix || '', // route prefix to use in swagger http client
    };
    //https://github.com/Surnet/swagger-jsdoc/blob/master/docs/GETTING-STARTED.md
    swagger.createSwaggerPage(config);

    // Register Manifiest Extension , maybe for later use
    this.registerUse("swagger-docs", config);

    return config;
  };

}

module.exports = AddSwaggerDocsExtension;

{'fraction_non_alphanumeric': 0.1301775147928994, 'fraction_numerical': 0.0, 'mean_word_length': 3.4553440702781844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2259544', 'n_tokens_mistral': 889, 'n_tokens_neox': 867, 'n_words': 243}