typescript-json-schema
Advanced tools
Comparing version 0.39.0 to 0.40.0
@@ -145,3 +145,5 @@ "use strict"; | ||
assertSchema("annotation-ref", "MyObject"); | ||
assertSchema("annotation-tjs", "MyObject"); | ||
assertSchema("annotation-tjs", "MyObject", { | ||
validationKeywords: ["hide"] | ||
}); | ||
assertSchema("annotation-id", "MyObject"); | ||
@@ -148,0 +150,0 @@ assertSchema("typeof-keyword", "MyObject", { typeOfKeyword: true }); |
import * as ts from "typescript"; | ||
import { JSONSchema7 } from "json-schema"; | ||
export { Program, CompilerOptions, Symbol } from "typescript"; | ||
@@ -29,36 +30,34 @@ export declare function getDefaultArgs(): Args; | ||
export declare type PrimitiveType = number | boolean | string | null; | ||
export declare type Definition = { | ||
$ref?: string; | ||
$schema?: string; | ||
$id?: string; | ||
description?: string; | ||
examples?: any[]; | ||
allOf?: Definition[]; | ||
oneOf?: Definition[]; | ||
anyOf?: Definition[]; | ||
title?: string; | ||
declare type RedifinedFields = "type" | "items" | "additionalItems" | "contains" | "properties" | "patternProperties" | "additionalProperties" | "dependencies" | "propertyNames" | "if" | "then" | "else" | "allOf" | "anyOf" | "oneOf" | "not" | "definitions"; | ||
export declare type DefinitionOrBoolean = Definition | boolean; | ||
export interface Definition extends Omit<JSONSchema7, RedifinedFields> { | ||
type?: string | string[]; | ||
definitions?: { | ||
[key: string]: any; | ||
}; | ||
format?: string; | ||
items?: Definition | Definition[]; | ||
minItems?: number; | ||
additionalItems?: { | ||
anyOf: Definition[]; | ||
} | Definition; | ||
enum?: PrimitiveType[] | Definition[]; | ||
default?: PrimitiveType | Object; | ||
additionalProperties?: Definition | boolean; | ||
required?: string[]; | ||
propertyOrder?: string[]; | ||
defaultProperties?: string[]; | ||
typeof?: "function"; | ||
items?: DefinitionOrBoolean | DefinitionOrBoolean[]; | ||
additionalItems?: DefinitionOrBoolean; | ||
contains?: JSONSchema7; | ||
properties?: { | ||
[key: string]: any; | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
defaultProperties?: string[]; | ||
patternProperties?: { | ||
[pattern: string]: Definition; | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
typeof?: "function"; | ||
}; | ||
additionalProperties?: DefinitionOrBoolean; | ||
dependencies?: { | ||
[key: string]: DefinitionOrBoolean | string[]; | ||
}; | ||
propertyNames?: DefinitionOrBoolean; | ||
if?: DefinitionOrBoolean; | ||
then?: DefinitionOrBoolean; | ||
else?: DefinitionOrBoolean; | ||
allOf?: DefinitionOrBoolean[]; | ||
anyOf?: DefinitionOrBoolean[]; | ||
oneOf?: DefinitionOrBoolean[]; | ||
not?: DefinitionOrBoolean; | ||
definitions?: { | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
} | ||
export declare type SymbolRef = { | ||
@@ -65,0 +64,0 @@ name: string; |
@@ -229,3 +229,14 @@ "use strict"; | ||
jsdocs.forEach(function (doc) { | ||
var _a = (doc.name === "TJS" ? new RegExp(REGEX_TJS_JSDOC).exec(doc.text).slice(1, 3) : [doc.name, doc.text]), name = _a[0], text = _a[1]; | ||
var _a = [doc.name, doc.text], name = _a[0], text = _a[1]; | ||
if (doc.name === "TJS") { | ||
var match = new RegExp(REGEX_TJS_JSDOC).exec(doc.text); | ||
if (match) { | ||
name = match[1]; | ||
text = match[2]; | ||
} | ||
else { | ||
name = text.replace(/^[\s\-]+/, ""); | ||
text = "true"; | ||
} | ||
} | ||
if (validationKeywords[name] || _this.userValidationKeywords[name]) { | ||
@@ -232,0 +243,0 @@ definition[name] = text === undefined ? "" : parseValue(text); |
{ | ||
"name": "typescript-json-schema", | ||
"version": "0.39.0", | ||
"version": "0.40.0", | ||
"description": "typescript-json-schema generates JSON Schema files from your Typescript sources", | ||
@@ -48,20 +48,20 @@ "main": "dist/typescript-json-schema.js", | ||
"dependencies": { | ||
"@types/json-schema": "^7.0.3", | ||
"glob": "~7.1.4", | ||
"json-stable-stringify": "^1.0.1", | ||
"typescript": "^3.5.1", | ||
"yargs": "^13.2.4" | ||
"typescript": "^3.5.3", | ||
"yargs": "^14.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/assertion-error": "^1.1.0", | ||
"@types/chai": "^4.1.7", | ||
"@types/chai": "^4.2.0", | ||
"@types/glob": "^7.1.1", | ||
"@types/json-stable-stringify": "^1.0.32", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.0.4", | ||
"ajv": "^6.10.0", | ||
"@types/node": "^12.7.2", | ||
"ajv": "^6.10.2", | ||
"chai": "^4.2.0", | ||
"mocha": "^6.1.4", | ||
"source-map-support": "^0.5.12", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.17.0" | ||
"mocha": "^6.2.0", | ||
"source-map-support": "^0.5.13", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.19.0" | ||
}, | ||
@@ -68,0 +68,0 @@ "scripts": { |
@@ -32,3 +32,2 @@ { | ||
"no-unused-expression": true, | ||
"no-use-before-declare": true, | ||
"one-line": [ | ||
@@ -35,0 +34,0 @@ true, |
@@ -6,2 +6,3 @@ import * as glob from "glob"; | ||
import * as ts from "typescript"; | ||
import { JSONSchema7 } from "json-schema"; | ||
export { Program, CompilerOptions, Symbol } from "typescript"; | ||
@@ -69,31 +70,40 @@ | ||
export type Definition = { | ||
$ref?: string, | ||
$schema?: string, | ||
$id?: string, | ||
description?: string, | ||
examples?: any[], | ||
allOf?: Definition[], | ||
oneOf?: Definition[], | ||
anyOf?: Definition[], | ||
title?: string, | ||
type?: string | string[], | ||
definitions?: {[key: string]: any}, | ||
format?: string, | ||
items?: Definition | Definition[], | ||
minItems?: number, | ||
additionalItems?: { | ||
anyOf: Definition[] | ||
} | Definition, | ||
enum?: PrimitiveType[] | Definition[], | ||
default?: PrimitiveType | Object, | ||
additionalProperties?: Definition | boolean, | ||
required?: string[], | ||
propertyOrder?: string[], | ||
properties?: {[key: string]: any}, | ||
defaultProperties?: string[], | ||
patternProperties?: {[pattern: string]: Definition}, | ||
typeof?: "function" | ||
}; | ||
type RedifinedFields = "type" | "items" | "additionalItems" | "contains" | "properties" | "patternProperties" | "additionalProperties" | "dependencies" | "propertyNames" | "if" | "then" | "else" | "allOf" | "anyOf" | "oneOf" | "not" | "definitions"; | ||
export type DefinitionOrBoolean = Definition | boolean; | ||
export interface Definition extends Omit<JSONSchema7, RedifinedFields> { | ||
// The type field here is incompatible with the standard definition | ||
type?: string | string[]; | ||
// Non-standard fields | ||
propertyOrder?: string[]; | ||
defaultProperties?: string[]; | ||
typeof?: "function"; | ||
// Fields that must be redifined because they make use of this definition itself | ||
items?: DefinitionOrBoolean | DefinitionOrBoolean[]; | ||
additionalItems?: DefinitionOrBoolean; | ||
contains?: JSONSchema7; | ||
properties?: { | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
patternProperties?: { | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
additionalProperties?: DefinitionOrBoolean; | ||
dependencies?: { | ||
[key: string]: DefinitionOrBoolean | string[]; | ||
}; | ||
propertyNames?: DefinitionOrBoolean; | ||
if?: DefinitionOrBoolean; | ||
then?: DefinitionOrBoolean; | ||
else?: DefinitionOrBoolean; | ||
allOf?: DefinitionOrBoolean[]; | ||
anyOf?: DefinitionOrBoolean[]; | ||
oneOf?: DefinitionOrBoolean[]; | ||
not?: DefinitionOrBoolean; | ||
definitions?: { | ||
[key: string]: DefinitionOrBoolean; | ||
}; | ||
} | ||
export type SymbolRef = { | ||
@@ -368,3 +378,14 @@ name: string; | ||
// if we have @TJS-... annotations, we have to parse them | ||
const [name, text] = (doc.name === "TJS" ? new RegExp(REGEX_TJS_JSDOC).exec(doc.text!)!.slice(1,3) : [doc.name, doc.text]) as string[]; | ||
let [ name, text ] = [doc.name, doc.text as string]; | ||
if( doc.name === "TJS" ) { | ||
let match: string[] | RegExpExecArray | null = new RegExp(REGEX_TJS_JSDOC).exec(doc.text!); | ||
if( match ) { | ||
name = match[1]; | ||
text = match[2]; | ||
} else { | ||
// Treat empty text as boolean true | ||
name = (text as string).replace(/^[\s\-]+/, ""); | ||
text = "true"; | ||
} | ||
} | ||
if (validationKeywords[name] || this.userValidationKeywords[name]) { | ||
@@ -371,0 +392,0 @@ definition[name] = text === undefined ? "" : parseValue(text); |
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
182929
11
2788
5
+ Added@types/json-schema@^7.0.3
+ Added@types/json-schema@7.0.15(transitive)
+ Addedyargs@14.2.3(transitive)
+ Addedyargs-parser@15.0.3(transitive)
- Removedyargs@13.3.2(transitive)
- Removedyargs-parser@13.1.2(transitive)
Updatedtypescript@^3.5.3
Updatedyargs@^14.0.0