online/src/js/parser.js
function parseSwagger () {
  try {
    // Clear any previous results
    editors.clearResults();

    // Get all the parameters
    swaggerParser = swaggerParser || new SwaggerParser();
    var options = form.getOptions();
    var method = form.method.button.val();
    var api = form.getAPI();

    // Call Swagger Parser
    swaggerParser[method](api, options)
      .then(function () {
        // Show the results
        var results = swaggerParser.$refs.values();
        Object.keys(results).forEach(function (key) {
          editors.showResult(key, results[key]);
        });
      })
      .catch(function (err) {
        editors.showError(ono(err));
        analytics.trackError(err);
      });

    // Track the operation
    counters[method]++;
    analytics.trackEvent("button", "click", method, counters[method]);
  }
  catch (err) {
    editors.showError(ono(err));
    analytics.trackError(err);
  }
}
function parseSwagger () {
  try {
    // Clear any previous results
    editors.clearResults();

    // Get all the parameters
    swaggerParser = swaggerParser || new SwaggerParser();
    var options = form.getOptions();
    var method = form.method.button.val();
    var api = form.getAPI();

    // Call Swagger Parser
    swaggerParser[method](api, options)
      .then(function () {
        // Show the results
        var results = swaggerParser.$refs.values();
        Object.keys(results).forEach(function (key) {
          editors.showResult(key, results[key]);
        });
      })
      .catch(function (err) {
        editors.showError(ono(err));
        analytics.trackError(err);
      });

    // Track the operation
    counters[method]++;
    analytics.trackEvent("button", "click", method, counters[method]);
  }
  catch (err) {
    editors.showError(ono(err));
    analytics.trackError(err);
  }
}
function parseSwagger ( ) { try { // Clear any previous results editors . clearResults ( ) ; // Get all the parameters swaggerParser = swaggerParser || new SwaggerParser ( ) ; var options = form . getOptions ( ) ; var method = form . method . button . val ( ) ; var api = form . getAPI ( ) ; // Call Swagger Parser swaggerParser [ method ] ( api , options ) . then ( function ( ) { // Show the results var results = swaggerParser . $refs . values ( ) ; Object . keys ( results ) . forEach ( function ( key ) { editors . showResult ( key , results [ key ] ) ; } ) ; } ) . catch ( function ( err ) { editors . showError ( ono ( err ) ) ; analytics . trackError ( err ) ; } ) ; // Track the operation counters [ method ] ++ ; analytics . trackEvent ( "button" , "click" , method , counters [ method ] ) ; } catch ( err ) { editors . showError ( ono ( err ) ) ; analytics . trackError ( err ) ; } }
This function is called when the "Validate it!" button is clicked.
It calls Swagger Parser, passing it all the options selected on the form.
This function is called when the Validate it! button is clicked . It calls Swagger Parser passing it all the options selected on the form .