src/SwaggerParser.js   A
last analyzed

Size

Lines of Code 62

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
nc 1
dl 0
loc 62
rs 10
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A SwaggerParser.js ➔ ??? 0 7 1
1
const Parser20        = require('./2.0/Parser'),
2
      ParserInterface = require('./ParserInterface')
3
4
/**
5
 * @ignore Parser20
6
 */
7
8
/**
9
 * Parser for swagger data
10
 *
11
 * @class SwaggerParser
12
 * @property {String} type Swagger type (2.0 only supported)
13
 * @property {Swagger20} data Swagger data (from json or yaml)
14
 * @property {Parser} parser Swagger parse object
15
 */
16
class SwaggerParser extends ParserInterface {
17
18
  /**
19
   * SwaggerParser constructor
20
   *
21
   * @param {String} type Swagger type (2.0 only supported)
22
   * @param {Swagger20} data Swagger data (from json or yaml)
23
   * @param {ParserOptions} parserOptions Parser options
24
   */
25
  constructor (type, data, parserOptions) {
26
    super()
27
28
    this.type   = type || '2.0'
29
    this.data   = data
30
    this.parser = this._getParser(parserOptions)
31
  }
32
33
  /**
34
   * Get swagger parser object
35
   *
36
   * @param {ParserOptions} parserOptions Parser options
37
   *
38
   * return {ParserInterface}
39
   * @private
40
   */
41
  _getParser (parserOptions) {
42
    switch (this.type) {
0 ignored issues
show
Unused Code introduced by
You have a switch statement with only a default case. This statement can be turned into a normal statement.
Loading history...
43
      default:
44
        return new Parser20(this.data, parserOptions)
45
    }
46
  }
47
48
  /**
49
   * Parse swagger data
50
   *
51
   * @return {Swagger20}
52
   */
53
  parse () {
54
    return this.parser.parse()
55
  }
56
}
57
58
/**
59
 * @ignore module.exports
60
 * @ignore exports
61
 */
62
module.exports = SwaggerParser