Skip to content

Commit

Permalink
Merge pull request #128 from samchon/feat/enum
Browse files Browse the repository at this point in the history
Fix #127: ChatGPT and Gemini schema had dropped enum typed description.
  • Loading branch information
samchon authored Jan 23, 2025
2 parents 181da93 + 9106183 commit fecf39a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samchon/openapi",
"version": "2.4.0",
"version": "2.4.1",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
Expand Down Expand Up @@ -75,7 +75,7 @@
"tstl": "^3.0.0",
"typescript": "~5.7.2",
"typescript-transform-paths": "^3.5.2",
"typia": "7.3.0",
"typia": "7.6.0",
"uuid": "^10.0.0"
},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion src/composers/llm/ChatGptSchemaComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export namespace ChatGptSchemaComposer {
...union[0],
description: ChatGptTypeChecker.isReference(union[0]!)
? undefined
: union[0].description,
: (union[0].description ?? attribute.description),
};
return {
...attribute,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/internal/OpenApiTypeCheckerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export namespace OpenApiTypeCheckerBase {
) as OpenApi.IJsonSchema[];
if (filtered.length === 0) return undefined;
return {
...props,
...props.schema,
oneOf: filtered
.map((v) =>
flatSchema({
Expand Down
32 changes: 32 additions & 0 deletions test/features/issues/test_issue_127_enum_description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { TestValidator } from "@nestia/e2e";
import { OpenApi } from "@samchon/openapi";
import { LlmSchemaComposer } from "@samchon/openapi/lib/composers/LlmSchemaComposer";
import typia, { IJsonSchemaCollection } from "typia";

export const test_issue_127_enum_description = (): void => {
const collection: IJsonSchemaCollection = typia.json.schemas<[ISomething]>();
const chatgpt = LlmSchemaComposer.parameters("chatgpt")({
config: LlmSchemaComposer.defaultConfig("chatgpt"),
components: collection.components,
schema: collection.schemas[0] as OpenApi.IJsonSchema.IReference,
});
TestValidator.equals("description")(
chatgpt.success ? chatgpt.value.properties.value.description : "",
)("The description.");

const gemini = LlmSchemaComposer.parameters("gemini")({
config: LlmSchemaComposer.defaultConfig("gemini"),
components: collection.components,
schema: collection.schemas[0] as OpenApi.IJsonSchema.IReference,
});
TestValidator.equals("description")(
gemini.success ? gemini.value.properties.value.description : "",
)("The description.");
};

interface ISomething {
/**
* The description.
*/
value: 1 | 2 | 3;
}

0 comments on commit fecf39a

Please sign in to comment.