Skip to content

Commit

Permalink
Fix IOpenAiSchema's nested type problem
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Sep 20, 2024
1 parent 345402c commit 2877be5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wrtnio/schema",
"version": "1.0.2",
"version": "1.0.3",
"description": "JSON and LLM function calling schemas extended for Wrtn Studio Pro",
"main": "lib/index.js",
"module": "./lib/index.mjs",
Expand Down
53 changes: 50 additions & 3 deletions src/IOpenAiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,52 @@ export namespace IOpenAiSchema {
/**
* Array type schema info.
*/
export interface IArray extends ILlmSchema.IArray, ISwaggerSchemaPlugin {}
export interface IArray
extends Omit<ILlmSchema.IArray, "items">,
ISwaggerSchemaPlugin {
/**
* Items type schema info.
*
* The `items` means the type of the array elements. In other words, it is
* the type schema info of the `T` in the TypeScript array type `Array<T>`.
*/
items: IOpenAiSchema;
}

/**
* Object type schema info.
*/
export interface IObject extends ILlmSchema.IObject, ISwaggerSchemaPlugin {}
export interface IObject
extends Omit<ILlmSchema.IObject, "properties" | "additionalProperties">,
ISwaggerSchemaPlugin {
/**
* Properties of the object.
*
* The `properties` means a list of key-value pairs of the object's
* regular properties. The key is the name of the regular property,
* and the value is the type schema info.
*
* If you need additional properties that is represented by dynamic key,
* you can use the {@link additionalProperties} instead.
*/
properties?: Record<string, IOpenAiSchema>;

/**
* Additional properties' info.
*
* The `additionalProperties` means the type schema info of the additional
* properties that are not listed in the {@link properties}.
*
* If the value is `true`, it means that the additional properties are not
* restricted. They can be any type. Otherwise, if the value is
* {@link ILlmSchema} type, it means that the additional properties must
* follow the type schema info.
*
* - `true`: `Record<string, any>`
* - `ILlmSchema`: `Record<string, T>`
*/
additionalProperties?: boolean | IOpenAiSchema;
}

/**
* Unknown type schema info.
Expand All @@ -103,5 +143,12 @@ export namespace IOpenAiSchema {
* defined `anyOf` instead of the `oneOf`, {@link OpenAiComposer} forcibly
* converts it to `oneOf` type.
*/
export interface IOneOf extends ILlmSchema.IOneOf, ISwaggerSchemaPlugin {}
export interface IOneOf
extends Omit<ILlmSchema.IOneOf, "oneOf">,
ISwaggerSchemaPlugin {
/**
* List of the union types.
*/
oneOf: Exclude<IOpenAiSchema, IOpenAiSchema.IOneOf>[];
}
}

0 comments on commit 2877be5

Please sign in to comment.