Skip to content

Commit

Permalink
Add tags.Example type with @samchon/openapi upgrading.
Browse files Browse the repository at this point in the history
Upgraded `@samchon/openapi` to the latest version (`1.0.5`) and added `tags.Example` and `tags.Examples` types for following the `@samchon/openapi`'s newly added properties.

samchon/openapi#54
  • Loading branch information
samchon committed Sep 25, 2024
1 parent 771de43 commit 16cff2d
Show file tree
Hide file tree
Showing 16 changed files with 1,846 additions and 273 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.2-dev.20240920.tgz"
"typia": "../typia-6.10.3-dev.20240925.tgz"
}
}
3 changes: 2 additions & 1 deletion debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"typescript": "^5.4.2"
},
"dependencies": {
"@samchon/openapi": "^1.0.5",
"tstl": "^3.0.0",
"typia": "../typia-6.10.2-dev.20240920.tgz",
"typia": "../typia-6.10.2.tgz",
"uuid": "^10.0.0"
}
}
12 changes: 12 additions & 0 deletions debug/src/llm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ILlmApplication } from "@samchon/openapi";
import typia from "typia";

interface ICalculator {
/**
* @deprecated
*/
plus(x: number, y: number): number;
}

const app: ILlmApplication = typia.llm.application<ICalculator>();
console.log(app.functions[0]?.deprecated);
14 changes: 0 additions & 14 deletions debug/src/random.ts

This file was deleted.

2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.10.2-dev.20240920.tgz"
"typia": "../typia-6.10.3-dev.20240925.tgz"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "6.10.2",
"version": "6.10.3-dev.20240925",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -67,7 +67,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"@samchon/openapi": "^1.0.2",
"@samchon/openapi": "^1.0.5",
"commander": "^10.0.0",
"comment-json": "^4.2.3",
"inquirer": "^8.2.5",
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": "6.10.2-dev.20240920",
"version": "6.10.3-dev.20240925",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "6.10.2-dev.20240920"
"typia": "6.10.3-dev.20240925"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.7.0"
Expand Down
3 changes: 3 additions & 0 deletions src/programmers/llm/LlmApplicationProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export namespace LlmApplicationProgrammer {
})
: undefined,
description: props.description ?? undefined,
deprecated: props.jsDocTags.some((tag) => tag.name === "deprecated")
? true
: undefined,
});

const writeSchema = (props: {
Expand Down
17 changes: 17 additions & 0 deletions src/tags/Example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { TagBase } from "./TagBase";

export type Example<
Value extends boolean | bigint | number | string | Array<unknown> | null,
> = TagBase<{
target: "boolean" | "bigint" | "number" | "string" | "array";
kind: "example";
value: Value;
exclusive: true;
schema: Value extends bigint
? { example: Numeric<Value> }
: { example: Value };
}>;

type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
? N
: never;
16 changes: 16 additions & 0 deletions src/tags/Examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TagBase } from "./TagBase";

export type Examples<
Dict extends Record<
string,
boolean | bigint | number | string | Array<unknown> | null
>,
> = TagBase<{
target: "boolean" | "bigint" | "number" | "string" | "array";
kind: "examples";
value: Dict;
exclusive: true;
schema: {
examples: Dict;
};
}>;
2 changes: 2 additions & 0 deletions src/tags/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from "./Constant";
export * from "./ContentMediaType";
export * from "./Default";
export * from "./Example";
export * from "./Examples";
export * from "./ExclusiveMaximum";
export * from "./ExclusiveMinimum";
export * from "./Format";
Expand Down
2 changes: 1 addition & 1 deletion test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"typia": "../typia-6.10.2-dev.20240920.tgz"
"typia": "../typia-6.10.3-dev.20240925.tgz"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.2-dev.20240920.tgz"
"typia": "../typia-6.10.3-dev.20240925.tgz"
}
}
115 changes: 115 additions & 0 deletions test/schemas/json/v3_0/UltimateUnion.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand All @@ -145,6 +154,13 @@
],
"description": "Constant value type."
},
"Recordstringany": {
"type": "object",
"properties": {},
"nullable": false,
"description": "Construct a type with a set of properties K of type T",
"additionalProperties": {}
},
"OpenApi.IJsonSchema.IBoolean": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -175,6 +191,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -240,6 +265,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -305,6 +339,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -368,6 +411,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -421,6 +473,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -523,6 +584,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -615,6 +685,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -645,6 +724,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -717,6 +805,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down Expand Up @@ -755,6 +852,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand All @@ -780,6 +886,15 @@
"type": "boolean",
"title": "Whether the type is deprecated or not",
"description": "Whether the type is deprecated or not."
},
"example": {
"title": "Example value",
"description": "Example value."
},
"examples": {
"$ref": "#/components/schemas/Recordstringany",
"title": "List of example values as key-value pairs",
"description": "List of example values as key-value pairs."
}
},
"nullable": false,
Expand Down
Loading

0 comments on commit 16cff2d

Please sign in to comment.