Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 5fc078f

Browse files
authored
Merge pull request #15 from wrtnio/features/migrate
Break change from `@samchon/openapi`.
2 parents 7c575a7 + 5897483 commit 5fc078f

File tree

4 files changed

+82
-11
lines changed

4 files changed

+82
-11
lines changed

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'npm'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'
7+
open-pull-requests-limit: 25
8+
allow:
9+
- dependency-name: "@samchon/openapi"
10+
- dependency-name: "@nestjs/*"
11+
- dependency-name: "@nestia/*"
12+
- dependency-name: "nestia"
13+
- dependency-name: "typia"
14+
- dependency-name: "typescript"
15+
- dependency-name: "ts-patch"
16+
groups:
17+
Samchon:
18+
patterns:
19+
- "@samchon/openapi"
20+
- "@nestia/*"
21+
- "nestia"
22+
- "typia"
23+
NestJS:
24+
patterns:
25+
- "@nestjs/*"
26+
TypeScript:
27+
patterns:
28+
- "typescript"
29+
- "ts-patch"

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wrtnio/openai-function-schema",
3-
"version": "0.1.4",
3+
"version": "0.2.0",
44
"description": "OpenAI LLM function schema from OpenAPI (Swagger) document",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -37,16 +37,16 @@
3737
"author": "",
3838
"license": "ISC",
3939
"dependencies": {
40-
"@nestia/fetcher": "^3.5.0",
41-
"@samchon/openapi": "^0.3.4",
40+
"@nestia/fetcher": "^3.7.0",
41+
"@samchon/openapi": "^0.4.2",
4242
"commander": "^10.0.0",
4343
"inquirer": "^8.2.5",
44-
"typia": "^6.4.3"
44+
"typia": "^6.5.0"
4545
},
4646
"devDependencies": {
47-
"@nestia/core": "^3.5.0",
47+
"@nestia/core": "^3.7.0",
4848
"@nestia/e2e": "^0.7.0",
49-
"@nestia/sdk": "^3.5.0",
49+
"@nestia/sdk": "^3.7.0",
5050
"@nestjs/common": "^10.3.10",
5151
"@nestjs/core": "^10.3.10",
5252
"@nestjs/platform-express": "^10.3.10",

src/OpenAiComposer.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export namespace OpenAiComposer {
6363
/**
6464
* Migrate document from Swagger.
6565
*
66-
* If you've already migrated from the Swagger document, you can pass it.
66+
* If you've already migrated from the Swagger document, you can re-use it.
6767
*/
6868
migrate?: ISwaggerMigrate;
6969
}
@@ -186,10 +186,40 @@ export namespace OpenAiComposer {
186186
route.success && route.success ? cast(route.success.schema) : undefined;
187187
if (output === null) return null;
188188
const properties: [string, IOpenAiSchema | null][] = [
189-
...route.parameters,
190-
...(route.query ? [route.query] : []),
191-
...(route.body ? [route.body] : []),
192-
].map((p) => [p.key, cast(p.schema)]);
189+
...route.parameters.map((p) => ({
190+
key: p.key,
191+
schema: {
192+
...p.schema,
193+
title: p.parameter().title ?? p.schema.title,
194+
description: p.parameter().description ?? p.schema.description,
195+
},
196+
})),
197+
...(route.query
198+
? [
199+
{
200+
key: route.query.key,
201+
schema: {
202+
...route.query.schema,
203+
title: route.query.title() ?? route.query.schema.title,
204+
description:
205+
route.query.description() ?? route.query.schema.description,
206+
},
207+
},
208+
]
209+
: []),
210+
...(route.body
211+
? [
212+
{
213+
key: route.body.key,
214+
schema: {
215+
...route.body.schema,
216+
description:
217+
route.body.description() ?? route.body.schema.description,
218+
},
219+
},
220+
]
221+
: []),
222+
].map((o) => [o.key, cast(o.schema)]);
193223
if (properties.some(([_k, v]) => v === null)) return null;
194224

195225
// COMPOSE PARAMETERS

test/features/composer/test_composer_schema.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ export const test_composer_schema = (): void => {
1515
second: {
1616
type: "object",
1717
required: ["third"],
18+
description: "The second property",
1819
properties: {
1920
third: {
2021
type: "object",
2122
required: ["id"],
23+
description: "The third property",
2224
properties: {
2325
id: {
2426
type: "string",
2527
format: "uuid",
28+
description: "Hello word",
2629
},
2730
},
2831
},
@@ -33,11 +36,20 @@ export const test_composer_schema = (): void => {
3336
};
3437

3538
interface First {
39+
/**
40+
* The second property
41+
*/
3642
second: Second;
3743
}
3844
interface Second {
45+
/**
46+
* The third property
47+
*/
3948
third: Third;
4049
}
4150
interface Third {
51+
/**
52+
* Hello word
53+
*/
4254
id: string & tags.Format<"uuid">;
4355
}

0 commit comments

Comments
 (0)