typescript-json-schema
Advanced tools
Comparing version 0.20.0 to 0.21.0
{ | ||
"name": "typescript-json-schema", | ||
"version": "0.20.0", | ||
"version": "0.21.0", | ||
"description": "typescript-json-schema generates JSON Schema files from your Typescript sources", | ||
@@ -51,4 +51,4 @@ "main": "typescript-json-schema.js", | ||
"json-stable-stringify": "^1.0.1", | ||
"typescript": "~2.5.3", | ||
"yargs": "^8.0.2" | ||
"typescript": "~2.6.2", | ||
"yargs": "^11.0.0" | ||
}, | ||
@@ -61,8 +61,8 @@ "devDependencies": { | ||
"@types/mocha": "^2.2.41", | ||
"@types/node": "^8.0.7", | ||
"ajv": "^5.2.0", | ||
"chai": "^4.0.2", | ||
"mocha": "^3.4.2", | ||
"source-map-support": "^0.4.15", | ||
"ts-node": "^3.1.0", | ||
"@types/node": "^9.4.6", | ||
"ajv": "^6.2.0", | ||
"chai": "^4.1.2", | ||
"mocha": "^5.0.1", | ||
"source-map-support": "^0.5.3", | ||
"ts-node": "^5.0.0", | ||
"tslint": "^5.4.3" | ||
@@ -69,0 +69,0 @@ }, |
@@ -62,4 +62,7 @@ # typescript-json-schema | ||
const program = TJS.getProgramFromFiles([resolve("my-file.ts")], compilerOptions); | ||
// optionally pass a base path | ||
const basePath = "./my-dir"; | ||
const program = TJS.getProgramFromFiles([resolve("my-file.ts")], compilerOptions, basePath); | ||
// We can either get the schema for one file and one type... | ||
@@ -104,3 +107,3 @@ const schema = TJS.generateSchema(program, "MyType", settings); | ||
"$ref": "#/definitions/Shape", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -107,0 +110,0 @@ "Shape": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "varBoolean": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MySubObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MySubObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "dateTime": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "description": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"items": { | ||
@@ -4,0 +4,0 @@ "type": "number" |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"items": { | ||
@@ -4,0 +4,0 @@ "type": [ |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "propA": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "propA": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MySubObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"additionalProperties": false, | ||
@@ -4,0 +4,0 @@ "description": "Description of MyObject, a top level object,\nwhich also has a comment that spans\nmultiple lines", |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"enum": [ | ||
@@ -4,0 +4,0 @@ 1, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Enum": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"enum": [ | ||
@@ -4,0 +4,0 @@ 1, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Enum": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Enum": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "A.B": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"additionalProperties": { | ||
@@ -4,0 +4,0 @@ "type": [ |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Widget": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Widget": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyEnum": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
"MyGeneric<number, string>": { | ||
"MyGeneric<number,string>": { | ||
"properties": { | ||
@@ -19,3 +19,3 @@ "a": { | ||
}, | ||
"MyGeneric<string, number>": { | ||
"MyGeneric<string,number>": { | ||
"properties": { | ||
@@ -38,6 +38,6 @@ "a": { | ||
"value1": { | ||
"$ref": "#/definitions/MyGeneric<string, number>" | ||
"$ref": "#/definitions/MyGeneric<string,number>" | ||
}, | ||
"value2": { | ||
"$ref": "#/definitions/MyGeneric<number, string>" | ||
"$ref": "#/definitions/MyGeneric<number,string>" | ||
} | ||
@@ -44,0 +44,0 @@ }, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "numberArray": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -93,3 +93,3 @@ "GenericA<\"alias\">": { | ||
}, | ||
"SomeGeneric<\"alias\", \"alias\">": { | ||
"SomeGeneric<\"alias\",\"alias\">": { | ||
"properties": { | ||
@@ -123,3 +123,3 @@ "a": { | ||
}, | ||
"SomeGeneric<1, 2>": { | ||
"SomeGeneric<1,2>": { | ||
"properties": { | ||
@@ -162,6 +162,6 @@ "a": { | ||
"someAlias": { | ||
"$ref": "#/definitions/SomeGeneric<\"alias\", \"alias\">" | ||
"$ref": "#/definitions/SomeGeneric<\"alias\",\"alias\">" | ||
}, | ||
"someGeneric": { | ||
"$ref": "#/definitions/SomeGeneric<1, 2>" | ||
"$ref": "#/definitions/SomeGeneric<1,2>" | ||
} | ||
@@ -168,0 +168,0 @@ }, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
"MyGeneric<number, string>": { | ||
"MyGeneric<number,string>": { | ||
"properties": { | ||
@@ -19,3 +19,3 @@ "a": { | ||
}, | ||
"MyGeneric<string, number>": { | ||
"MyGeneric<string,number>": { | ||
"properties": { | ||
@@ -38,6 +38,6 @@ "a": { | ||
"value1": { | ||
"$ref": "#/definitions/MyGeneric<string, number>" | ||
"$ref": "#/definitions/MyGeneric<string,number>" | ||
}, | ||
"value2": { | ||
"$ref": "#/definitions/MyGeneric<number, string>" | ||
"$ref": "#/definitions/MyGeneric<number,string>" | ||
} | ||
@@ -44,0 +44,0 @@ }, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyGeneric<number>": { |
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
"MyGeneric<number, string>": { | ||
"MyGeneric<number,string>": { | ||
"properties": { | ||
"field": { | ||
"$ref": "#/definitions/MyGeneric<string, number>" | ||
"$ref": "#/definitions/MyGeneric<string,number>" | ||
} | ||
@@ -16,6 +16,6 @@ }, | ||
}, | ||
"MyGeneric<string, number>": { | ||
"MyGeneric<string,number>": { | ||
"properties": { | ||
"field": { | ||
"$ref": "#/definitions/MyGeneric<number, string>" | ||
"$ref": "#/definitions/MyGeneric<number,string>" | ||
} | ||
@@ -31,3 +31,3 @@ }, | ||
"value": { | ||
"$ref": "#/definitions/MyGeneric<string, number>" | ||
"$ref": "#/definitions/MyGeneric<string,number>" | ||
} | ||
@@ -34,0 +34,0 @@ }, |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyGeneric<number>": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "required": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyInterface": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "propA": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MySubObject": { |
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -5,0 +5,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "propA": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyMap1": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyModule.Def": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "propA": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "RootNamespace.Def": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "RootNamespace.Def": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"enum": [ | ||
@@ -4,0 +4,0 @@ "x", |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"type": "object", | ||
@@ -4,0 +4,0 @@ "required": [ "baseRequired", "derivedRequired" ], |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "optional": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "publicMember": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "val": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "bar": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "result": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"description": "This is a description", | ||
@@ -4,0 +4,0 @@ "type": "string", |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"type": "string" | ||
} | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "prop": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"additionalItems": { | ||
@@ -4,0 +4,0 @@ "anyOf": [ |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "B.B": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "B.B": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyAlias": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyString": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyAlias": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyAlias": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyAlias": { |
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -5,0 +5,0 @@ "MyAlias": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyTuple": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Cardinal": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyUnion": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyAlias": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "FieldWithAnonType": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "Function": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"additionalProperties": false, | ||
@@ -4,0 +4,0 @@ "properties": { |
{ | ||
"$ref": "#/definitions/MyObject", | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -5,0 +5,0 @@ "MyObject": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"definitions": { | ||
@@ -4,0 +4,0 @@ "MyType6": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "array1": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"anyOf": [ | ||
@@ -4,0 +4,0 @@ { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "var1": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "foo": { |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"properties": { | ||
@@ -4,0 +4,0 @@ "name": { |
import * as TJS from "../typescript-json-schema"; | ||
export declare function assertSchema(group: string, type: string, settings?: TJS.PartialArgs, compilerOptions?: TJS.CompilerOptions): void; | ||
export declare function assertSchema(group: string, type: string, settings?: TJS.PartialArgs, compilerOptions?: TJS.CompilerOptions, only?: boolean): void; |
@@ -9,8 +9,9 @@ "use strict"; | ||
var ajv = new Ajv(); | ||
var metaSchema = require("ajv/lib/refs/json-schema-draft-04.json"); | ||
ajv.addMetaSchema(metaSchema, "http://json-schema.org/draft-04/schema#"); | ||
var metaSchema = require("ajv/lib/refs/json-schema-draft-06.json"); | ||
ajv.addMetaSchema(metaSchema); | ||
var BASE = "test/programs/"; | ||
function assertSchema(group, type, settings, compilerOptions) { | ||
function assertSchema(group, type, settings, compilerOptions, only) { | ||
if (settings === void 0) { settings = {}; } | ||
it(group + " should create correct schema", function () { | ||
var run = only ? it.only : it; | ||
run(group + " should create correct schema", function () { | ||
if (!("required" in settings)) { | ||
@@ -26,2 +27,3 @@ settings.required = true; | ||
ajv.validateSchema(actual); | ||
console.warn(ajv.errors); | ||
chai_1.assert.equal(ajv.errors, null, "The schema is not valid"); | ||
@@ -81,2 +83,3 @@ } | ||
}); | ||
assertSchema("type-mapped-types", "MyMappedType"); | ||
}); | ||
@@ -130,3 +133,2 @@ describe("enums", function () { | ||
assertSchema("type-nullable", "MyObject"); | ||
assertSchema("type-function", "MyObject"); | ||
}); | ||
@@ -133,0 +135,0 @@ describe("class and interface", function () { |
@@ -93,3 +93,3 @@ import * as ts from "typescript"; | ||
} | ||
export declare function getProgramFromFiles(files: string[], compilerOptions?: ts.CompilerOptions): ts.Program; | ||
export declare function getProgramFromFiles(files: string[], jsonCompilerOptions?: any, basePath?: string): ts.Program; | ||
export declare function buildGenerator(program: ts.Program, args?: PartialArgs): JsonSchemaGenerator | null; | ||
@@ -96,0 +96,0 @@ export declare function generateSchema(program: ts.Program, fullTypeName: string, args?: PartialArgs): Definition | null; |
@@ -598,2 +598,3 @@ "use strict"; | ||
} | ||
fullTypeName = fullTypeName.replace(" ", ""); | ||
if (asRef) { | ||
@@ -648,3 +649,3 @@ returnedDefinition = { | ||
} | ||
else if (symbol && symbol.flags & ts.SymbolFlags.TypeLiteral && symbol.members.size === 0) { | ||
else if (symbol && symbol.flags & ts.SymbolFlags.TypeLiteral && symbol.members.size === 0 && !(node && (node.kind === ts.SyntaxKind.MappedType))) { | ||
definition.type = "object"; | ||
@@ -675,3 +676,3 @@ definition.properties = {}; | ||
} | ||
def["$schema"] = "http://json-schema.org/draft-04/schema#"; | ||
def["$schema"] = "http://json-schema.org/draft-06/schema#"; | ||
return def; | ||
@@ -682,3 +683,3 @@ }; | ||
var root = { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
$schema: "http://json-schema.org/draft-06/schema#", | ||
definitions: {} | ||
@@ -743,4 +744,6 @@ }; | ||
exports.JsonSchemaGenerator = JsonSchemaGenerator; | ||
function getProgramFromFiles(files, compilerOptions) { | ||
if (compilerOptions === void 0) { compilerOptions = {}; } | ||
function getProgramFromFiles(files, jsonCompilerOptions, basePath) { | ||
if (jsonCompilerOptions === void 0) { jsonCompilerOptions = {}; } | ||
if (basePath === void 0) { basePath = "./"; } | ||
var compilerOptions = ts.convertCompilerOptionsFromJson(jsonCompilerOptions, basePath).options; | ||
var options = { | ||
@@ -836,3 +839,3 @@ noEmit: true, emitDecoratorMetadata: true, experimentalDecorators: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS | ||
var configObject = result.config; | ||
var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, path.dirname(configFileName), {}, configFileName); | ||
var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, path.dirname(configFileName), {}, path.basename(configFileName)); | ||
var options = configParseResult.options; | ||
@@ -839,0 +842,0 @@ options.noEmit = true; |
@@ -764,2 +764,4 @@ import * as glob from "glob"; | ||
fullTypeName = fullTypeName.replace(" ", ""); | ||
if (asRef) { | ||
@@ -818,3 +820,3 @@ returnedDefinition = { | ||
this.getEnumDefinition(typ, tc, definition); | ||
} else if (symbol && symbol.flags & ts.SymbolFlags.TypeLiteral && symbol.members!.size === 0) { | ||
} else if (symbol && symbol.flags & ts.SymbolFlags.TypeLiteral && symbol.members!.size === 0 && !(node && (node.kind === ts.SyntaxKind.MappedType))) { | ||
// {} is TypeLiteral with no members. Need special case because it doesn't have declarations. | ||
@@ -849,3 +851,3 @@ definition.type = "object"; | ||
} | ||
def["$schema"] = "http://json-schema.org/draft-04/schema#"; | ||
def["$schema"] = "http://json-schema.org/draft-06/schema#"; | ||
return def; | ||
@@ -856,3 +858,3 @@ } | ||
const root = { | ||
$schema: "http://json-schema.org/draft-04/schema#", | ||
$schema: "http://json-schema.org/draft-06/schema#", | ||
definitions: {} | ||
@@ -893,4 +895,5 @@ }; | ||
export function getProgramFromFiles(files: string[], compilerOptions: ts.CompilerOptions = {}): ts.Program { | ||
export function getProgramFromFiles(files: string[], jsonCompilerOptions: any = {}, basePath: string = "./"): ts.Program { | ||
// use built-in default options | ||
const compilerOptions = ts.convertCompilerOptionsFromJson(jsonCompilerOptions, basePath).options; | ||
const options: ts.CompilerOptions = { | ||
@@ -1005,3 +1008,3 @@ noEmit: true, emitDecoratorMetadata: true, experimentalDecorators: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS | ||
const configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, path.dirname(configFileName), {}, configFileName); | ||
const configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, path.dirname(configFileName), {}, path.basename(configFileName)); | ||
const options = configParseResult.options; | ||
@@ -1008,0 +1011,0 @@ options.noEmit = true; |
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
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
276845
180
5574
134
+ Addedcliui@4.1.0(transitive)
+ Addedcross-spawn@6.0.6(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexeca@1.0.0(transitive)
+ Addedget-stream@4.1.0(transitive)
+ Addedinvert-kv@2.0.0(transitive)
+ Addedlcid@2.0.0(transitive)
+ Addedmap-age-cleaner@0.1.3(transitive)
+ Addedmem@4.3.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addedos-locale@3.1.0(transitive)
+ Addedp-defer@1.0.0(transitive)
+ Addedp-is-promise@2.1.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedtypescript@2.6.2(transitive)
+ Addedyargs@11.1.1(transitive)
+ Addedyargs-parser@9.0.2(transitive)
- Removedcliui@3.2.0(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedexeca@0.7.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedlcid@1.0.0(transitive)
- Removedload-json-file@2.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmem@1.1.0(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedos-locale@2.1.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@2.0.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedread-pkg@2.0.0(transitive)
- Removedread-pkg-up@2.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtypescript@2.5.3(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedyallist@2.1.2(transitive)
- Removedyargs@8.0.2(transitive)
- Removedyargs-parser@7.0.0(transitive)
Updatedtypescript@~2.6.2
Updatedyargs@^11.0.0