Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-json-schema-generator

Package Overview
Dependencies
Maintainers
1
Versions
337
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.26.0 to 0.27.0

2

dist/factory/formatter.js

@@ -44,3 +44,3 @@ "use strict";

.addTypeFormatter(new ArrayTypeFormatter_1.ArrayTypeFormatter(circularReferenceTypeFormatter))
.addTypeFormatter(new TupleTypeFormatter_1.TupleTypeFormatter(circularReferenceTypeFormatter))
.addTypeFormatter(new TupleTypeFormatter_1.TupleTypeFormatter(circularReferenceTypeFormatter, config))
.addTypeFormatter(new UnionTypeFormatter_1.UnionTypeFormatter(circularReferenceTypeFormatter))

@@ -47,0 +47,0 @@ .addTypeFormatter(new IntersectionTypeFormatter_1.IntersectionTypeFormatter(circularReferenceTypeFormatter));

@@ -6,2 +6,3 @@ export interface PartialConfig {

sortProps?: boolean;
strictTuples?: boolean;
}

@@ -8,0 +9,0 @@ export interface Config extends PartialConfig {

@@ -8,3 +8,4 @@ "use strict";

sortProps: true,
strictTuples: false,
};
//# sourceMappingURL=Config.js.map

@@ -14,2 +14,3 @@ export declare type RawType = number | boolean | string | null;

minItems?: number;
maxItems?: number;
additionalItems?: {

@@ -16,0 +17,0 @@ anyOf: Definition[];

@@ -0,1 +1,2 @@

import { Config } from "../Config";
import { Definition } from "../Schema/Definition";

@@ -8,3 +9,4 @@ import { SubTypeFormatter } from "../SubTypeFormatter";

private childTypeFormatter;
constructor(childTypeFormatter: TypeFormatter);
private config;
constructor(childTypeFormatter: TypeFormatter, config: Config);
supportsType(type: TupleType): boolean;

@@ -11,0 +13,0 @@ getDefinition(type: TupleType): Definition;

@@ -5,4 +5,5 @@ "use strict";

class TupleTypeFormatter {
constructor(childTypeFormatter) {
constructor(childTypeFormatter, config) {
this.childTypeFormatter = childTypeFormatter;
this.config = config;
}

@@ -14,3 +15,5 @@ supportsType(type) {

const tupleDefinitions = type.getTypes().map((item) => this.childTypeFormatter.getDefinition(item));
return Object.assign({ type: "array", items: tupleDefinitions, minItems: tupleDefinitions.length }, (tupleDefinitions.length > 1 ? { additionalItems: { anyOf: tupleDefinitions } } : {}));
const addAdditionalItems = tupleDefinitions.length > 1 && !this.config.strictTuples;
const additionalItems = { additionalItems: { anyOf: tupleDefinitions } };
return Object.assign({ type: "array", items: tupleDefinitions, minItems: tupleDefinitions.length }, (addAdditionalItems ? additionalItems : { maxItems: tupleDefinitions.length }));
}

@@ -17,0 +20,0 @@ getChildren(type) {

@@ -43,3 +43,17 @@ "use strict";

assertSchema("jsdoc-inheritance", { type: "MyObject", expose: "export", topRef: true, jsDoc: "extended" });
assertSchema("strict-tuples-true", {
type: "MyObject",
expose: "export",
topRef: true,
jsDoc: "none",
strictTuples: true,
});
assertSchema("strict-tuples-false", {
type: "MyObject",
expose: "export",
topRef: true,
jsDoc: "none",
strictTuples: false,
});
});
//# sourceMappingURL=config.test.js.map

@@ -16,4 +16,5 @@ "use strict";

.option("-u, --unstable", "Do not sort properties")
.option("-s, --strictTuples", "Do not allow additional items on tuples")
.parse(process.argv);
const config = Object.assign({}, Config_1.DEFAULT_CONFIG, { path: args.path, type: args.type, expose: args.expose, topRef: args.topRef, jsDoc: args.jsDoc, sortProps: !args.unstable });
const config = Object.assign({}, Config_1.DEFAULT_CONFIG, { path: args.path, type: args.type, expose: args.expose, topRef: args.topRef, jsDoc: args.jsDoc, sortProps: !args.unstable, strictTuples: args.strictTuples });
try {

@@ -20,0 +21,0 @@ const schema = generator_1.createGenerator(config).createSchema(args.type);

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

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

@@ -25,5 +25,30 @@ # ts-json-schema-generator

--expose 'export' \
--jsDoc 'extended'
--jsDoc 'extended' \
--strictTuples
```
## Options
```
-e, --expose <all|none|export>
all: Create shared $ref definitions for all types.
none: Do not create shared $ref definitions.
export: Create shared $ref definitions only for exported types.
-r, --no-top-ref
Do not create a top-level $ref definition.
-j, --jsDoc <extended|none|basic>
basic: Read JsDoc annotations to provide schema properties.
extended: Also read @nullable, and @asType annotations.
none: Do not use JsDoc annotations.
-u, --unstable
Do not sort properties.
-s, --strictTuples
Do not allow additional items on tuples.
```
## Current state

@@ -30,0 +55,0 @@

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

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