@takeshape/schema 8.68.1 → 8.68.3
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.
- package/es/rewrite.js +4 -5
- package/lib/rewrite.d.ts.map +1 -1
- package/lib/rewrite.js +5 -5
- package/package.json +4 -4
package/es/rewrite.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import defaults from 'lodash/fp/defaults';
|
|
2
|
+
import { isObject } from '@takeshape/util';
|
|
2
3
|
const rewriteSchemaCache = new Map();
|
|
3
4
|
|
|
4
5
|
function getRewriteCache(options) {
|
|
@@ -32,11 +33,9 @@ export function rewriteSchema(schema, options) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
rewrittenSchema = JSON.parse(JSON.stringify(schema), (_key, value) => {
|
|
35
|
-
if (
|
|
36
|
-
var _value$required;
|
|
37
|
-
|
|
36
|
+
if (isObject(value)) {
|
|
38
37
|
// Remove required
|
|
39
|
-
if (options.removeRequired && (
|
|
38
|
+
if (options.removeRequired && Array.isArray(value.required) && value.required.length) {
|
|
40
39
|
delete value.required;
|
|
41
40
|
} // Remove default
|
|
42
41
|
|
|
@@ -45,7 +44,7 @@ export function rewriteSchema(schema, options) {
|
|
|
45
44
|
delete value.default;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
if (options.replaceInput && value['@input']) {
|
|
47
|
+
if (options.replaceInput && isObject(value['@input'])) {
|
|
49
48
|
return { ...value['@input'],
|
|
50
49
|
'@mapping': value['@mapping']
|
|
51
50
|
};
|
package/lib/rewrite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/rewrite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../src/rewrite.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAkBD;;GAEG;AAEH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,CAAC,CAkC3F"}
|
package/lib/rewrite.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.rewriteSchema = rewriteSchema;
|
|
|
7
7
|
|
|
8
8
|
var _defaults = _interopRequireDefault(require("lodash/fp/defaults"));
|
|
9
9
|
|
|
10
|
+
var _util = require("@takeshape/util");
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
13
|
|
|
12
14
|
const rewriteSchemaCache = new Map();
|
|
@@ -42,11 +44,9 @@ function rewriteSchema(schema, options) {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
rewrittenSchema = JSON.parse(JSON.stringify(schema), (_key, value) => {
|
|
45
|
-
if (
|
|
46
|
-
var _value$required;
|
|
47
|
-
|
|
47
|
+
if ((0, _util.isObject)(value)) {
|
|
48
48
|
// Remove required
|
|
49
|
-
if (options.removeRequired && (
|
|
49
|
+
if (options.removeRequired && Array.isArray(value.required) && value.required.length) {
|
|
50
50
|
delete value.required;
|
|
51
51
|
} // Remove default
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ function rewriteSchema(schema, options) {
|
|
|
55
55
|
delete value.default;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (options.replaceInput && value['@input']) {
|
|
58
|
+
if (options.replaceInput && (0, _util.isObject)(value['@input'])) {
|
|
59
59
|
return { ...value['@input'],
|
|
60
60
|
'@mapping': value['@mapping']
|
|
61
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/schema",
|
|
3
|
-
"version": "8.68.
|
|
3
|
+
"version": "8.68.3",
|
|
4
4
|
"description": "TakeShape Schema",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"examples"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@takeshape/errors": "8.68.
|
|
25
|
-
"@takeshape/json-schema": "8.68.
|
|
26
|
-
"@takeshape/util": "8.68.
|
|
24
|
+
"@takeshape/errors": "8.68.3",
|
|
25
|
+
"@takeshape/json-schema": "8.68.3",
|
|
26
|
+
"@takeshape/util": "8.68.3",
|
|
27
27
|
"ajv": "^7.0.4",
|
|
28
28
|
"ajv-formats": "^1.5.1",
|
|
29
29
|
"blueimp-md5": "^2.10.0",
|