Blame view

node_modules/swagger-client/lib/helpers.js 1.09 KB
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  'use strict';
  
  var _ = {
    isPlainObject: require('lodash-compat/lang/isPlainObject'),
    indexOf: require('lodash-compat/array/indexOf')
  };
  
  module.exports.__bind = function (fn, me) {
    return function(){
      return fn.apply(me, arguments);
    };
  };
  
  var log = module.exports.log = function() {
    // Only log if available and we're not testing
    if (console && process.env.NODE_ENV !== 'test') {
      console.log(Array.prototype.slice.call(arguments)[0]);
    }
  };
  
  module.exports.fail = function (message) {
    log(message);
  };
  
  var optionHtml = module.exports.optionHtml = function (label, value) {
    return '<tr><td class="optionName">' + label + ':</td><td>' + value + '</td></tr>';
  };
  
  var resolveSchema = module.exports.resolveSchema = function (schema) {
    if (_.isPlainObject(schema.schema)) {
      schema = resolveSchema(schema.schema);
    }
  
    return schema;
  };
  
  var simpleRef = module.exports.simpleRef = function (name) {
    if (typeof name === 'undefined') {
      return null;
    }
  
    if (name.indexOf('#/definitions/') === 0) {
      return name.substring('#/definitions/'.length);
    } else {
      return name;
    }
  };