<commit_before>var colors = require('colors');
var inquirer = require('inquirer');
var fs = require('fs');
var crypto = require('crypto');
var YAML = require('json2yaml');
var utils = require('../utils');

exports.swagger = false;
exports.login = false;
exports.category = "basic";
exports.desc = "Create a new API specification";

var types = [
  { "name": "application/json", "checked": true },
  { "name": "application/xml" },
  { "name": "application/x-www-form-urlencoded" },
  { "name": "multipart/form-data" },
];

exports.run = function(config, info) {

  console.log("This will help you set up an 'Open API' (formerly 'Swagger') spec in your");
  console.log("repo, so you can start documenting your API!");

  console.log("");

  var questions = [
    {
      type: 'input',
      name: 'info.title',
      message: 'Name of the API',
      default: process.cwd().split('/').slice(-1)[0],
    },
    {
      type: 'input',
      name: 'info.version',
      message: 'Version number',
      default: '1.0.0',
    },
    {
      type: 'input',
      name: 'info.license',
      message: 'License',
    },
    {
      type: 'input',
      name: 'url',
      message: 'Full Base URL',
      validate: function (value) {
        var pass = /^(http|https|ws|wss):\/\/[^ "]+$/.test(value);

        if (pass) {
          return true;
        }

        return 'Please enter a valid URL, including protocol';
      }
    },
    {
      type: 'checkbox',
      name: 'consumes',
      message: 'Consumes content types',
      choices: types,
    },
    {
      type: 'checkbox',
      name: 'produces',
      message: 'Produces content types',
      choices: types,
    },
    {
      type: 'input',
      name: 'output',
      message: 'Output JSON or YAML file',
      default: getDefaultSwagger(),
      choices: types,
      validate: function (value) {
        var pass = /.(json|yaml|yml)$/.test(value);
        var doesntExist = !utils.fileExists(value);

        if (pass && doesntExist) {
          return true;
        }

        if(!pass) {
          return 'Your file must end with .json or .yaml';
        }
        if(!doesntExist) {
          return 'This file already exists';
        }
      }
    }
  ];

  inquirer.prompt(questions).then(function (answers) {
    var swagger = {
      'swagger': '2.0',
      'x-api-id': crypto.randomBytes(15).toString('hex'),
      'info': {
        'version': answers['info.version'],
        'title': answers['info.title'],
      },
    };

    if(answers['info.license']) {
      swagger.info.license = {
        'name': answers['info.license']
      };
    }<commit_msg>Include an empty paths so it validates<commit_after>var colors = require('colors');
var inquirer = require('inquirer');
var fs = require('fs');
var crypto = require('crypto');
var YAML = require('json2yaml');
var utils = require('../utils');

exports.swagger = false;
exports.login = false;
exports.category = "basic";
exports.desc = "Create a new API specification";

var types = [
  { "name": "application/json", "checked": true },
  { "name": "application/xml" },
  { "name": "application/x-www-form-urlencoded" },
  { "name": "multipart/form-data" },
];

exports.run = function(config, info) {

  console.log("This will help you set up an 'Open API' (formerly 'Swagger') spec in your");
  console.log("repo, so you can start documenting your API!");

  console.log("");

  var questions = [
    {
      type: 'input',
      name: 'info.title',
      message: 'Name of the API',
      default: process.cwd().split('/').slice(-1)[0],
    },
    {
      type: 'input',
      name: 'info.version',
      message: 'Version number',
      default: '1.0.0',
    },
    {
      type: 'input',
      name: 'info.license',
      message: 'License',
    },
    {
      type: 'input',
      name: 'url',
      message: 'Full Base URL',
      validate: function (value) {
        var pass = /^(http|https|ws|wss):\/\/[^ "]+$/.test(value);

        if (pass) {
          return true;
        }

        return 'Please enter a valid URL, including protocol';
      }
    },
    {
      type: 'checkbox',
      name: 'consumes',
      message: 'Consumes content types',
      choices: types,
    },
    {
      type: 'checkbox',
      name: 'produces',
      message: 'Produces content types',
      choices: types,
    },
    {
      type: 'input',
      name: 'output',
      message: 'Output JSON or YAML file',
      default: getDefaultSwagger(),
      choices: types,
      validate: function (value) {
        var pass = /.(json|yaml|yml)$/.test(value);
        var doesntExist = !utils.fileExists(value);

        if (pass && doesntExist) {
          return true;
        }

        if(!pass) {
          return 'Your file must end with .json or .yaml';
        }
        if(!doesntExist) {
          return 'This file already exists';
        }
      }
    }
  ];

  inquirer.prompt(questions).then(function (answers) {
    var swagger = {
      'swagger': '2.0',
      'x-api-id': crypto.randomBytes(15).toString('hex'),
      'info': {
        'version': answers['info.version'],
        'title': answers['info.title'],
      },
      'paths': {},
    };

    if(answers['info.license']) {
      swagger.info.license = {
        'name': answers['info.license']
      };
    }
{'fraction_non_alphanumeric': 0.17050169747265184, 'fraction_numerical': 0.003772161448509996, 'mean_word_length': 2.2355094569859673, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '7264874', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1660, 'n_words': 415}