From 06bcafc56c92559d9ddec85a5177015b761d583b Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Thu, 1 Aug 2024 00:48:50 +0900 Subject: [PATCH] Fix #1188: invalid JSON schema about tuple type. --- benchmark/package.json | 2 +- debug/features/enum.ts | 39 -- debug/features/internal/TestValidator.ts | 47 -- debug/features/join.ts | 9 - debug/features/tuple.ts | 7 + debug/package.json | 2 +- errors/package.json | 2 +- package.json | 2 +- packages/typescript-json/package.json | 4 +- .../internal/application_v31_tuple.ts | 2 +- test-esm/package.json | 2 +- test/package.json | 2 +- test/schemas/json/v3_1/ArrayAtomicAlias.json | 4 +- test/schemas/json/v3_1/ArrayAtomicSimple.json | 7 +- .../v3_1/ArrayRepeatedUnionWithTuple.json | 8 +- test/schemas/json/v3_1/AtomicAlias.json | 4 +- test/schemas/json/v3_1/AtomicClass.json | 4 +- .../schemas/json/v3_1/AtomicIntersection.json | 4 +- test/schemas/json/v3_1/AtomicSimple.json | 4 +- .../json/v3_1/ConstantAtomicSimple.json | 4 +- .../json/v3_1/ConstantAtomicWrapper.json | 4 +- .../json/v3_1/ConstantIntersection.json | 4 +- test/schemas/json/v3_1/ObjectGeneric.json | 4 +- .../schemas/json/v3_1/ObjectHierarchical.json | 4 +- .../json/v3_1/ObjectPropertyNullable.json | 7 +- test/schemas/json/v3_1/ObjectTuple.json | 4 +- test/schemas/json/v3_1/ToJsonArray.json | 7 +- .../schemas/json/v3_1/ToJsonAtomicSimple.json | 4 +- test/schemas/json/v3_1/ToJsonTuple.json | 4 +- test/schemas/json/v3_1/TupleHierarchical.json | 422 +----------------- test/schemas/json/v3_1/TupleRestArray.json | 7 +- test/schemas/json/v3_1/TupleRestAtomic.json | 4 +- test/schemas/json/v3_1/TupleRestObject.json | 15 +- test/schemas/json/v3_1/TypeTagTuple.json | 11 +- .../test_issue_1188_json_schema_tuple_type.ts | 22 + website/package-lock.json | 53 ++- website/package.json | 10 +- 37 files changed, 127 insertions(+), 618 deletions(-) delete mode 100644 debug/features/enum.ts delete mode 100644 debug/features/internal/TestValidator.ts delete mode 100644 debug/features/join.ts create mode 100644 debug/features/tuple.ts create mode 100644 test/src/features/issues/test_issue_1188_json_schema_tuple_type.ts diff --git a/benchmark/package.json b/benchmark/package.json index 2318b0d949..890efdae0f 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -72,6 +72,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.6.1.tgz" + "typia": "../typia-6.6.2.tgz" } } \ No newline at end of file diff --git a/debug/features/enum.ts b/debug/features/enum.ts deleted file mode 100644 index dcb6fd5959..0000000000 --- a/debug/features/enum.ts +++ /dev/null @@ -1,39 +0,0 @@ -import typia from "typia"; - -import { TestValidator } from "./internal/TestValidator"; - -const app = typia.json.application<[ConstEnum]>(); -console.log(app.components.schemas?.ConstEnum); - -TestValidator.equals("enum-description")(app.components.schemas?.ConstEnum)({ - oneOf: [ - { - const: 1, - title: "The value one", - description: - "The value one.\n\nThe value one defined in the constant enumeration.", - }, - { - const: 2, - title: "The value two", - description: - "The value two.\n\nThe value two defined in the constant enumeration.", - }, - ], -}); - -const enum ConstEnum { - /** - * The value one. - * - * The value one defined in the constant enumeration. - */ - ONE = 1, - - /** - * The value two. - * - * The value two defined in the constant enumeration. - */ - TWO = 2, -} diff --git a/debug/features/internal/TestValidator.ts b/debug/features/internal/TestValidator.ts deleted file mode 100644 index a2d533e47a..0000000000 --- a/debug/features/internal/TestValidator.ts +++ /dev/null @@ -1,47 +0,0 @@ -export namespace TestValidator { - export const equals = - (title: string, exception: (key: string) => boolean = () => false) => - (x: T) => - (y: T) => { - const diff: string[] = json_equal_to(exception)(x)(y); - if (diff.length) - throw new Error( - `Bug on ${title}: found different values - [${diff.join(", ")}]`, - ); - }; -} - -const json_equal_to = - (exception: (key: string) => boolean) => - (x: T) => - (y: T): string[] => { - const container: string[] = []; - const iterate = - (accessor: string) => - (x: any) => - (y: any): void => { - if (typeof x !== typeof y) container.push(accessor); - else if (x instanceof Array) - if (!(y instanceof Array)) container.push(accessor); - else array(accessor)(x)(y); - else if (x instanceof Object) object(accessor)(x)(y); - else if (x !== y) container.push(accessor); - }; - const array = - (accessor: string) => - (x: any[]) => - (y: any[]): void => { - if (x.length !== y.length) container.push(`${accessor}.length`); - x.forEach((xItem, i) => iterate(`${accessor}[${i}]`)(xItem)(y[i])); - }; - const object = - (accessor: string) => - (x: any) => - (y: any): void => - Object.keys(x) - .filter((key) => x[key] !== undefined && !exception(key)) - .forEach((key) => iterate(`${accessor}.${key}`)(x[key])(y[key])); - - iterate("")(x)(y); - return container; - }; diff --git a/debug/features/join.ts b/debug/features/join.ts deleted file mode 100644 index 62adb9ab9b..0000000000 --- a/debug/features/join.ts +++ /dev/null @@ -1,9 +0,0 @@ -import typia from "typia"; - -interface Foo { - paths?: { - [from: string]: [string]; - }; -} - -console.log(typia.createAssert().toString()); diff --git a/debug/features/tuple.ts b/debug/features/tuple.ts new file mode 100644 index 0000000000..c0cd3aa386 --- /dev/null +++ b/debug/features/tuple.ts @@ -0,0 +1,7 @@ +import typia from "typia"; + +console.log( + typia.json.application<[[number, string]], "3.0">().schemas[0], + typia.json.application<[[number, string]], "3.1">().schemas[0], + typia.json.application<[[number, string, ...boolean[]]], "3.1">().schemas[0], +); diff --git a/debug/package.json b/debug/package.json index 33baeaf943..f301bfd8e7 100644 --- a/debug/package.json +++ b/debug/package.json @@ -16,6 +16,6 @@ "typescript": "^5.4.2" }, "dependencies": { - "typia": "../typia-6.6.0-dev.20240727.tgz" + "typia": "../typia-6.6.1.tgz" } } \ No newline at end of file diff --git a/errors/package.json b/errors/package.json index 476546f2da..6bc002b827 100644 --- a/errors/package.json +++ b/errors/package.json @@ -32,6 +32,6 @@ "typescript": "^5.3.2" }, "dependencies": { - "typia": "../typia-6.6.1.tgz" + "typia": "../typia-6.6.2.tgz" } } \ No newline at end of file diff --git a/package.json b/package.json index 65547f4586..6d3b30ef4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "6.6.1", + "version": "6.6.2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/typescript-json/package.json b/packages/typescript-json/package.json index 5a2b4e7350..e67de7640a 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "6.6.1", + "version": "6.6.2", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -63,7 +63,7 @@ }, "homepage": "https://typia.io", "dependencies": { - "typia": "6.6.1" + "typia": "6.6.2" }, "peerDependencies": { "typescript": ">=4.8.0 <5.6.0" diff --git a/src/programmers/internal/application_v31_tuple.ts b/src/programmers/internal/application_v31_tuple.ts index 6909e543c3..426abad342 100644 --- a/src/programmers/internal/application_v31_tuple.ts +++ b/src/programmers/internal/application_v31_tuple.ts @@ -9,7 +9,7 @@ import { MetadataTuple } from "../../schemas/metadata/MetadataTuple"; export const application_v31_tuple = (generator: (meta: Metadata) => OpenApi.IJsonSchema) => (tuple: MetadataTuple): OpenApi.IJsonSchema.ITuple => { - const tail: Metadata | undefined = tuple.type.elements.at(-1); + const tail: Metadata | null = tuple.type.elements.at(-1)?.rest ?? null; const prefixItems: Metadata[] = tuple.type.isRest() ? tuple.type.elements.slice(0, -1) : tuple.type.elements; diff --git a/test-esm/package.json b/test-esm/package.json index cafa592ea3..b55e10a027 100644 --- a/test-esm/package.json +++ b/test-esm/package.json @@ -36,6 +36,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "typia": "../typia-6.6.1.tgz" + "typia": "../typia-6.6.2.tgz" } } \ No newline at end of file diff --git a/test/package.json b/test/package.json index b34ade671a..15a2f9a1a8 100644 --- a/test/package.json +++ b/test/package.json @@ -51,6 +51,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-6.6.1.tgz" + "typia": "../typia-6.6.2.tgz" } } \ No newline at end of file diff --git a/test/schemas/json/v3_1/ArrayAtomicAlias.json b/test/schemas/json/v3_1/ArrayAtomicAlias.json index 0e7057b019..7c4928b4e8 100644 --- a/test/schemas/json/v3_1/ArrayAtomicAlias.json +++ b/test/schemas/json/v3_1/ArrayAtomicAlias.json @@ -15,9 +15,7 @@ "$ref": "#/components/schemas/ArrayAtomicAlias.Aliasstring" } ], - "additionalItems": { - "$ref": "#/components/schemas/ArrayAtomicAlias.Aliasstring" - } + "additionalItems": false }, "ArrayAtomicAlias.Aliasboolean": { "type": "array", diff --git a/test/schemas/json/v3_1/ArrayAtomicSimple.json b/test/schemas/json/v3_1/ArrayAtomicSimple.json index b6a0217ea9..27d6a95cab 100644 --- a/test/schemas/json/v3_1/ArrayAtomicSimple.json +++ b/test/schemas/json/v3_1/ArrayAtomicSimple.json @@ -24,12 +24,7 @@ } } ], - "additionalItems": { - "type": "array", - "items": { - "type": "string" - } - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/ArrayRepeatedUnionWithTuple.json b/test/schemas/json/v3_1/ArrayRepeatedUnionWithTuple.json index 67a88c6b47..fcf22cdf4d 100644 --- a/test/schemas/json/v3_1/ArrayRepeatedUnionWithTuple.json +++ b/test/schemas/json/v3_1/ArrayRepeatedUnionWithTuple.json @@ -38,9 +38,7 @@ "type": "boolean" } ], - "additionalItems": { - "type": "boolean" - } + "additionalItems": false }, { "type": "array", @@ -52,9 +50,7 @@ "$ref": "#/components/schemas/ArrayRepeatedUnionWithTuple.IPoint3D" } ], - "additionalItems": { - "$ref": "#/components/schemas/ArrayRepeatedUnionWithTuple.IPoint3D" - } + "additionalItems": false } ] }, diff --git a/test/schemas/json/v3_1/AtomicAlias.json b/test/schemas/json/v3_1/AtomicAlias.json index d23665d7d2..72cc211346 100644 --- a/test/schemas/json/v3_1/AtomicAlias.json +++ b/test/schemas/json/v3_1/AtomicAlias.json @@ -15,9 +15,7 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/AtomicClass.json b/test/schemas/json/v3_1/AtomicClass.json index 68742a43c0..d3bcd5f231 100644 --- a/test/schemas/json/v3_1/AtomicClass.json +++ b/test/schemas/json/v3_1/AtomicClass.json @@ -33,9 +33,7 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/AtomicIntersection.json b/test/schemas/json/v3_1/AtomicIntersection.json index fc7b721469..95de9c164e 100644 --- a/test/schemas/json/v3_1/AtomicIntersection.json +++ b/test/schemas/json/v3_1/AtomicIntersection.json @@ -15,9 +15,7 @@ "$ref": "#/components/schemas/AtomicIntersection.Wrapperstring" } ], - "additionalItems": { - "$ref": "#/components/schemas/AtomicIntersection.Wrapperstring" - } + "additionalItems": false }, "AtomicIntersection.Wrapperboolean": { "type": "boolean" diff --git a/test/schemas/json/v3_1/AtomicSimple.json b/test/schemas/json/v3_1/AtomicSimple.json index cd6b4b899e..53a74debee 100644 --- a/test/schemas/json/v3_1/AtomicSimple.json +++ b/test/schemas/json/v3_1/AtomicSimple.json @@ -15,9 +15,7 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/ConstantAtomicSimple.json b/test/schemas/json/v3_1/ConstantAtomicSimple.json index 4c37a9ae9b..041e8d6940 100644 --- a/test/schemas/json/v3_1/ConstantAtomicSimple.json +++ b/test/schemas/json/v3_1/ConstantAtomicSimple.json @@ -18,9 +18,7 @@ "const": "three" } ], - "additionalItems": { - "const": "three" - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/ConstantAtomicWrapper.json b/test/schemas/json/v3_1/ConstantAtomicWrapper.json index c265514f89..cd1de59cdb 100644 --- a/test/schemas/json/v3_1/ConstantAtomicWrapper.json +++ b/test/schemas/json/v3_1/ConstantAtomicWrapper.json @@ -15,9 +15,7 @@ "$ref": "#/components/schemas/ConstantAtomicWrapper.IPointerstring" } ], - "additionalItems": { - "$ref": "#/components/schemas/ConstantAtomicWrapper.IPointerstring" - } + "additionalItems": false }, "ConstantAtomicWrapper.IPointerboolean": { "type": "object", diff --git a/test/schemas/json/v3_1/ConstantIntersection.json b/test/schemas/json/v3_1/ConstantIntersection.json index ef78edf7ed..0a139b0580 100644 --- a/test/schemas/json/v3_1/ConstantIntersection.json +++ b/test/schemas/json/v3_1/ConstantIntersection.json @@ -15,9 +15,7 @@ "$ref": "#/components/schemas/ConstantIntersection.Wrappertwo" } ], - "additionalItems": { - "$ref": "#/components/schemas/ConstantIntersection.Wrappertwo" - } + "additionalItems": false }, "ConstantIntersection.Wrapperfalse": { "const": false diff --git a/test/schemas/json/v3_1/ObjectGeneric.json b/test/schemas/json/v3_1/ObjectGeneric.json index 05ed71acb4..a4003fe4ff 100644 --- a/test/schemas/json/v3_1/ObjectGeneric.json +++ b/test/schemas/json/v3_1/ObjectGeneric.json @@ -15,9 +15,7 @@ "$ref": "#/components/schemas/ObjectGeneric.ISomethingstring" } ], - "additionalItems": { - "$ref": "#/components/schemas/ObjectGeneric.ISomethingstring" - } + "additionalItems": false }, "ObjectGeneric.ISomethingboolean": { "type": "object", diff --git a/test/schemas/json/v3_1/ObjectHierarchical.json b/test/schemas/json/v3_1/ObjectHierarchical.json index 72c7128b7b..5d4777594a 100644 --- a/test/schemas/json/v3_1/ObjectHierarchical.json +++ b/test/schemas/json/v3_1/ObjectHierarchical.json @@ -53,9 +53,7 @@ "type": "number" } ], - "additionalItems": { - "type": "number" - } + "additionalItems": false }, "created_at": { "$ref": "#/components/schemas/ObjectHierarchical.ITimestamp" diff --git a/test/schemas/json/v3_1/ObjectPropertyNullable.json b/test/schemas/json/v3_1/ObjectPropertyNullable.json index 4d3332c897..aaf3efbe6a 100644 --- a/test/schemas/json/v3_1/ObjectPropertyNullable.json +++ b/test/schemas/json/v3_1/ObjectPropertyNullable.json @@ -30,12 +30,7 @@ } } ], - "additionalItems": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ObjectPropertyNullable.IPointerObjectPropertyNullable.IMember" - } - } + "additionalItems": false }, "ObjectPropertyNullable.IPointerboolean": { "type": "object", diff --git a/test/schemas/json/v3_1/ObjectTuple.json b/test/schemas/json/v3_1/ObjectTuple.json index 272abc87e1..28ac7e4f41 100644 --- a/test/schemas/json/v3_1/ObjectTuple.json +++ b/test/schemas/json/v3_1/ObjectTuple.json @@ -12,9 +12,7 @@ "$ref": "#/components/schemas/ObjectTuple.ICitizen" } ], - "additionalItems": { - "$ref": "#/components/schemas/ObjectTuple.ICitizen" - } + "additionalItems": false }, "ObjectTuple.ISection": { "type": "object", diff --git a/test/schemas/json/v3_1/ToJsonArray.json b/test/schemas/json/v3_1/ToJsonArray.json index 84c7ec4808..6882e6ddbd 100644 --- a/test/schemas/json/v3_1/ToJsonArray.json +++ b/test/schemas/json/v3_1/ToJsonArray.json @@ -30,12 +30,7 @@ } } ], - "additionalItems": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ToJsonArray.IObject" - } - } + "additionalItems": false }, "ToJsonArray.IObject": { "type": "object", diff --git a/test/schemas/json/v3_1/ToJsonAtomicSimple.json b/test/schemas/json/v3_1/ToJsonAtomicSimple.json index 8d770b84c7..bccdf88270 100644 --- a/test/schemas/json/v3_1/ToJsonAtomicSimple.json +++ b/test/schemas/json/v3_1/ToJsonAtomicSimple.json @@ -15,9 +15,7 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/ToJsonTuple.json b/test/schemas/json/v3_1/ToJsonTuple.json index cd5d3596bd..12247ed587 100644 --- a/test/schemas/json/v3_1/ToJsonTuple.json +++ b/test/schemas/json/v3_1/ToJsonTuple.json @@ -18,9 +18,7 @@ "$ref": "#/components/schemas/ToJsonTuple.IObject" } ], - "additionalItems": { - "$ref": "#/components/schemas/ToJsonTuple.IObject" - } + "additionalItems": false }, "ToJsonTuple.IObject": { "$ref": "#/components/schemas/ToJsonTuple.IHobby" diff --git a/test/schemas/json/v3_1/TupleHierarchical.json b/test/schemas/json/v3_1/TupleHierarchical.json index 2d278658b2..49ab8af638 100644 --- a/test/schemas/json/v3_1/TupleHierarchical.json +++ b/test/schemas/json/v3_1/TupleHierarchical.json @@ -39,63 +39,13 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } + "additionalItems": false } ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } + "additionalItems": false }, { "type": "array", @@ -135,377 +85,21 @@ "type": "string" } ], - "additionalItems": { - "type": "string" - } + "additionalItems": false } ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } + "additionalItems": false } } ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } + "additionalItems": false } } ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "string" - }, - { - "type": "boolean" - }, - { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - } - } + "additionalItems": false } ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "string" - }, - { - "type": "boolean" - }, - { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - } - } - ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "string" - }, - { - "type": "boolean" - }, - { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - ], - "additionalItems": { - "type": "array", - "items": { - "type": "array", - "prefixItems": [ - { - "type": "number" - }, - { - "type": "number" - }, - { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - ], - "additionalItems": { - "type": "array", - "prefixItems": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ], - "additionalItems": { - "type": "string" - } - } - } - } - } - } - } + "additionalItems": false } } }, diff --git a/test/schemas/json/v3_1/TupleRestArray.json b/test/schemas/json/v3_1/TupleRestArray.json index 156d4372b8..03e96f6ac9 100644 --- a/test/schemas/json/v3_1/TupleRestArray.json +++ b/test/schemas/json/v3_1/TupleRestArray.json @@ -12,7 +12,12 @@ "type": "number" } ], - "additionalItems": {} + "additionalItems": { + "type": "array", + "items": { + "type": "string" + } + } } } }, diff --git a/test/schemas/json/v3_1/TupleRestAtomic.json b/test/schemas/json/v3_1/TupleRestAtomic.json index 315726bb94..9c676ea039 100644 --- a/test/schemas/json/v3_1/TupleRestAtomic.json +++ b/test/schemas/json/v3_1/TupleRestAtomic.json @@ -12,7 +12,9 @@ "type": "number" } ], - "additionalItems": {} + "additionalItems": { + "type": "string" + } } } }, diff --git a/test/schemas/json/v3_1/TupleRestObject.json b/test/schemas/json/v3_1/TupleRestObject.json index e28e9c6f37..e8964803f4 100644 --- a/test/schemas/json/v3_1/TupleRestObject.json +++ b/test/schemas/json/v3_1/TupleRestObject.json @@ -12,7 +12,20 @@ "type": "number" } ], - "additionalItems": {} + "additionalItems": { + "$ref": "#/components/schemas/TupleRestObject.IObject" + } + }, + "TupleRestObject.IObject": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + }, + "required": [ + "value" + ] } } }, diff --git a/test/schemas/json/v3_1/TypeTagTuple.json b/test/schemas/json/v3_1/TypeTagTuple.json index 486f236f07..cc3ce0f5c4 100644 --- a/test/schemas/json/v3_1/TypeTagTuple.json +++ b/test/schemas/json/v3_1/TypeTagTuple.json @@ -39,16 +39,7 @@ "maxItems": 7 } ], - "additionalItems": { - "type": "array", - "items": { - "type": "number", - "minimum": 1, - "maximum": 2 - }, - "minItems": 3, - "maxItems": 7 - } + "additionalItems": false } }, "required": [ diff --git a/test/src/features/issues/test_issue_1188_json_schema_tuple_type.ts b/test/src/features/issues/test_issue_1188_json_schema_tuple_type.ts new file mode 100644 index 0000000000..d12e7f88dd --- /dev/null +++ b/test/src/features/issues/test_issue_1188_json_schema_tuple_type.ts @@ -0,0 +1,22 @@ +import typia from "typia"; + +import { TestValidator } from "../../helpers/TestValidator"; + +export const test_issue_1188_json_schema_tuple_type = (): void => { + TestValidator.equals("tuples")( + typia.json.application< + [[boolean, number], [boolean, number, ...string[]]] + >().schemas, + )([ + { + type: "array", + prefixItems: [{ type: "boolean" }, { type: "number" }], + additionalItems: false, + }, + { + type: "array", + prefixItems: [{ type: "boolean" }, { type: "number" }], + additionalItems: { type: "string" }, + }, + ]); +}; diff --git a/website/package-lock.json b/website/package-lock.json index f877f93dfd..26d7a95809 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -26,8 +26,8 @@ "react-dom": "^18.2.0", "tgrid": "^1.0.2", "tstl": "^3.0.0", - "typescript": "^5.5.2", - "typia": "^6.4.1" + "typescript": "^5.5.4", + "typia": "^6.6.1" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -41,6 +41,7 @@ "ts-loader": "^9.5.1", "ts-node": "^10.9.1", "typedoc": "^0.26.2", + "typedoc-github-theme": "^0.1.1", "webpack": "^5.90.3", "webpack-cli": "^5.1.4", "write-file-webpack-plugin": "^4.5.1" @@ -1373,9 +1374,9 @@ } }, "node_modules/@samchon/openapi": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@samchon/openapi/-/openapi-0.3.1.tgz", - "integrity": "sha512-vnKcQmteAGhB7goVpG++06Ut8ecwUpLN+QOmpaAoE4ByL8AqQ/rgCVWvPJw9syN+DlaDMuzmmOvJct0XicoENA==" + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@samchon/openapi/-/openapi-0.4.3.tgz", + "integrity": "sha512-FyXEYRD/y9YND1AkpshAzdGpp/zKAIHI7RNrH4rnjaJP2hi2Yqz8OXquTW3PUOnqlos3jSwR3b2nKLohyTjp6w==" }, "node_modules/@shikijs/core": { "version": "1.9.1", @@ -8780,15 +8781,15 @@ } }, "node_modules/typedoc": { - "version": "0.26.2", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.2.tgz", - "integrity": "sha512-q/t+M+PZqhN9gPWLBZ3CCvP+KT8O1tyYkSzEYbcQ6mo89avdIrMlBEl3vfo5BgSzwC6Lbmq0W64E8RkY+eVsLA==", + "version": "0.26.5", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", + "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", "dev": true, "dependencies": { "lunr": "^2.3.9", "markdown-it": "^14.1.0", - "minimatch": "^9.0.4", - "shiki": "^1.9.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", "yaml": "^2.4.5" }, "bin": { @@ -8801,6 +8802,18 @@ "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" } }, + "node_modules/typedoc-github-theme": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/typedoc-github-theme/-/typedoc-github-theme-0.1.1.tgz", + "integrity": "sha512-dXb4dFn+rX3Wrfwl8SAVkk13o1aTWhvMdUIJ5Hk9zaIMJ6Uqf6HbPkdeGg2feHAg4F1qE/0AjeGrywxxNyQhMg==", + "dev": true, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "typedoc": "^0.26.4" + } + }, "node_modules/typedoc/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -8811,9 +8824,9 @@ } }, "node_modules/typedoc/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -8847,9 +8860,9 @@ } }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8859,11 +8872,11 @@ } }, "node_modules/typia": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/typia/-/typia-6.4.1.tgz", - "integrity": "sha512-1cDcPQ5AayEkKKHFa2sPczljB80v1e10zj+DVCGn9uxcAcUwxEEXm34emBJMT5q4dhwUGwzfk0GoxK2/OeNi6w==", + "version": "6.6.1", + "resolved": "https://registry.npmjs.org/typia/-/typia-6.6.1.tgz", + "integrity": "sha512-fK8dBwBtgV0jFqJiaVNzzWqLPwh3TNAP2mshQO00SjAVGpYxMUJA5PqqR9VYVNfXGhlWCpmaCuyviX8wJ0Sq9Q==", "dependencies": { - "@samchon/openapi": "^0.3.1", + "@samchon/openapi": "^0.4.3", "commander": "^10.0.0", "comment-json": "^4.2.3", "inquirer": "^8.2.5", diff --git a/website/package.json b/website/package.json index 53d69b1d91..98f22242f1 100644 --- a/website/package.json +++ b/website/package.json @@ -4,10 +4,11 @@ "description": "Typia Guide Documents", "private": true, "scripts": { - "build": "rimraf .next && rimraf out && typedoc && next build && next-sitemap", + "build": "rimraf .next && rimraf out && npm run build:typedoc && next build && next-sitemap", + "build:typedoc": "typedoc --plugin typedoc-github-theme --theme typedoc-github-theme", "deploy": "node build/deploy", "dev": "next dev", - "prepare": "node build/raw && webpack && typedoc" + "prepare": "node build/raw && webpack && npm run build:typedoc" }, "repository": { "type": "git", @@ -34,10 +35,10 @@ "prettier": "^3.2.5", "react": "^18.2.0", "react-dom": "^18.2.0", - "tgrid": "^1.0.2", + "tgrid": "^1.0.3", "tstl": "^3.0.0", "typescript": "^5.5.4", - "typia": "^6.6.1" + "typia": "^6.6.2" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", @@ -51,6 +52,7 @@ "ts-loader": "^9.5.1", "ts-node": "^10.9.1", "typedoc": "^0.26.2", + "typedoc-github-theme": "^0.1.1", "webpack": "^5.90.3", "webpack-cli": "^5.1.4", "write-file-webpack-plugin": "^4.5.1"