-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
gemini
schema's oneOf
detection logic.
- Loading branch information
Showing
6 changed files
with
126 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { TestValidator } from "@nestia/e2e"; | ||
import { LlmSchemaConverter } from "@samchon/openapi/lib/converters/LlmSchemaConverter"; | ||
import typia, { IJsonSchemaCollection, tags } from "typia"; | ||
|
||
export const test_gemini_schema_enum = (): void => { | ||
const collection: IJsonSchemaCollection = | ||
typia.json.schemas< | ||
[ | ||
0 | 1 | 2, | ||
(number & {}) | 1.2 | 2.3 | 3.4, | ||
(number & tags.Type<"int32">) | 1 | 2 | 3, | ||
"one" | "two" | "three", | ||
] | ||
>(); | ||
for (const schema of collection.schemas) { | ||
const errors: string[] = []; | ||
const gemini = LlmSchemaConverter.schema("gemini")({ | ||
config: LlmSchemaConverter.defaultConfig("gemini"), | ||
components: collection.components, | ||
schema, | ||
errors, | ||
}); | ||
TestValidator.equals("success")(!!gemini)(true); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { TestValidator } from "@nestia/e2e"; | ||
import { LlmSchemaConverter } from "@samchon/openapi/lib/converters/LlmSchemaConverter"; | ||
import typia, { IJsonSchemaCollection } from "typia"; | ||
|
||
export const test_gemini_schema_nullable = (): void => { | ||
const collection: IJsonSchemaCollection = typia.json.schemas< | ||
[ | ||
0 | 1 | 2 | 3 | null, | ||
(number & {}) | 1.2 | 2.3 | 3.4 | null, | ||
{ | ||
id: string | null; | ||
value: number; | ||
} | null, | ||
Array<number> | null, | ||
Array<{ | ||
nested: Array<{ | ||
id: string | null; | ||
}>; | ||
nullable: Array<string | null>; | ||
}>, | ||
{ | ||
first: ToJsonNull; | ||
second: ToJsonNull | null; | ||
}, | ||
{ | ||
first: ToJsonNull | null; | ||
second: ToJsonNull | null; | ||
third?: ToJsonNull | null; | ||
}, | ||
] | ||
>(); | ||
for (const schema of collection.schemas) { | ||
const errors: string[] = []; | ||
const gemini = LlmSchemaConverter.schema("gemini")({ | ||
config: LlmSchemaConverter.defaultConfig("gemini"), | ||
components: collection.components, | ||
schema, | ||
errors, | ||
}); | ||
TestValidator.equals("success")(!!gemini)(true); | ||
} | ||
}; | ||
|
||
interface ToJsonNull { | ||
toJSON: () => null; | ||
} |