Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
459 changes: 262 additions & 197 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,44 @@
},
"dependencies": {
"@types/json-schema": "^7.0.15",
"commander": "^14.0.0",
"commander": "^14.0.2",
"glob": "^13.0.0",
"json5": "^2.2.3",
"normalize-path": "^3.0.0",
"safe-stable-stringify": "^2.5.0",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"typescript": "^5.9.3",
"@typescript/vfs":"1.6.2"
},
"devDependencies": {
"@auto-it/conventional-commits": "^11.3.0",
"@auto-it/first-time-contributor": "^11.3.0",
"@babel/core": "^7.28.0",
"@babel/preset-env": "^7.28.0",
"@babel/preset-typescript": "^7.27.1",
"@eslint/js": "^9.30.1",
"@auto-it/conventional-commits": "^11.3.6",
"@auto-it/first-time-contributor": "^11.3.6",
"@babel/core": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@babel/preset-typescript": "^7.28.5",
"@eslint/js": "^9.39.1",
"@types/eslint": "^9.6.1",
"@types/jest": "^30.0.0",
"@types/node": "^24.0.10",
"@types/node": "^24.10.1",
"@types/normalize-path": "^3.0.2",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"auto": "^11.3.0",
"chai": "^6.0.1",
"cross-env": "^10.0.0",
"auto": "^11.3.6",
"chai": "^6.2.1",
"cross-env": "^10.1.0",
"eslint": "9.39.1",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-prettier": "^5.5.1",
"globals": "^16.3.0",
"jest": "^30.0.4",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"globals": "^16.5.0",
"jest": "^30.2.0",
"jest-junit": "^16.0.0",
"prettier": "^3.6.2",
"tsx": "^4.20.3",
"typescript-eslint": "^8.35.1",
"vega": "^6.1.2",
"vega-lite": "^6.2.0"
"prettier": "^3.7.3",
"tsx": "^4.21.0",
"typescript-eslint": "^8.48.0",
"vega": "^6.2.0",
"vega-lite": "^6.4.1"
},
"packageManager": "npm@11.4.2",
"packageManager": "npm@11.6.4",
"engines": {
"node": ">=18.0.0"
}
Expand Down
4 changes: 1 addition & 3 deletions src/Type/AnnotatedType.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { BaseType } from "./BaseType.js";
import { hash } from "../Utils/nodeKey.js";

export interface Annotations {
[name: string]: any;
}
export type Annotations = Record<string, unknown>;

