Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt typia v7 and nestia v4 for testing. #71

Merged
merged 2 commits into from
Nov 16, 2024
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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
},
"homepage": "https://github.com/samchon/openapi",
"devDependencies": {
"@nestia/core": "^3.12.0",
"@nestia/e2e": "^0.7.0",
"@nestia/fetcher": "^3.12.0",
"@nestia/sdk": "^3.12.0",
"@nestia/core": "4.0.0-dev.20241116",
"@nestia/e2e": "0.7.0",
"@nestia/fetcher": "4.0.0-dev.20241116",
"@nestia/sdk": "4.0.0-dev.20241116",
"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/platform-express": "^10.4.1",
Expand All @@ -56,7 +56,7 @@
"ts-patch": "^3.2.1",
"typescript": "^5.6.3",
"typescript-transform-paths": "^3.4.7",
"typia": "^6.9.0",
"typia": "7.0.0-dev.20241115",
"uuid": "^10.0.0"
},
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { TestValidator } from "@nestia/e2e";
import { IChatGptSchema } from "@samchon/openapi";
import { ChatGptConverter } from "@samchon/openapi/lib/converters/ChatGptConverter";
import typia, { IJsonApplication } from "typia";
import typia, { IJsonSchemaCollection } from "typia";

export const test_chatgpt_schema_oneof_discriminator = (): void => {
const collection: IJsonApplication =
typia.json.application<[IPoint | ILine | ITriangle | IRectangle]>();
const collection: IJsonSchemaCollection =
typia.json.schemas<[IPoint | ILine | ITriangle | IRectangle]>();
const schema = ChatGptConverter.schema({
components: collection.components,
schema: collection.schemas[0],
Expand Down
8 changes: 4 additions & 4 deletions test/features/llm/chatgpt/test_chatgpt_schema_ref.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestValidator } from "@nestia/e2e";
import { IChatGptSchema } from "@samchon/openapi";
import { ChatGptConverter } from "@samchon/openapi/lib/converters/ChatGptConverter";
import typia, { IJsonApplication, tags } from "typia";
import typia, { IJsonSchemaCollection, tags } from "typia";

export const test_chatgpt_schema_ref = (): void => {
test(typia.json.application<[IShoppingCategory]>(), {
test(typia.json.schemas<[IShoppingCategory]>(), {
$ref: "#/$defs/IShoppingCategory",
$defs: {
IShoppingCategory: {
Expand All @@ -29,7 +29,7 @@ export const test_chatgpt_schema_ref = (): void => {
},
},
});
test(typia.json.application<[IShoppingCategory.IInvert]>(), {
test(typia.json.schemas<[IShoppingCategory.IInvert]>(), {
$ref: "#/$defs/IShoppingCategory.IInvert",
$defs: {
"IShoppingCategory.IInvert": {
Expand Down Expand Up @@ -61,7 +61,7 @@ export const test_chatgpt_schema_ref = (): void => {
};

const test = (
collection: IJsonApplication,
collection: IJsonSchemaCollection,
expected: IChatGptSchema.ITop,
): void => {
const schema: IChatGptSchema.ITop | null = ChatGptConverter.schema({
Expand Down
4 changes: 2 additions & 2 deletions test/features/llm/test_llm_schema_object.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TestValidator } from "@nestia/e2e";
import { HttpLlm, ILlmSchemaV3 } from "@samchon/openapi";
import typia, { IJsonApplication, tags } from "typia";
import typia, { IJsonSchemaCollection, tags } from "typia";

export const test_llm_schema_object = (): void => {
const app: IJsonApplication = typia.json.application<[First]>();
const app: IJsonSchemaCollection = typia.json.schemas<[First]>();
const schema: ILlmSchemaV3 | null = HttpLlm.schema({
model: "3.0",
components: app.components,
Expand Down
6 changes: 3 additions & 3 deletions test/features/llm/test_llm_schema_oneof.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestValidator } from "@nestia/e2e";
import { HttpLlm, ILlmSchemaV3 } from "@samchon/openapi";
import typia, { IJsonApplication } from "typia";
import typia, { IJsonSchemaCollection } from "typia";

export const test_llm_schema_oneof = (): void => {
const app: IJsonApplication =
typia.json.application<[Circle | Triangle | Rectangle]>();
const app: IJsonSchemaCollection =
typia.json.schemas<[Circle | Triangle | Rectangle]>();
const casted: ILlmSchemaV3 | null = HttpLlm.schema({
model: "3.0",
components: app.components,
Expand Down
10 changes: 3 additions & 7 deletions test/features/llm/test_llm_schema_separate_array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ export const test_llm_schema_separate_array = (): void => {
LlmTypeCheckerV3.isString(s) && s.contentMediaType !== undefined,
schema,
});
const member: ILlmSchemaV3 = schema(typia.json.application<[IMember[]]>());
const upload: ILlmSchemaV3 = schema(
typia.json.application<[IFileUpload[]]>(),
);
const combined: ILlmSchemaV3 = schema(
typia.json.application<[ICombined[]]>(),
);
const member: ILlmSchemaV3 = schema(typia.json.schemas<[IMember[]]>());
const upload: ILlmSchemaV3 = schema(typia.json.schemas<[IFileUpload[]]>());
const combined: ILlmSchemaV3 = schema(typia.json.schemas<[ICombined[]]>());

TestValidator.equals("member")(separator(member))([member, null]);
TestValidator.equals("upload")(separator(upload))([null, upload]);
Expand Down
8 changes: 3 additions & 5 deletions test/features/llm/test_llm_schema_separate_nested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ export const test_llm_schema_separate_nested = (): void => {
LlmTypeCheckerV3.isString(s) && s.contentMediaType !== undefined,
schema,
});
const member: ILlmSchemaV3 = schema(
typia.json.application<[INested<IMember>]>(),
);
const member: ILlmSchemaV3 = schema(typia.json.schemas<[INested<IMember>]>());
const upload: ILlmSchemaV3 = schema(
typia.json.application<[INested<IFileUpload>]>(),
typia.json.schemas<[INested<IFileUpload>]>(),
);
const combined: ILlmSchemaV3 = schema(
typia.json.application<[INested<ICombined>]>(),
typia.json.schemas<[INested<ICombined>]>(),
);

TestValidator.equals(
Expand Down
6 changes: 3 additions & 3 deletions test/features/llm/test_llm_schema_separate_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const test_llm_schema_separate_object = (): void => {
LlmTypeCheckerV3.isString(s) && s.contentMediaType !== undefined,
schema,
});
const member: ILlmSchemaV3 = schema(typia.json.application<[IMember]>());
const upload: ILlmSchemaV3 = schema(typia.json.application<[IFileUpload]>());
const combined: ILlmSchemaV3 = schema(typia.json.application<[ICombined]>());
const member: ILlmSchemaV3 = schema(typia.json.schemas<[IMember]>());
const upload: ILlmSchemaV3 = schema(typia.json.schemas<[IFileUpload]>());
const combined: ILlmSchemaV3 = schema(typia.json.schemas<[ICombined]>());

TestValidator.equals(
"member",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpLlmConverter } from "@samchon/openapi/lib/converters/HttpLlmConvert
import typia from "typia";

export const test_llm_schema_v31_ultimate_union = (): void => {
const collection = typia.json.application<[IJsonSchemaCollection[]]>();
const collection = typia.json.schemas<[IJsonSchemaCollection[]]>();
HttpLlmConverter.schema({
model: "3.1",
components: collection.components,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestValidator } from "@nestia/e2e";
import { OpenApi, OpenApiTypeChecker } from "@samchon/openapi";
import typia, { IJsonApplication } from "typia";
import typia, { IJsonSchemaCollection } from "typia";

export const test_json_schema_type_checker_cover_array = (): void => {
const app: IJsonApplication =
typia.json.application<[Plan2D, Plan3D, Box2D, Box3D]>();
const app: IJsonSchemaCollection =
typia.json.schemas<[Plan2D, Plan3D, Box2D, Box3D]>();
const components: OpenApi.IComponents = app.components as any;

const plan2D: OpenApi.IJsonSchema = components.schemas!.Plan2D;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestValidator } from "@nestia/e2e";
import { OpenApi, OpenApiTypeChecker } from "@samchon/openapi";
import typia, { IJsonApplication } from "typia";
import typia, { IJsonSchemaCollection } from "typia";

export const test_json_schema_type_checker_cover_object = (): void => {
const app: IJsonApplication =
typia.json.application<[Plan2D, Plan3D, Box2D, Box3D]>();
const app: IJsonSchemaCollection =
typia.json.schemas<[Plan2D, Plan3D, Box2D, Box3D]>();
const components: OpenApi.IComponents = app.components as any;

const plan2D: OpenApi.IJsonSchema = components.schemas!.Plan2D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export const test_json_schema_type_checker_cover_string = (): void => {
);

// CHECK FORMAT CASE
for (const x of typia.misc.literals<keyof tags.Format.Validator>())
for (const y of typia.misc.literals<keyof tags.Format.Validator>())
for (const x of typia.misc.literals<tags.Format.Value>())
for (const y of typia.misc.literals<tags.Format.Value>())
TestValidator.equals(`format ${x} covers ${y}`)(
x === y ||
(x === "idn-email" && y === "email") ||
Expand Down