@samchon/openapi
Advanced tools
Comparing version 2.0.0-dev.20241110-2 to 2.0.0-dev.20241111-2
@@ -62,7 +62,10 @@ "use strict"; | ||
if (OpenApiTypeChecker_1.OpenApiTypeChecker.isReference(props.schema)) { | ||
var key = props.schema.$ref.split("#/components/schemas/")[1]; | ||
var target = (_a = props.components.schemas) === null || _a === void 0 ? void 0 : _a[key]; | ||
var key_1 = props.schema.$ref.split("#/components/schemas/")[1]; | ||
var target = (_a = props.components.schemas) === null || _a === void 0 ? void 0 : _a[key_1]; | ||
if (target === undefined) | ||
return null; | ||
props.$defs[key] = {}; | ||
var out = function () { return (__assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key_1) })); }; | ||
if (props.$defs[key_1] !== undefined) | ||
return out(); | ||
props.$defs[key_1] = {}; | ||
var converted = convertSchema({ | ||
@@ -75,4 +78,4 @@ components: props.components, | ||
return null; | ||
props.$defs[key] = converted; | ||
return __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key) }); | ||
props.$defs[key_1] = converted; | ||
return out(); | ||
} | ||
@@ -152,3 +155,16 @@ else if (OpenApiTypeChecker_1.OpenApiTypeChecker.isArray(props.schema)) { | ||
return null; | ||
return __assign(__assign({}, props.schema), { oneOf: oneOf.filter(function (v) { return v !== null; }) }); | ||
return __assign(__assign({}, props.schema), { oneOf: oneOf.filter(function (v) { return v !== null; }), discriminator: props.schema.discriminator | ||
? { | ||
propertyName: props.schema.discriminator.propertyName, | ||
mapping: props.schema.discriminator.mapping | ||
? Object.fromEntries(Object.entries(props.schema.discriminator.mapping).map(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
return [ | ||
key, | ||
value.replace("#/components/schemas/", "#/$defs/"), | ||
]; | ||
})) | ||
: undefined, | ||
} | ||
: undefined }); | ||
} | ||
@@ -155,0 +171,0 @@ return props.schema; |
@@ -71,3 +71,3 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpLlmApplication<Model extends IHttpLlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema = IHttpLlmApplication.ModelSchema[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
export interface IHttpLlmApplication<Model extends IHttpLlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema = IHttpLlmApplication.ModelSchema[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
/** | ||
@@ -103,3 +103,3 @@ * Model of the target LLM. | ||
"3.1": ILlmSchemaV3_1; | ||
chatgpt: IChatGptSchema; | ||
chatgpt: IChatGptSchema.ITop; | ||
gemini: IGeminiSchema; | ||
@@ -144,3 +144,3 @@ }; | ||
*/ | ||
interface IOptions<Model extends IHttpLlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema = IHttpLlmApplication.ModelSchema[Model]> { | ||
interface IOptions<Model extends IHttpLlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema = IHttpLlmApplication.ModelSchema[Model]> { | ||
/** | ||
@@ -147,0 +147,0 @@ * Whether the parameters are keyworded or not. |
@@ -59,3 +59,3 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpLlmFunction<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema, Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
export interface IHttpLlmFunction<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema, Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
/** | ||
@@ -215,3 +215,3 @@ * HTTP method of the endpoint. | ||
*/ | ||
interface ISeparated<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema> { | ||
interface ISeparated<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema> { | ||
/** | ||
@@ -229,3 +229,3 @@ * Parameters that would be composed by the LLM. | ||
*/ | ||
interface ISeparatedParameter<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema> { | ||
interface ISeparatedParameter<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema> { | ||
/** | ||
@@ -232,0 +232,0 @@ * Index of the parameter. |
@@ -36,3 +36,3 @@ import { IChatGptSchema } from "./IChatGptSchema"; | ||
*/ | ||
export interface ILlmApplication<Model extends ILlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema = ILlmApplication.ModelSchema[Model]> { | ||
export interface ILlmApplication<Model extends ILlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema = ILlmApplication.ModelSchema[Model]> { | ||
/** | ||
@@ -58,3 +58,3 @@ * Model of the LLM. | ||
"3.1": ILlmSchemaV3_1; | ||
chatgpt: IChatGptSchema; | ||
chatgpt: IChatGptSchema.ITop; | ||
gemini: IGeminiSchema; | ||
@@ -65,3 +65,3 @@ }; | ||
*/ | ||
interface IOptions<Model extends ILlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema = ILlmApplication.ModelSchema[Model]> { | ||
interface IOptions<Model extends ILlmApplication.Model, Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema = ILlmApplication.ModelSchema[Model]> { | ||
/** | ||
@@ -68,0 +68,0 @@ * Whether to allow recursive types or not. |
@@ -27,3 +27,3 @@ import { IChatGptSchema } from "./IChatGptSchema"; | ||
*/ | ||
export interface ILlmFunction<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema> { | ||
export interface ILlmFunction<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema> { | ||
/** | ||
@@ -79,3 +79,3 @@ * Representative name of the function. | ||
*/ | ||
interface ISeparated<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema> { | ||
interface ISeparated<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema> { | ||
/** | ||
@@ -93,3 +93,3 @@ * Parameters that would be composed by the LLM. | ||
*/ | ||
interface ISeparatedParameter<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema> { | ||
interface ISeparatedParameter<Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema.ITop | IGeminiSchema> { | ||
/** | ||
@@ -96,0 +96,0 @@ * Index of the parameter. |
{ | ||
"name": "@samchon/openapi", | ||
"version": "2.0.0-dev.20241110-2", | ||
"version": "2.0.0-dev.20241111-2", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -33,2 +33,7 @@ import { OpenApi } from "../OpenApi"; | ||
const out = () => ({ | ||
...props.schema, | ||
$ref: `#/$defs/${key}`, | ||
}); | ||
if (props.$defs[key] !== undefined) return out(); | ||
props.$defs[key] = {}; | ||
@@ -43,6 +48,3 @@ const converted: IChatGptSchema | null = convertSchema({ | ||
props.$defs[key] = converted; | ||
return { | ||
...props.schema, | ||
$ref: `#/$defs/${key}`, | ||
}; | ||
return out(); | ||
} else if (OpenApiTypeChecker.isArray(props.schema)) { | ||
@@ -133,2 +135,17 @@ const items: IChatGptSchema | null = convertSchema({ | ||
oneOf: oneOf.filter((v) => v !== null), | ||
discriminator: props.schema.discriminator | ||
? { | ||
propertyName: props.schema.discriminator.propertyName, | ||
mapping: props.schema.discriminator.mapping | ||
? Object.fromEntries( | ||
Object.entries(props.schema.discriminator.mapping).map( | ||
([key, value]) => [ | ||
key, | ||
value.replace("#/components/schemas/", "#/$defs/"), | ||
], | ||
), | ||
) | ||
: undefined, | ||
} | ||
: undefined, | ||
}; | ||
@@ -135,0 +152,0 @@ } |
@@ -70,3 +70,3 @@ export type IChatGptSchema = | ||
* For reference, even though your Swagger (or OpenAPI) document has | ||
* defined the `exclusiveMinimum` value as `number`, {@link OpenApi} | ||
* defined the `exclusiveMinimum` value as `number`, {@link IChatGptSchema} | ||
* forcibly converts it to `boolean` type, and assign the numeric value to | ||
@@ -81,3 +81,3 @@ * the {@link minimum} property. | ||
* For reference, even though your Swagger (or OpenAPI) document has | ||
* defined the `exclusiveMaximum` value as `number`, {@link OpenApi} | ||
* defined the `exclusiveMaximum` value as `number`, {@link IChatGptSchema} | ||
* forcibly converts it to `boolean` type, and assign the numeric value to | ||
@@ -380,7 +380,7 @@ * the {@link maximum} property. | ||
* following the JSON Pointer specification. In the OpenAPI, the `$ref` | ||
* starts with `#/components/schemas/` which means the type is stored in | ||
* the {@link OpenApi.IComponents.schemas} object. | ||
* starts with `#/$defs/` which means the type is stored in | ||
* the {@link IChatGptSchema.ITop.$defs} object. | ||
* | ||
* - `#/components/schemas/SomeObject` | ||
* - `#/components/schemas/AnotherObject` | ||
* - `#/$defs/SomeObject` | ||
* - `#/$defs/AnotherObject` | ||
*/ | ||
@@ -396,3 +396,3 @@ $ref: Key; | ||
* For reference, even though your Swagger (or OpenAPI) document has | ||
* defined `anyOf` instead of the `oneOf`, {@link OpenApi} forcibly | ||
* defined `anyOf` instead of the `oneOf`, {@link IChatGptSchema} forcibly | ||
* converts it to `oneOf` type. | ||
@@ -427,3 +427,3 @@ */ | ||
* the discriminator value, and `value` of `mapping` is the | ||
* schema name like `#/components/schemas/SomeObject`. | ||
* schema name like `#/$defs/SomeObject`. | ||
*/ | ||
@@ -430,0 +430,0 @@ mapping?: Record<string, string>; |
@@ -77,3 +77,3 @@ import { OpenApi } from "../OpenApi"; | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema = IHttpLlmApplication.ModelSchema[Model], | ||
@@ -116,3 +116,3 @@ Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
"3.1": ILlmSchemaV3_1; | ||
chatgpt: IChatGptSchema; | ||
chatgpt: IChatGptSchema.ITop; | ||
gemini: IGeminiSchema; | ||
@@ -171,3 +171,3 @@ }; | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema = IHttpLlmApplication.ModelSchema[Model], | ||
@@ -174,0 +174,0 @@ > { |
@@ -61,3 +61,7 @@ import { OpenApi } from "../OpenApi"; | ||
export interface IHttpLlmFunction< | ||
Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema, | ||
Schema extends | ||
| ILlmSchemaV3 | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
@@ -235,3 +239,3 @@ Route extends IHttpMigrateRoute = IHttpMigrateRoute, | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
@@ -257,3 +261,3 @@ > { | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
@@ -260,0 +264,0 @@ > { |
@@ -42,3 +42,3 @@ import { IChatGptSchema } from "./IChatGptSchema"; | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema = ILlmApplication.ModelSchema[Model], | ||
@@ -68,3 +68,3 @@ > { | ||
"3.1": ILlmSchemaV3_1; | ||
chatgpt: IChatGptSchema; | ||
chatgpt: IChatGptSchema.ITop; | ||
gemini: IGeminiSchema; | ||
@@ -81,3 +81,3 @@ }; | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema = ILlmApplication.ModelSchema[Model], | ||
@@ -84,0 +84,0 @@ > { |
@@ -29,3 +29,7 @@ import { IChatGptSchema } from "./IChatGptSchema"; | ||
export interface ILlmFunction< | ||
Schema extends ILlmSchemaV3 | ILlmSchemaV3_1 | IChatGptSchema | IGeminiSchema, | ||
Schema extends | ||
| ILlmSchemaV3 | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
> { | ||
@@ -92,3 +96,3 @@ /** | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
@@ -114,3 +118,3 @@ > { | ||
| ILlmSchemaV3_1 | ||
| IChatGptSchema | ||
| IChatGptSchema.ITop | ||
| IGeminiSchema, | ||
@@ -117,0 +121,0 @@ > { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1484608
26004