@ombori/ts-schema
Advanced tools
Comparing version 2.65.5 to 2.82.17
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.82.17](https://github.com/ombori/gridapp/compare/v2.82.16...v2.82.17) (2021-08-13) | ||
### Bug Fixes | ||
* builtin types in settings ([f970d2e](https://github.com/ombori/gridapp/commit/f970d2e16ebd3e834dad81e10267daa22e44c188)) | ||
## [2.65.5](https://github.com/ombori/gridapp/compare/v2.65.4...v2.65.5) (2021-06-09) | ||
@@ -8,0 +19,0 @@ |
17
cli.js
@@ -6,6 +6,15 @@ #!/usr/bin/env node | ||
const extractMeta = (schema) => { | ||
const extractMeta = (schema, root) => { | ||
if (schema.$ref) { | ||
const ref = schema.$ref.split("/"); | ||
if (ref.shift() !== "#") throw new Error("Ref must start with #"); | ||
const obj = ref.reduce((prev, item) => prev[item], root); | ||
const copy = JSON.parse(JSON.stringify(obj)); // create a deep copy of obj | ||
return extractMeta(copy, root); | ||
} | ||
if (schema.type === 'object' && schema.properties) { | ||
return Object.keys(schema.properties).reduce((res, field) => { | ||
const meta = extractMeta(schema.properties[field]); | ||
const meta = extractMeta(schema.properties[field], root); | ||
if (meta !== null) { | ||
@@ -26,3 +35,3 @@ res[field] = meta; | ||
return { | ||
items: extractMeta(schema.items), | ||
items: extractMeta(schema.items, root), | ||
}; | ||
@@ -61,3 +70,3 @@ } | ||
const converted = convert(result); | ||
const meta = extractMeta(converted); // NOTE: this will remove 'ui' field from `converted` | ||
const meta = extractMeta(converted, converted); // NOTE: this will remove 'ui' field from `converted` | ||
const schemaText = JSON.stringify(converted, null, 2); | ||
@@ -64,0 +73,0 @@ const metaSchemaText = JSON.stringify(meta, null, 2); |
{ | ||
"name": "@ombori/ts-schema", | ||
"version": "2.65.5", | ||
"version": "2.82.17", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"license": "ISC", | ||
"gitHead": "3a47b8649f04e487a382f90a6abbfb5511eb8463" | ||
"gitHead": "1e65d47694cea0e74fb7a661dc21223adf5c33a8" | ||
} |
8042
116
115