Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
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
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
40 changes: 35 additions & 5 deletions src/OpenAiComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/features/composer/test_composer_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand All @@ -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">;
}