-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix additionalProperties's separation problem
- Loading branch information
Showing
4 changed files
with
90 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { TestValidator } from "@nestia/e2e"; | ||
import { IHttpOpenAiFunction, IOpenAiSchema } from "@wrtnio/schema"; | ||
import { LlmDataMerger } from "@wrtnio/schema/lib/internal/HttpOpenAiMerger"; | ||
|
||
export const test_http_llm_merge_parameters = (): void => { | ||
const p = LlmDataMerger.parameters({ | ||
function: { | ||
parameters: [ | ||
{ | ||
type: "array", | ||
items: {}, | ||
}, | ||
] satisfies IOpenAiSchema[], | ||
separated: { | ||
human: [ | ||
{ | ||
index: 0, | ||
schema: { | ||
type: "array", | ||
items: {}, | ||
}, | ||
}, | ||
], | ||
llm: [ | ||
{ | ||
index: 0, | ||
schema: { | ||
type: "array", | ||
items: {}, | ||
}, | ||
}, | ||
], | ||
} satisfies IHttpOpenAiFunction.ISeparated, | ||
} as IHttpOpenAiFunction, | ||
llm: [], | ||
human: [ | ||
{ | ||
a: 1, | ||
}, | ||
], | ||
}); | ||
TestValidator.equals(p as any)([ | ||
{ | ||
a: 1, | ||
}, | ||
]); | ||
}; |
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,31 @@ | ||
import { TestValidator } from "@nestia/e2e"; | ||
import { OpenApi } from "@samchon/openapi"; | ||
import { HttpOpenAi, OpenAiTypeChecker } from "@wrtnio/schema"; | ||
import typia from "typia"; | ||
|
||
export const test_http_llm_separate_parameters = async (): Promise<void> => { | ||
const document: OpenApi.IDocument = typia.assert<OpenApi.IDocument>( | ||
await fetch( | ||
"https://wrtnio.github.io/connectors/swagger/swagger.json", | ||
).then((r) => r.json()), | ||
); | ||
for (const path of Object.keys(document.paths ?? {})) | ||
if (path !== "/connector/notion/database-item/{databaseId}") | ||
delete document.paths?.[path]; | ||
|
||
const app = HttpOpenAi.application({ | ||
document, | ||
options: { | ||
separate: (schema) => | ||
OpenAiTypeChecker.isString(schema) && | ||
schema["x-wrtn-secret-key"] !== undefined, | ||
}, | ||
}); | ||
const func = app.functions.find( | ||
(f) => | ||
f.method === "post" && | ||
f.path === "/connector/notion/database-item/{databaseId}", | ||
); | ||
if (func === undefined) throw new Error("Function not found"); | ||
TestValidator.equals("human")(func.separated?.human.at(0)?.index)(1); | ||
}; |