json-schema-to-typescript
Advanced tools
Comparing version 10.1.0 to 10.1.1
@@ -44,3 +44,3 @@ "use strict"; | ||
// to the parent intersection type, so we remove it from the children. | ||
return parseAsTypeWithCache(lodash_1.omit(schema, 'description', 'id', 'title'), type, options, keyName, processed, usedNames); | ||
return parseAsTypeWithCache(utils_1.maybeStripNameHints(schema), type, options, keyName, processed, usedNames); | ||
}); | ||
@@ -47,0 +47,0 @@ utils_1.log('blue', 'parser', 'Types:', types, 'Input:', schema, 'Output:', ast); |
@@ -34,2 +34,10 @@ import { JSONSchema, LinkedJSONSchema } from './types/JSONSchema'; | ||
export declare function maybeStripDefault(schema: LinkedJSONSchema): LinkedJSONSchema; | ||
/** | ||
* Removes the schema's `id`, `name`, and `description` properties | ||
* if they exist. | ||
* Useful when parsing intersections. | ||
* | ||
* Mutates `schema`. | ||
*/ | ||
export declare function maybeStripNameHints(schema: JSONSchema): JSONSchema; | ||
export {}; |
@@ -10,3 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.maybeStripDefault = exports.pathTransform = exports.escapeBlockComment = exports.log = exports.error = exports.generateName = exports.toSafeString = exports.stripExtension = exports.justName = exports.traverse = exports.mapDeep = exports.Try = void 0; | ||
exports.maybeStripNameHints = exports.maybeStripDefault = exports.pathTransform = exports.escapeBlockComment = exports.log = exports.error = exports.generateName = exports.toSafeString = exports.stripExtension = exports.justName = exports.traverse = exports.mapDeep = exports.Try = void 0; | ||
var lodash_1 = require("lodash"); | ||
@@ -343,2 +343,22 @@ var path_1 = require("path"); | ||
exports.maybeStripDefault = maybeStripDefault; | ||
/** | ||
* Removes the schema's `id`, `name`, and `description` properties | ||
* if they exist. | ||
* Useful when parsing intersections. | ||
* | ||
* Mutates `schema`. | ||
*/ | ||
function maybeStripNameHints(schema) { | ||
if ('description' in schema) { | ||
delete schema.description; | ||
} | ||
if ('id' in schema) { | ||
delete schema.id; | ||
} | ||
if ('name' in schema) { | ||
delete schema.name; | ||
} | ||
return schema; | ||
} | ||
exports.maybeStripNameHints = maybeStripNameHints; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "json-schema-to-typescript", | ||
"version": "10.1.0", | ||
"version": "10.1.1", | ||
"description": "compile json schema to typescript typings", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -26,3 +26,3 @@ import {JSONSchema4Type, JSONSchema4TypeName} from 'json-schema' | ||
} from './types/JSONSchema' | ||
import {generateName, log, maybeStripDefault} from './utils' | ||
import {generateName, log, maybeStripDefault, maybeStripNameHints} from './utils' | ||
@@ -70,3 +70,3 @@ export type Processed = Map<LinkedJSONSchema, Map<SchemaType, AST>> | ||
// to the parent intersection type, so we remove it from the children. | ||
parseAsTypeWithCache(omit(schema, 'description', 'id', 'title'), type, options, keyName, processed, usedNames) | ||
parseAsTypeWithCache(maybeStripNameHints(schema), type, options, keyName, processed, usedNames) | ||
) | ||
@@ -73,0 +73,0 @@ |
@@ -344,1 +344,21 @@ import {deburr, isPlainObject, mapValues, trim, upperFirst} from 'lodash' | ||
} | ||
/** | ||
* Removes the schema's `id`, `name`, and `description` properties | ||
* if they exist. | ||
* Useful when parsing intersections. | ||
* | ||
* Mutates `schema`. | ||
*/ | ||
export function maybeStripNameHints(schema: JSONSchema): JSONSchema { | ||
if ('description' in schema) { | ||
delete schema.description | ||
} | ||
if ('id' in schema) { | ||
delete schema.id | ||
} | ||
if ('name' in schema) { | ||
delete schema.name | ||
} | ||
return schema | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
402196
4822