diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5f4571d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +version: 2 +updates: + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'daily' + open-pull-requests-limit: 25 + allow: + - dependency-name: "@samchon/openapi" + - dependency-name: "@nestjs/*" + - dependency-name: "@nestia/*" + - dependency-name: "nestia" + - dependency-name: "typia" + - dependency-name: "typescript" + - dependency-name: "ts-patch" + groups: + Samchon: + patterns: + - "@samchon/openapi" + - "@nestia/*" + - "nestia" + - "typia" + NestJS: + patterns: + - "@nestjs/*" + TypeScript: + patterns: + - "typescript" + - "ts-patch" \ No newline at end of file diff --git a/package.json b/package.json index 6999b09..9869a0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wrtnio/openai-function-schema", - "version": "0.1.4", + "version": "0.2.0", "description": "OpenAI LLM function schema from OpenAPI (Swagger) document", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -37,16 +37,16 @@ "author": "", "license": "ISC", "dependencies": { - "@nestia/fetcher": "^3.5.0", - "@samchon/openapi": "^0.3.4", + "@nestia/fetcher": "^3.7.0", + "@samchon/openapi": "^0.4.2", "commander": "^10.0.0", "inquirer": "^8.2.5", - "typia": "^6.4.3" + "typia": "^6.5.0" }, "devDependencies": { - "@nestia/core": "^3.5.0", + "@nestia/core": "^3.7.0", "@nestia/e2e": "^0.7.0", - "@nestia/sdk": "^3.5.0", + "@nestia/sdk": "^3.7.0", "@nestjs/common": "^10.3.10", "@nestjs/core": "^10.3.10", "@nestjs/platform-express": "^10.3.10", diff --git a/src/OpenAiComposer.ts b/src/OpenAiComposer.ts index 7802423..756a2e1 100644 --- a/src/OpenAiComposer.ts +++ b/src/OpenAiComposer.ts @@ -63,7 +63,7 @@ export namespace OpenAiComposer { /** * Migrate document from Swagger. * - * If you've already migrated from the Swagger document, you can pass it. + * If you've already migrated from the Swagger document, you can re-use it. */ migrate?: ISwaggerMigrate; } @@ -186,10 +186,40 @@ export namespace OpenAiComposer { route.success && route.success ? cast(route.success.schema) : undefined; if (output === null) return null; const properties: [string, IOpenAiSchema | null][] = [ - ...route.parameters, - ...(route.query ? [route.query] : []), - ...(route.body ? [route.body] : []), - ].map((p) => [p.key, cast(p.schema)]); + ...route.parameters.map((p) => ({ + key: p.key, + schema: { + ...p.schema, + title: p.parameter().title ?? p.schema.title, + description: p.parameter().description ?? p.schema.description, + }, + })), + ...(route.query + ? [ + { + key: route.query.key, + schema: { + ...route.query.schema, + title: route.query.title() ?? route.query.schema.title, + description: + route.query.description() ?? route.query.schema.description, + }, + }, + ] + : []), + ...(route.body + ? [ + { + key: route.body.key, + schema: { + ...route.body.schema, + description: + route.body.description() ?? route.body.schema.description, + }, + }, + ] + : []), + ].map((o) => [o.key, cast(o.schema)]); if (properties.some(([_k, v]) => v === null)) return null; // COMPOSE PARAMETERS diff --git a/test/features/composer/test_composer_schema.ts b/test/features/composer/test_composer_schema.ts index 31a2760..2ca3d28 100644 --- a/test/features/composer/test_composer_schema.ts +++ b/test/features/composer/test_composer_schema.ts @@ -15,14 +15,17 @@ export const test_composer_schema = (): void => { second: { type: "object", required: ["third"], + description: "The second property", properties: { third: { type: "object", required: ["id"], + description: "The third property", properties: { id: { type: "string", format: "uuid", + description: "Hello word", }, }, }, @@ -33,11 +36,20 @@ export const test_composer_schema = (): void => { }; interface First { + /** + * The second property + */ second: Second; } interface Second { + /** + * The third property + */ third: Third; } interface Third { + /** + * Hello word + */ id: string & tags.Format<"uuid">; }