Skip to content

Commit

Permalink
Merge pull request #844 from samchon/features/swagger
Browse files Browse the repository at this point in the history
Close #823 - ban Map types on JSON functions.
  • Loading branch information
samchon authored Oct 12, 2023
2 parents 7b6d0f9 + 786b5ac commit 6d30759
Show file tree
Hide file tree
Showing 367 changed files with 593 additions and 42,908 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Check out the document in the [website](https://typia.io/docs/):
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
- [`encode()` functions](https://typia.io/docs/protobuf/encode/)
- [Random Generator](https://typia.io/docs/random/)
- [Miscellaneous](https://typia.io/docs/miscellaneous/)
- [Miscellaneous](https://typia.io/docs/misc/)

### 🔗 Appendix
- Utillization Cases
Expand Down
35 changes: 35 additions & 0 deletions errors/src/json/error_json_map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import typia from "typia";

interface IPointer<T> {
value: T;
}

// JSON SCHEMA
typia.json.application<[Map<any, any>]>();
typia.json.application<[[Map<any, any>, Map<any, any>]]>();
typia.json.application<[Map<any, any>[]]>();
typia.json.application<[Record<string, Map<any, any>>]>();
typia.json.application<[IPointer<Map<any, any>>]>();
typia.json.application<[IPointer<[Map<any, any>, Map<any, any>]>]>();
typia.json.application<[IPointer<Map<any, any>[]>]>();
typia.json.application<[IPointer<Record<string, Map<any, any>>>]>();

// ENCODE
typia.json.createStringify<Map<any, any>>();
typia.json.createStringify<[Map<any, any>, Map<any, any>]>();
typia.json.createStringify<Map<any, any>[]>();
typia.json.createStringify<Record<string, Map<any, any>>>();
typia.json.createStringify<IPointer<Map<any, any>>>();
typia.json.createStringify<IPointer<[Map<any, any>, Map<any, any>]>>();
typia.json.createStringify<IPointer<Map<any, any>[]>>();
typia.json.createStringify<IPointer<Record<string, Map<any, any>>>>();

// DECODE
typia.json.createAssertParse<Map<any, any>>();
typia.json.createAssertParse<[Map<any, any>, Map<any, any>]>();
typia.json.createAssertParse<Map<any, any>[]>();
typia.json.createAssertParse<Record<string, Map<any, any>>>();
typia.json.createAssertParse<IPointer<Map<any, any>>>();
typia.json.createAssertParse<IPointer<[Map<any, any>, Map<any, any>]>>();
typia.json.createAssertParse<IPointer<Map<any, any>[]>>();
typia.json.createAssertParse<IPointer<Record<string, Map<any, any>>>>();
471 changes: 471 additions & 0 deletions errors/src/json/error_json_native.ts

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions errors/src/json/error_json_set.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import typia from "typia";

interface IPointer<T> {
value: T;
}

// JSON SCHEMA
typia.json.application<[Set<any>]>();
typia.json.application<[[Set<any>, Set<any>]]>();
typia.json.application<[Set<any>[]]>();
typia.json.application<[Record<string, Set<any>>]>();
typia.json.application<[IPointer<Set<any>>]>();
typia.json.application<[IPointer<[Set<any>, Set<any>]>]>();
typia.json.application<[IPointer<Set<any>[]>]>();
typia.json.application<[IPointer<Record<string, Set<any>>>]>();

// ENCODE
typia.json.createStringify<Set<any>>();
typia.json.createStringify<[Set<any>, Set<any>]>();
typia.json.createStringify<Set<any>[]>();
typia.json.createStringify<Record<string, Set<any>>>();
typia.json.createStringify<IPointer<Set<any>>>();
typia.json.createStringify<IPointer<[Set<any>, Set<any>]>>();
typia.json.createStringify<IPointer<Set<any>[]>>();
typia.json.createStringify<IPointer<Record<string, Set<any>>>>();

// DECODE
typia.json.createAssertParse<Set<any>>();
typia.json.createAssertParse<[Set<any>, Set<any>]>();
typia.json.createAssertParse<Set<any>[]>();
typia.json.createAssertParse<Record<string, Set<any>>>();
typia.json.createAssertParse<IPointer<Set<any>>>();
typia.json.createAssertParse<IPointer<[Set<any>, Set<any>]>>();
typia.json.createAssertParse<IPointer<Set<any>[]>>();
typia.json.createAssertParse<IPointer<Record<string, Set<any>>>>();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "5.2.2-dev.20231012",
"version": "5.2.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Check out the document in the [website](https://typia.io/docs/):
- [`decode()` functions](https://typia.io/docs/protobuf/decode/)
- [`encode()` functions](https://typia.io/docs/protobuf/encode/)
- [Random Generator](https://typia.io/docs/random/)
- [Miscellaneous](https://typia.io/docs/miscellaneous/)
- [Miscellaneous](https://typia.io/docs/misc/)

### 🔗 Appendix
- Utillization Cases
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "5.2.2-dev.20231012",
"version": "5.2.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -72,7 +72,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "5.2.2-dev.20231012"
"typia": "5.2.2"
},
"peerDependencies": {
"typescript": ">= 4.8.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Primitive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type PrimitiveMain<Instance> = Instance extends [never]
: ValueOf<Instance> extends object
? Instance extends object
? Instance extends NativeClass
? {}
? never
: Instance extends IJsonable<infer Raw>
? ValueOf<Raw> extends object
? Raw extends object
Expand Down
7 changes: 7 additions & 0 deletions src/factories/JsonMetadataFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import ts from "typescript";

import { Metadata } from "../schemas/metadata/Metadata";

import { AtomicPredicator } from "../programmers/helpers/AtomicPredicator";

import { TransformerError } from "../transformers/TransformerError";

import { MetadataCollection } from "./MetadataCollection";
Expand Down Expand Up @@ -38,6 +40,11 @@ export namespace JsonMetadataFactory {
meta.arrays.some((a) => a.type.value.isRequired() === false)
)
output.push("JSON does not support undefined type in array.");
if (meta.maps.length) output.push("JSON does not support Map type.");
if (meta.sets.length) output.push("JSON does not support Set type.");
for (const native of meta.natives)
if (AtomicPredicator.native(native) === false && native !== "Date")
output.push(`JSON does not support ${native} type.`);
return output;
};
}
2 changes: 1 addition & 1 deletion src/programmers/helpers/AtomicPredicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export namespace AtomicPredicator {
!ArrayUtil.has(meta.atomics, (a) => a.type === "string");
}

const LIKE = new Set(["boolean", "number", "string"]);
const LIKE = new Set(["boolean", "bigint", "number", "string"]);

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6d30759

Please sign in to comment.