joi-to-json 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,32 @@
1
- const BaseConverter = require('./v15')
2
-
3
- class JoiSpecConvertor extends BaseConverter {
4
- static getVersion(joiObj) {
5
- return joiObj.$_root.version
6
- }
7
-
8
- static getSupportVersion() {
9
- return '16'
10
- }
11
-
12
- // All methods are overridden because the Joi v16.1.8 spec is closed to the latest version
13
- _convertExamples(_joiObj) { }
14
-
15
- _convertObject(_joiObj) { }
16
-
17
- _convertDate(_joiObj) { }
18
-
19
- _convertAlternatives(_joiObj) { }
20
-
21
- _convertBinary(_joiObj) { }
22
-
23
- _convertString(_joiObj) { }
24
-
25
- _convertNumber(_joiObj) { }
26
-
27
- _convertBoolean(_joiObj) { }
28
-
29
- _convertArray(_joiObj) {}
30
- }
31
-
32
- module.exports = JoiSpecConvertor
1
+ const BaseConverter = require('./v15')
2
+
3
+ class JoiSpecConvertor extends BaseConverter {
4
+ static getVersion(joiObj) {
5
+ return joiObj.$_root.version
6
+ }
7
+
8
+ static getSupportVersion() {
9
+ return '16'
10
+ }
11
+
12
+ // All methods are overridden because the Joi v16.1.8 spec is closed to the latest version
13
+ _convertExamples(_joiObj) { }
14
+
15
+ _convertObject(_joiObj) { }
16
+
17
+ _convertDate(_joiObj) { }
18
+
19
+ _convertAlternatives(_joiObj) { }
20
+
21
+ _convertBinary(_joiObj) { }
22
+
23
+ _convertString(_joiObj) { }
24
+
25
+ _convertNumber(_joiObj) { }
26
+
27
+ _convertBoolean(_joiObj) { }
28
+
29
+ _convertArray(_joiObj) {}
30
+ }
31
+
32
+ module.exports = JoiSpecConvertor
@@ -1,74 +1,74 @@
1
- const _ = require('lodash')
2
- const JoiJsonSchemaParser = require('./json')
3
-
4
- class JoiJsonDraftSchemaParser extends JoiJsonSchemaParser {
5
- constructor(opts = {}) {
6
- super(_.merge({
7
- $schema: 'http://json-schema.org/draft-04/schema#',
8
- logicalOpParser: {
9
- xor: null,
10
- with: function (schema, dependency) {
11
- schema.dependencies = schema.dependencies || {}
12
- schema.dependencies[dependency.key] = dependency.peers
13
- },
14
- without: null
15
- }
16
- }, opts))
17
- }
18
-
19
- _isIfThenElseSupported() {
20
- return false
21
- }
22
-
23
- _setNumberFieldProperties(fieldSchema, fieldDefn) {
24
- super._setNumberFieldProperties(fieldSchema, fieldDefn)
25
-
26
- if (typeof fieldSchema.exclusiveMinimum !== 'undefined') {
27
- fieldSchema.minimum = fieldSchema.exclusiveMinimum
28
- fieldSchema.exclusiveMinimum = true
29
- }
30
- if (typeof fieldSchema.exclusiveMaximum !== 'undefined') {
31
- fieldSchema.maximum = fieldSchema.exclusiveMaximum
32
- fieldSchema.exclusiveMaximum = true
33
- }
34
-
35
- if (typeof fieldSchema.minimum !== 'undefined' && fieldSchema.minimum === fieldSchema.exclusiveMinimum) {
36
- fieldSchema.exclusiveMinimum = true
37
- }
38
- if (typeof fieldSchema.maximum !== 'undefined' && fieldSchema.maximum === fieldSchema.exclusiveMaximum) {
39
- fieldSchema.exclusiveMaximum = true
40
- }
41
- }
42
-
43
- _getLocalSchemaBasePath() {
44
- return '#/definitions'
45
- }
46
-
47
- _setArrayFieldProperties(fieldSchema, fieldDefn, definitions, level) {
48
- super._setArrayFieldProperties(fieldSchema, fieldDefn, definitions, level)
49
-
50
- delete fieldSchema.contains
51
- }
52
-
53
- _setConst(fieldSchema, fieldDefn) {
54
- super._setConst(fieldSchema, fieldDefn)
55
-
56
- if (typeof fieldSchema.const !== 'undefined') {
57
- if (fieldSchema.const === null) {
58
- fieldSchema.type = 'null'
59
- } else if (_.isArray(fieldSchema.const)) {
60
- fieldSchema.type = 'array'
61
- } else {
62
- // boolean / number / string / object
63
- fieldSchema.type = typeof fieldSchema.const
64
- if (fieldSchema.type === 'number' && Number.isInteger(fieldSchema.const)) {
65
- fieldSchema.type = 'integer'
66
- }
67
- }
68
- fieldSchema.enum = [fieldSchema.const]
69
- delete fieldSchema.const
70
- }
71
- }
72
- }
73
-
74
- module.exports = JoiJsonDraftSchemaParser
1
+ const _ = require('lodash')
2
+ const JoiJsonSchemaParser = require('./json')
3
+
4
+ class JoiJsonDraftSchemaParser extends JoiJsonSchemaParser {
5
+ constructor(opts = {}) {
6
+ super(_.merge({
7
+ $schema: 'http://json-schema.org/draft-04/schema#',
8
+ logicalOpParser: {
9
+ xor: null,
10
+ with: function (schema, dependency) {
11
+ schema.dependencies = schema.dependencies || {}
12
+ schema.dependencies[dependency.key] = dependency.peers
13
+ },
14
+ without: null
15
+ }
16
+ }, opts))
17
+ }
18
+
19
+ _isIfThenElseSupported() {
20
+ return false
21
+ }
22
+
23
+ _setNumberFieldProperties(fieldSchema, fieldDefn) {
24
+ super._setNumberFieldProperties(fieldSchema, fieldDefn)
25
+
26
+ if (typeof fieldSchema.exclusiveMinimum !== 'undefined') {
27
+ fieldSchema.minimum = fieldSchema.exclusiveMinimum
28
+ fieldSchema.exclusiveMinimum = true
29
+ }
30
+ if (typeof fieldSchema.exclusiveMaximum !== 'undefined') {
31
+ fieldSchema.maximum = fieldSchema.exclusiveMaximum
32
+ fieldSchema.exclusiveMaximum = true
33
+ }
34
+
35
+ if (typeof fieldSchema.minimum !== 'undefined' && fieldSchema.minimum === fieldSchema.exclusiveMinimum) {
36
+ fieldSchema.exclusiveMinimum = true
37
+ }
38
+ if (typeof fieldSchema.maximum !== 'undefined' && fieldSchema.maximum === fieldSchema.exclusiveMaximum) {
39
+ fieldSchema.exclusiveMaximum = true
40
+ }
41
+ }
42
+
43
+ _getLocalSchemaBasePath() {
44
+ return '#/definitions'
45
+ }
46
+
47
+ _setArrayFieldProperties(fieldSchema, fieldDefn, definitions, level) {
48
+ super._setArrayFieldProperties(fieldSchema, fieldDefn, definitions, level)
49
+
50
+ delete fieldSchema.contains
51
+ }
52
+
53
+ _setConst(fieldSchema, fieldDefn) {
54
+ super._setConst(fieldSchema, fieldDefn)
55
+
56
+ if (typeof fieldSchema.const !== 'undefined') {
57
+ if (fieldSchema.const === null) {
58
+ fieldSchema.type = 'null'
59
+ } else if (_.isArray(fieldSchema.const)) {
60
+ fieldSchema.type = 'array'
61
+ } else {
62
+ // boolean / number / string / object
63
+ fieldSchema.type = typeof fieldSchema.const
64
+ if (fieldSchema.type === 'number' && Number.isInteger(fieldSchema.const)) {
65
+ fieldSchema.type = 'integer'
66
+ }
67
+ }
68
+ fieldSchema.enum = [fieldSchema.const]
69
+ delete fieldSchema.const
70
+ }
71
+ }
72
+ }
73
+
74
+ module.exports = JoiJsonDraftSchemaParser
@@ -1,16 +1,16 @@
1
- const _ = require('lodash')
2
- const JoiJsonSchemaParser = require('./json')
3
-
4
- class JoiJsonDraftSchemaParser extends JoiJsonSchemaParser {
5
- constructor(opts = {}) {
6
- super(_.merge({
7
- $schema: 'https://json-schema.org/draft/2019-09/schema'
8
- }, opts))
9
- }
10
-
11
- _isKnownMetaKey(key) {
12
- return key === 'deprecated' || key === 'readOnly' || key === 'writeOnly'
13
- }
14
- }
15
-
16
- module.exports = JoiJsonDraftSchemaParser
1
+ const _ = require('lodash')
2
+ const JoiJsonSchemaParser = require('./json')
3
+
4
+ class JoiJsonDraftSchemaParser extends JoiJsonSchemaParser {
5
+ constructor(opts = {}) {
6
+ super(_.merge({
7
+ $schema: 'https://json-schema.org/draft/2019-09/schema'
8
+ }, opts))
9
+ }
10
+
11
+ _isKnownMetaKey(key) {
12
+ return key === 'deprecated' || key === 'readOnly' || key === 'writeOnly'
13
+ }
14
+ }
15
+
16
+ module.exports = JoiJsonDraftSchemaParser