export class AnnotatedType extends BaseType {
public constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/TypeFormatter/AnnotatedTypeFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AnnotatedTypeFormatter implements SubTypeFormatter {
if ("discriminator" in annotations) {
const deref = derefType(type.getType());
if (deref instanceof UnionType) {
deref.setDiscriminator(annotations.discriminator);
deref.setDiscriminator(annotations.discriminator as string);
delete annotations.discriminator;
} else {
throw new JsonTypeError(
Expand Down
7 changes: 1 addition & 6 deletions src/Utils/narrowType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ import { derefType } from "./derefType.js";
* kept, when returning false it is removed.
* @return The narrowed down type.
*/
export function narrowType(
type: BaseType,
// TODO: remove the next line
// eslint-disable-next-line no-shadow
predicate: (type: BaseType) => boolean,
): BaseType {
export function narrowType(type: BaseType, predicate: (type: BaseType) => boolean): BaseType {
const derefed = derefType(type);
if (derefed instanceof UnionType || derefed instanceof EnumType) {
let changed = false;
Expand Down
4 changes: 3 additions & 1 deletion src/Utils/nodeKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import stringify from "safe-stable-stringify";
import type { Node } from "typescript";
import type { Context } from "../NodeParser.js";

export function hash(a: string | boolean | number | (string | boolean | number)[] | object): string | number {
export function hash(
a: string | boolean | number | (string | boolean | number | Record<string, unknown>)[] | Record<string, unknown>,
): string | number {
if (typeof a === "number") {
return a;
}
Expand Down
29 changes: 16 additions & 13 deletions test/config/full-description/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
"type": "string"
},
"MyNonEmptyArray<number>": {
"fullDescription": "@minItems 1",
"items": {
"type": "number"
},
"minItems": 1,
"fullDescription": "@minItems 1",
"type": "array"
}
},
"description": "Top-level interface: This interface is used to test the fullDescription output.\nIt includes various formatting quirks, inline tags such as {@link SomeReference }, and multiple JSDoc sections.",
"fullDescription": "@title Raw Test Schema Interface\n@description Top-level interface: This interface is used to test the fullDescription output.\nIt includes various formatting quirks, inline tags such as {@link SomeReference}, and multiple JSDoc sections.\n\n@markdownDescription **Markdown version:** Markdown description which should be <b>preserved</b>\n\nAdditional info: Top-level details should be completely preserved in raw form.",
"properties": {
"description": {
"description": "Some more examples: ```yaml name: description length: 42 ```",
"markdownDescription": "Some more examples:\n```yaml\nname: description\nlength: 42\n```",
"fullDescription": "Some more examples:\n```yaml\nname: description\nlength: 42\n```",
"markdownDescription": "Some more examples:\n```yaml\nname: description\nlength: 42\n```",
"title": "Inherited Title",
"type": "string"
},
Expand All @@ -35,8 +36,8 @@
"anyOf": [
{
"$ref": "#/definitions/MyExportString",
"markdownDescription": "Some ignored comment description",
"fullDescription": "Some ignored comment description\n\n@description Export field description\n@default {\"length\": 10}\n@nullable"
"fullDescription": "Some ignored comment description\n\n@description Export field description\n@default {\"length\": 10}\n@nullable",
"markdownDescription": "Some ignored comment description"
},
{
"type": "null"
Expand All @@ -50,22 +51,22 @@
"inheritedDescription": {
"default": "",
"description": "Inherited description text.\n\nIt contains an inline link: {@link https://example.com} and additional commentary.",
"markdownDescription": "This is an inherited description.\n\nIt may include multiple at-tags:",
"fullDescription": "@default \"\"",
"markdownDescription": "This is an inherited description.\n\nIt may include multiple at-tags:",
"title": "Inherited Title",
"type": "string"
},
"initialText": {
"default": "42\n\nFurther comments in the same block should be preserved entirely.",
"description": "Field with initial untagged text followed by a tag.",
"markdownDescription": "Some initial descriptive text that is not tagged.",
"fullDescription": "Some initial descriptive text that is not tagged.\n\n@description Field with initial untagged text followed by a tag.\n@default 42\n\nFurther comments in the same block should be preserved entirely.",
"markdownDescription": "Some initial descriptive text that is not tagged.",
"type": "number"
},
"markdownField": {
"description": "This field tests `inline code` and <b>bold text</b>.\n\nAlso includes an inline link: {@link https://example.com} and additional commentary.",
"markdownDescription": "Some *code block*:\n```yaml\nname: description\nlength: 42\n```\n\nSome list:\n- one\n- two\n- and three...",
"fullDescription": "Some *code block*:\n```yaml\nname: description\nlength: 42\n```\n\nSome list:\n- one\n- two\n- and three...\n\n@description This field tests `inline code` and <b>bold text</b>.\n\nAlso includes an inline link: {@link https://example.com} and additional commentary.",
"markdownDescription": "Some *code block*:\n```yaml\nname: description\nlength: 42\n```\n\nSome list:\n- one\n- two\n- and three...",
"type": "string"
},
"multilineField": {
Expand All @@ -80,13 +81,16 @@
},
"noTagField": {
"description": "This field has a comment without explicit tags. It includes an inline reference: {@link ExampleReference } and extra text on several lines.\n\nThe raw output should preserve this whole block as is.",
"markdownDescription": "This field has a comment without explicit tags.\nIt includes an inline reference: {@link ExampleReference } and extra text on several lines.\n\nThe raw output should preserve this whole block as is.",
"fullDescription": "This field has a comment without explicit tags.\nIt includes an inline reference: {@link ExampleReference} and extra text on several lines.\n\nThe raw output should preserve this whole block as is.",
"markdownDescription": "This field has a comment without explicit tags.\nIt includes an inline reference: {@link ExampleReference } and extra text on several lines.\n\nThe raw output should preserve this whole block as is.",
"type": "boolean"
},
"number": {
"fullDescription": "@nullable",
"type": ["number", "null"]
"type": [
"number",
"null"
]
},
"numberArray": {
"$ref": "#/definitions/MyNonEmptyArray%3Cnumber%3E",
Expand All @@ -95,14 +99,14 @@
},
"oneLineJsDoc": {
"description": "Some text",
"markdownDescription": "Some text",
"fullDescription": "Some text",
"markdownDescription": "Some text",
"type": "string"
},
"oneLineJsDocComplex": {
"description": "Some *text* - {@link https://example.com } -",
"markdownDescription": "Some *text* - {@link https://example.com } -",
"fullDescription": "Some *text* - {@link https://example.com} - @see the `link`",
"markdownDescription": "Some *text* - {@link https://example.com } -",
"type": "string"
},
"privateString": {
Expand All @@ -120,8 +124,8 @@
},
"specialFormat": {
"description": "Extra spaces and indentation should be preserved.",
"pattern": "/^\\w+$/",
"fullDescription": "@title Field with Special Formatting\n@description Extra spaces and indentation should be preserved.\n\n@pattern /^\\w+$/",
"pattern": "/^\\w+$/",
"title": "Field with Special Formatting",
"type": "string"
},
Expand All @@ -137,7 +141,6 @@
"type": "string"
}
},
"fullDescription": "@title Raw Test Schema Interface\n@description Top-level interface: This interface is used to test the fullDescription output.\nIt includes various formatting quirks, inline tags such as {@link SomeReference}, and multiple JSDoc sections.\n\n@markdownDescription **Markdown version:** Markdown description which should be <b>preserved</b>\n\nAdditional info: Top-level details should be completely preserved in raw form.",
"required": [
"singleLine",
"multilineField",
Expand Down
28 changes: 14 additions & 14 deletions test/config/multiple-types-all/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"MyObject1": {
"additionalProperties": false,
"properties": {
"id": {
"type": "number"
},
"bar": {
"$ref": "#/definitions/Object1Prop"
},
"id": {
"type": "number"
}
},
"required": [
"id",
"bar"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"MyObject2": {
"additionalProperties": false,
"properties": {
"idStr": {
"type": "string"
},
"baz": {
"$ref": "#/definitions/Object2Prop"
},
"idStr": {
"type": "string"
}
},
"required": [
"idStr",
"baz"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"Object1Prop": {
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
Expand All @@ -42,10 +43,10 @@
"required": [
"name"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"Object2Prop": {
"additionalProperties": false,
"properties": {
"description": {
"type": "string"
Expand All @@ -54,8 +55,7 @@
"required": [
"description"
],
"type": "object",
"additionalProperties": false
"type": "object"
}
}
}
28 changes: 14 additions & 14 deletions test/config/multiple-types/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"MyObject1": {
"additionalProperties": false,
"properties": {
"id": {
"type": "number"
},
"bar": {
"$ref": "#/definitions/Object1Prop"
},
"id": {
"type": "number"
}
},
"required": [
"id",
"bar"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"MyObject2": {
"additionalProperties": false,
"properties": {
"idStr": {
"type": "string"
},
"baz": {
"additionalProperties": false,
"properties": {
"description": {
"type": "string"
Expand All @@ -31,18 +30,20 @@
"required": [
"description"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"idStr": {
"type": "string"
}
},
"required": [
"idStr",
"baz"
],
"type": "object",
"additionalProperties": false
"type": "object"
},
"Object1Prop": {
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
Expand All @@ -51,8 +52,7 @@
"required": [
"name"
],
"type": "object",
"additionalProperties": false
"type": "object"
}
}
}
Loading
Loading