-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1799 from vega/next
- Loading branch information
Showing
16 changed files
with
1,240 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
"json5": "^2.2.3", | ||
"normalize-path": "^3.0.0", | ||
"safe-stable-stringify": "^2.4.3", | ||
"typescript": "~5.1.6" | ||
"typescript": "~5.2.2" | ||
}, | ||
"devDependencies": { | ||
"@auto-it/conventional-commits": "^11.0.0", | ||
|
@@ -92,5 +92,6 @@ | |
"debug": "node -r ts-node/register --inspect-brk ts-json-schema-generator.ts", | ||
"run": "ts-node-transpile-only ts-json-schema-generator.ts", | ||
"release": "yarn build && auto shipit" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* @title Some title here | ||
* @description Some description here | ||
*/ | ||
export interface MyObject { | ||
/** | ||
* @title String field title | ||
* @minLength 10 | ||
* @format date-time | ||
* @pattern /^\d+$/ | ||
*/ | ||
stringValue: string; | ||
|
||
/** | ||
* @title Required value | ||
*/ | ||
requiredValue: number | string; | ||
/** | ||
* @title Nullable value | ||
*/ | ||
nullableValue: number | string |null; | ||
/** | ||
* @title Optional value | ||
*/ | ||
optionalValue: number | string | undefined; | ||
|
||
/** | ||
* Some ignored comment description | ||
* | ||
* @description Export field description | ||
* @default {"length": 10} | ||
* @nullable | ||
*/ | ||
exportString: MyExportString; | ||
/** | ||
* @description Export field description | ||
* @default "private" | ||
*/ | ||
privateString: MyPrivateString; | ||
|
||
/** | ||
* @title Non empty array | ||
*/ | ||
numberArray: MyNonEmptyArray<number>; | ||
|
||
/** | ||
* @nullable | ||
*/ | ||
number: number; | ||
|
||
/** | ||
* Some more examples: | ||
* ```yaml | ||
* name: description | ||
* length: 42 | ||
* ``` | ||
*/ | ||
description: InheritedExample['description']; | ||
|
||
/** | ||
* @default "" | ||
*/ | ||
inheritedDescription: InheritedExample['description']; | ||
} | ||
|
||
/** | ||
* @title My export string | ||
*/ | ||
export type MyExportString = string; | ||
/** | ||
* @title My private string | ||
*/ | ||
type MyPrivateString = string; | ||
/** | ||
* @minItems 1 | ||
*/ | ||
export type MyNonEmptyArray<T> = T[]; | ||
|
||
interface InheritedExample { | ||
/** | ||
* We have a bit more text. | ||
* | ||
* Usage: It is possible to add markdown in the JSDoc comment. | ||
* | ||
* ```ts | ||
* // comment | ||
* async function readFile(path: string): Promise<string>; | ||
* ``` | ||
* | ||
* It is stored raw. | ||
* @title description | ||
* | ||
* More comments. | ||
* | ||
*/ | ||
description: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"MyExportString": { | ||
"title": "My export string", | ||
"type": "string" | ||
}, | ||
"MyNonEmptyArray<number>": { | ||
"items": { | ||
"type": "number" | ||
}, | ||
"minItems": 1, | ||
"type": "array" | ||
} | ||
}, | ||
"description": "Some description here", | ||
"properties": { | ||
"description": { | ||
"description": "Some more examples: ```yaml name: description length: 42 ```", | ||
"markdownDescription": "Some more examples:\n```yaml\nname: description\nlength: 42\n```", | ||
"title": "description\n\nMore comments.", | ||
"type": "string" | ||
}, | ||
"exportString": { | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/MyExportString", | ||
"markdownDescription": "Some ignored comment description" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"default": { | ||
"length": 10 | ||
}, | ||
"description": "Export field description" | ||
}, | ||
"inheritedDescription": { | ||
"default": "", | ||
"description": "We have a bit more text.\n\nUsage: It is possible to add markdown in the JSDoc comment.\n\n```ts // comment async function readFile(path: string): Promise<string>; ```\n\nIt is stored raw.", | ||
"markdownDescription": "We have a bit more text.\n\nUsage: It is possible to add markdown in the JSDoc comment.\n\n```ts\n// comment\nasync function readFile(path: string): Promise<string>;\n```\n\nIt is stored raw.", | ||
"title": "description\n\nMore comments.", | ||
"type": "string" | ||
}, | ||
"nullableValue": { | ||
"title": "Nullable value", | ||
"type": [ | ||
"number", | ||
"string", | ||
"null" | ||
] | ||
}, | ||
"number": { | ||
"type": [ | ||
"number", | ||
"null" | ||
] | ||
}, | ||
"numberArray": { | ||
"$ref": "#/definitions/MyNonEmptyArray%3Cnumber%3E", | ||
"title": "Non empty array" | ||
}, | ||
"optionalValue": { | ||
"title": "Optional value", | ||
"type": [ | ||
"number", | ||
"string" | ||
] | ||
}, | ||
"privateString": { | ||
"default": "private", | ||
"description": "Export field description", | ||
"title": "My private string", | ||
"type": "string" | ||
}, | ||
"requiredValue": { | ||
"title": "Required value", | ||
"type": [ | ||
"number", | ||
"string" | ||
] | ||
}, | ||
"stringValue": { | ||
"format": "date-time", | ||
"minLength": 10, | ||
"pattern": "/^\\d+$/", | ||
"title": "String field title", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"stringValue", | ||
"requiredValue", | ||
"nullableValue", | ||
"exportString", | ||
"privateString", | ||
"numberArray", | ||
"number", | ||
"description", | ||
"inheritedDescription" | ||
], | ||
"title": "Some title here", | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @required ["id", "keys", "definitions"] | ||
*/ | ||
export interface MyObject { | ||
id?: string; | ||
keys: string[]; | ||
/** | ||
* every element in `keys` must also be a key in `definitions` | ||
* @required { $data: "1/keys" } | ||
*/ | ||
definitions: Record<string, number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { MyObject } from "./main.js"; | ||
|
||
export const validSamples: MyObject[] = [ | ||
{ | ||
id: "123", | ||
keys: ["a", "b"], | ||
definitions: { a: 1, b: 2 }, | ||
}, | ||
{ | ||
id: "123", | ||
keys: [], | ||
definitions: {}, | ||
}, | ||
]; | ||
|
||
export const invalidSamples: MyObject[] = [ | ||
{ | ||
keys: ["a", "b"], | ||
definitions: { a: 1, b: 2 }, | ||
}, | ||
{ | ||
id: "123", | ||
keys: ["a", "b"], | ||
definitions: { a: 1 }, | ||
}, | ||
]; |
Oops, something went wrong.