New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-json-schema-generator

Package Overview
Dependencies
Maintainers
1
Versions
340
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-json-schema-generator - npm Package Compare versions

Comparing version 0.61.1 to 0.62.0

1

dist/src/TypeFormatter/ObjectTypeFormatter.d.ts

@@ -12,4 +12,5 @@ import { Definition } from "../Schema/Definition";

getChildren(type: ObjectType): BaseType[];
private getCircularChildRefs;
private getObjectDefinition;
private prepareObjectProperty;
}

54

dist/src/TypeFormatter/ObjectTypeFormatter.js

@@ -30,24 +30,42 @@ "use strict";

const additionalProperties = type.getAdditionalProperties();
const childrenOfBase = type
.getBaseTypes()
.reduce((result, baseType) => [
...result,
...this.childTypeFormatter
.getChildren(baseType)
.filter(childType => childType.getName() !== baseType.getName()),
], []);
const childrenOfAdditionalProps = additionalProperties instanceof BaseType_1.BaseType ? this.childTypeFormatter.getChildren(additionalProperties) : [];
const childrenOfProps = properties.reduce((result, property) => {
const propertyType = property.getType();
if (propertyType === undefined) {
return result;
}
return [...result, ...this.childTypeFormatter.getChildren(propertyType)];
}, []);
const children = [
...type
.getBaseTypes()
.reduce((result, baseType) => [
...result,
...this.childTypeFormatter
.getChildren(baseType)
.filter(childType => childType.getName() !== baseType.getName()),
], []),
...(additionalProperties instanceof BaseType_1.BaseType
? this.childTypeFormatter.getChildren(additionalProperties)
: []),
...properties.reduce((result, property) => {
const propertyType = property.getType();
if (propertyType === undefined) {
return result;
}
return [...result, ...this.childTypeFormatter.getChildren(propertyType)];
}, []),
...childrenOfBase,
...childrenOfAdditionalProps,
...childrenOfProps,
...this.getCircularChildRefs(type),
];
return uniqueArray_1.uniqueArray(children);
}
getCircularChildRefs(type) {
var _a;
const children = [];
for (const baseType of type.getBaseTypes()) {
const dereffedType = derefType_1.derefType(baseType);
if (dereffedType instanceof ObjectType_1.ObjectType) {
for (const prop of dereffedType.getProperties()) {
if (((_a = prop.getType()) === null || _a === void 0 ? void 0 : _a.getName()) === baseType.getName()) {
children.push(baseType);
break;
}
}
}
}
return children;
}
getObjectDefinition(type) {

@@ -54,0 +72,0 @@ const objectProperties = type.getProperties();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const AliasType_1 = require("../Type/AliasType");
const AnnotatedType_1 = require("../Type/AnnotatedType");
const DefinitionType_1 = require("../Type/DefinitionType");
const ReferenceType_1 = require("../Type/ReferenceType");
const uniqueArray_1 = require("./uniqueArray");
const deepMerge_1 = require("./deepMerge");
function getNonRefType(type) {
if (type instanceof ReferenceType_1.ReferenceType ||
type instanceof DefinitionType_1.DefinitionType ||
type instanceof AliasType_1.AliasType ||
type instanceof AnnotatedType_1.AnnotatedType) {
return getNonRefType(type.getType());
}
return type;
}
const derefType_1 = require("./derefType");
function getAllOfDefinitionReducer(childTypeFormatter, concatArrays) {
return (definition, baseType) => {
const other = childTypeFormatter.getDefinition(getNonRefType(baseType));
const other = childTypeFormatter.getDefinition(derefType_1.derefType(baseType));
definition.properties = deepMerge_1.deepMerge(other.properties || {}, definition.properties || {}, concatArrays);

@@ -23,0 +11,0 @@ function additionalPropsDefinition(props) {

@@ -99,2 +99,3 @@ "use strict";

it("type-extend", assertSchema("type-extend", "MyObject"));
it("type-extend-circular", assertSchema("type-extend-circular", "MyType"));
it("type-typeof", assertSchema("type-typeof", "MyType"));

@@ -101,0 +102,0 @@ it("type-typeof-value", assertSchema("type-typeof-value", "MyType"));

{
"name": "ts-json-schema-generator",
"version": "0.61.1",
"version": "0.62.0",
"description": "Generate JSON schema from your Typescript sources",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc